ну да, не добавил
This commit is contained in:
parent
cc5c85bef1
commit
8540448bdc
@ -31,6 +31,7 @@ import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2dTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2fTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector2iTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector4dTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.Vector4iTypeAdapter
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
||||
import ru.dbotthepony.kstarbound.math.PolyTypeAdapter
|
||||
@ -51,6 +52,7 @@ fun addStarboundJsonAdapters(builder: GsonBuilder) {
|
||||
registerTypeAdapter(Vector2fTypeAdapter)
|
||||
registerTypeAdapter(Vector2iTypeAdapter)
|
||||
registerTypeAdapter(Vector4iTypeAdapter)
|
||||
registerTypeAdapter(Vector4dTypeAdapter)
|
||||
registerTypeAdapter(PolyTypeAdapter)
|
||||
|
||||
// Снаряды
|
||||
|
@ -5,12 +5,14 @@ import com.google.common.collect.ImmutableMap
|
||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector4d
|
||||
|
||||
@JsonFactory
|
||||
data class AnimationDefinition(
|
||||
val animatedParts: AnimatedParts? = null,
|
||||
val sounds: ImmutableMap<String, Sound> = ImmutableMap.of(),
|
||||
val transformationGroups: ImmutableMap<String, TransformConfig> = ImmutableMap.of(),
|
||||
val particleEmitters: ImmutableMap<String, ParticleEmitter> = ImmutableMap.of(),
|
||||
) {
|
||||
@JsonFactory
|
||||
data class TransformConfig(
|
||||
@ -25,6 +27,11 @@ data class AnimationDefinition(
|
||||
|
||||
@JsonFactory
|
||||
data class ParticleEmitter(
|
||||
val enabled: Boolean = true,
|
||||
val emissionRate: Double = 1.0,
|
||||
val count: Int = 1,
|
||||
val offset: Vector2d? = null,
|
||||
val offsetRegion: Vector4d? = null,
|
||||
val transformationGroups: ImmutableList<String> = ImmutableList.of(),
|
||||
val particles: ImmutableList<ParticleDefinition>
|
||||
)
|
||||
|
@ -1,6 +1,6 @@
|
||||
package ru.dbotthepony.kstarbound.defs.animation
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import ru.dbotthepony.kstarbound.defs.AssetReference
|
||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
@ -9,14 +9,14 @@ import ru.dbotthepony.kvector.vector.ndouble.Vector4d
|
||||
@JsonFactory
|
||||
data class ParticleDefinition(
|
||||
val count: Int = 1,
|
||||
val offset: Vector2d = Vector2d.ZERO,
|
||||
val offsetRegion: Vector4d = Vector4d.ZERO,
|
||||
val particles: ImmutableList<Config>,
|
||||
val offset: Vector2d? = null,
|
||||
val offsetRegion: Vector4d? = null,
|
||||
val particle: Config,
|
||||
) {
|
||||
@JsonFactory
|
||||
data class Config(
|
||||
val type: ParticleType,
|
||||
val animation: AnimationDefinition? = null,
|
||||
val animation: AssetReference<AnimationDefinition>? = null,
|
||||
val image: SpriteReference? = null,
|
||||
val position: Vector2d = Vector2d.ZERO,
|
||||
val offsetRegion: Vector4d = Vector4d.ZERO,
|
||||
@ -24,11 +24,11 @@ data class ParticleDefinition(
|
||||
val finalVelocity: Vector2d = Vector2d.ZERO,
|
||||
val approach: Vector2d = Vector2d.ZERO,
|
||||
val angularVelocity: Double = 0.0,
|
||||
val destructionAction: DestructionAction,
|
||||
val destructionTime: Double,
|
||||
val destructionAction: DestructionAction? = null,
|
||||
val destructionTime: Double? = null,
|
||||
val fade: Double = 0.0,
|
||||
val size: Double = 1.0,
|
||||
val layer: ParticleLayer,
|
||||
val layer: ParticleLayer? = null,
|
||||
val timeToLive: Double = 1.0,
|
||||
val variance: Variance = Variance.EMPTY
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonWriter
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||
import ru.dbotthepony.kvector.vector.ndouble.Vector4d
|
||||
import ru.dbotthepony.kvector.vector.nfloat.Vector2f
|
||||
import ru.dbotthepony.kvector.vector.nint.Vector2i
|
||||
import ru.dbotthepony.kvector.vector.nint.Vector4i
|
||||
@ -32,6 +33,30 @@ object Vector4iTypeAdapter : TypeAdapter<Vector4i>() {
|
||||
}
|
||||
}
|
||||
|
||||
object Vector4dTypeAdapter : TypeAdapter<Vector4d>() {
|
||||
override fun write(out: JsonWriter, value: Vector4d) {
|
||||
`out`.beginArray()
|
||||
`out`.value(value.x)
|
||||
`out`.value(value.y)
|
||||
`out`.value(value.z)
|
||||
`out`.value(value.w)
|
||||
`out`.endArray()
|
||||
}
|
||||
|
||||
override fun read(`in`: JsonReader): Vector4d {
|
||||
`in`.beginArray()
|
||||
|
||||
val x = `in`.nextDouble()
|
||||
val y = `in`.nextDouble()
|
||||
val z = `in`.nextDouble()
|
||||
val w = `in`.nextDouble()
|
||||
|
||||
`in`.endArray()
|
||||
|
||||
return Vector4d(x, y, z, w)
|
||||
}
|
||||
}
|
||||
|
||||
object Vector2iTypeAdapter : TypeAdapter<Vector2i>() {
|
||||
override fun write(out: JsonWriter, value: Vector2i) {
|
||||
`out`.beginArray()
|
||||
|
Loading…
Reference in New Issue
Block a user