Устаревшие классы определения параллакса и мира
This commit is contained in:
parent
7f95ed29a5
commit
1bffac6014
@ -32,18 +32,11 @@ import ru.dbotthepony.kstarbound.defs.item.LeveledStatusEffect
|
|||||||
import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.parallax.ParallaxPrototype
|
|
||||||
import ru.dbotthepony.kstarbound.defs.parallax.ParallaxPrototypeLayer
|
|
||||||
import ru.dbotthepony.kstarbound.defs.particle.ParticleDefinition
|
import ru.dbotthepony.kstarbound.defs.particle.ParticleDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.player.BlueprintLearnList
|
import ru.dbotthepony.kstarbound.defs.player.BlueprintLearnList
|
||||||
import ru.dbotthepony.kstarbound.defs.player.PlayerDefinition
|
import ru.dbotthepony.kstarbound.defs.player.PlayerDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier
|
||||||
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
import ru.dbotthepony.kstarbound.defs.tile.TileDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.world.SkyColoring
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.SkyColoringManifold
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.SkyParameters
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.SkySatellite
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.dungeon.DungeonWorldDef
|
|
||||||
import ru.dbotthepony.kstarbound.io.*
|
import ru.dbotthepony.kstarbound.io.*
|
||||||
import ru.dbotthepony.kstarbound.io.json.AABBTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.AABBTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter
|
||||||
@ -161,21 +154,6 @@ class Starbound : ISBFileLocator {
|
|||||||
registerTypeAdapter(Vector4dTypeAdapter)
|
registerTypeAdapter(Vector4dTypeAdapter)
|
||||||
registerTypeAdapter(PolyTypeAdapter)
|
registerTypeAdapter(PolyTypeAdapter)
|
||||||
|
|
||||||
// Параметры неба
|
|
||||||
registerTypeAdapterFactory(SkyParameters.ADAPTER)
|
|
||||||
registerTypeAdapter(SkyColoringManifold.ADAPTER)
|
|
||||||
registerTypeAdapterFactory(SkyColoring.ADAPTER)
|
|
||||||
registerTypeAdapterFactory(SkySatellite.ADAPTER)
|
|
||||||
registerTypeAdapterFactory(SkySatellite.LAYER_ADAPTER)
|
|
||||||
|
|
||||||
// Данные о данжах
|
|
||||||
registerTypeAdapterFactory(DungeonWorldDef.ADAPTER)
|
|
||||||
|
|
||||||
// Параллакс
|
|
||||||
registerTypeAdapterFactory(ParallaxPrototype.ADAPTER)
|
|
||||||
registerTypeAdapterFactory(ParallaxPrototypeLayer.ADAPTER)
|
|
||||||
registerTypeAdapter(ParallaxPrototypeLayer.LAYER_PARALLAX_ADAPTER)
|
|
||||||
|
|
||||||
// Функции
|
// Функции
|
||||||
registerTypeAdapter(JsonFunction.CONSTRAINT_ADAPTER)
|
registerTypeAdapter(JsonFunction.CONSTRAINT_ADAPTER)
|
||||||
registerTypeAdapter(JsonFunction.INTERPOLATION_ADAPTER)
|
registerTypeAdapter(JsonFunction.INTERPOLATION_ADAPTER)
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.parallax
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
|
||||||
|
|
||||||
class ParallaxPrototype {
|
|
||||||
var verticalOrigin = 0.0
|
|
||||||
|
|
||||||
var layers = Array(0) { ParallaxPrototypeLayer() }
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(
|
|
||||||
::ParallaxPrototype,
|
|
||||||
ParallaxPrototype::verticalOrigin,
|
|
||||||
ParallaxPrototype::layers,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.parallax
|
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
class ParallaxPrototypeLayer {
|
|
||||||
class Parallax(val x: Double, val y: Double)
|
|
||||||
|
|
||||||
var timeOfDayCorrelation: String? = null
|
|
||||||
var offset = Vector2d.ZERO
|
|
||||||
var repeatY = false
|
|
||||||
var lightMapped = false
|
|
||||||
var tileLimitTop: Int? = null
|
|
||||||
var parallax by Delegates.notNull<Parallax>()
|
|
||||||
|
|
||||||
var unlit = false
|
|
||||||
var nohueshift = false
|
|
||||||
var minSpeed = 0
|
|
||||||
var maxSpeed = 0
|
|
||||||
var fadePercent = 0.0
|
|
||||||
|
|
||||||
var frequency = 1.0
|
|
||||||
|
|
||||||
var modCount = 0
|
|
||||||
|
|
||||||
var noRandomOffset = false
|
|
||||||
var directives: String? = null
|
|
||||||
|
|
||||||
var kind by Delegates.notNull<String>()
|
|
||||||
var baseCount = 1
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val LAYER_PARALLAX_ADAPTER = object : TypeAdapter<Parallax>() {
|
|
||||||
override fun write(out: JsonWriter?, value: Parallax?) {
|
|
||||||
TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(reader: JsonReader): Parallax {
|
|
||||||
return when (val type = reader.peek()) {
|
|
||||||
JsonToken.BEGIN_ARRAY -> {
|
|
||||||
reader.beginArray()
|
|
||||||
val instance = Parallax(reader.nextDouble(), reader.nextDouble())
|
|
||||||
reader.endArray()
|
|
||||||
instance
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonToken.NUMBER -> {
|
|
||||||
val num = reader.nextDouble()
|
|
||||||
Parallax(num, num)
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> throw JsonSyntaxException("Unexpected token $type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val ADAPTER = BuilderAdapter(::ParallaxPrototypeLayer,
|
|
||||||
ParallaxPrototypeLayer::timeOfDayCorrelation,
|
|
||||||
ParallaxPrototypeLayer::offset,
|
|
||||||
ParallaxPrototypeLayer::repeatY,
|
|
||||||
ParallaxPrototypeLayer::lightMapped,
|
|
||||||
ParallaxPrototypeLayer::tileLimitTop,
|
|
||||||
ParallaxPrototypeLayer::parallax,
|
|
||||||
ParallaxPrototypeLayer::unlit,
|
|
||||||
ParallaxPrototypeLayer::nohueshift,
|
|
||||||
ParallaxPrototypeLayer::minSpeed,
|
|
||||||
ParallaxPrototypeLayer::maxSpeed,
|
|
||||||
ParallaxPrototypeLayer::fadePercent,
|
|
||||||
ParallaxPrototypeLayer::kind,
|
|
||||||
ParallaxPrototypeLayer::baseCount,
|
|
||||||
ParallaxPrototypeLayer::noRandomOffset,
|
|
||||||
ParallaxPrototypeLayer::directives,
|
|
||||||
ParallaxPrototypeLayer::frequency,
|
|
||||||
ParallaxPrototypeLayer::modCount,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,148 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import org.apache.logging.log4j.LogManager
|
|
||||||
import ru.dbotthepony.kstarbound.io.ColorTypeAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
|
||||||
import kotlin.properties.ReadWriteProperty
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
class SkyParameters {
|
|
||||||
var spaceLevel = 3000
|
|
||||||
var ambientLightLevel = Color.BLACK
|
|
||||||
var skyType = SkyType.ATMOSPHERIC
|
|
||||||
var skyColoring = SkyColoring()
|
|
||||||
var satellites = Array(0) { SkySatellite() }
|
|
||||||
var planet: SkySatellite? = null
|
|
||||||
var horizonImages = Array(0) { "" }
|
|
||||||
var dayLength = 10_000.0
|
|
||||||
var surfaceLevel = 1_200
|
|
||||||
var seed = 0L
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(::SkyParameters,
|
|
||||||
SkyParameters::spaceLevel,
|
|
||||||
SkyParameters::ambientLightLevel,
|
|
||||||
SkyParameters::skyType,
|
|
||||||
SkyParameters::skyColoring,
|
|
||||||
SkyParameters::satellites,
|
|
||||||
SkyParameters::planet,
|
|
||||||
SkyParameters::horizonImages,
|
|
||||||
SkyParameters::dayLength,
|
|
||||||
SkyParameters::surfaceLevel,
|
|
||||||
SkyParameters::seed,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SkyColoringManifold {
|
|
||||||
var initial = Color.TRANSLUCENT
|
|
||||||
var final = Color.TRANSLUCENT
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = object : TypeAdapter<SkyColoringManifold>() {
|
|
||||||
override fun write(out: JsonWriter, value: SkyColoringManifold) {
|
|
||||||
TODO("Not yet implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(reader: JsonReader): SkyColoringManifold {
|
|
||||||
val instance = SkyColoringManifold()
|
|
||||||
reader.beginArray()
|
|
||||||
instance.initial = ColorTypeAdapter.read(reader)
|
|
||||||
instance.final = ColorTypeAdapter.read(reader)
|
|
||||||
reader.endArray()
|
|
||||||
return instance
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SkyColoring {
|
|
||||||
var mainColor = Color.TRANSLUCENT
|
|
||||||
|
|
||||||
var morningColors = SkyColoringManifold()
|
|
||||||
var dayColors = SkyColoringManifold()
|
|
||||||
var eveningColors = SkyColoringManifold()
|
|
||||||
var nightColors = SkyColoringManifold()
|
|
||||||
|
|
||||||
var morningLightColor = Color.TRANSLUCENT
|
|
||||||
var dayLightColor = Color.TRANSLUCENT
|
|
||||||
var eveningLightColor = Color.TRANSLUCENT
|
|
||||||
var nightLightColor = Color.TRANSLUCENT
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(::SkyColoring,
|
|
||||||
SkyColoring::mainColor,
|
|
||||||
SkyColoring::morningColors,
|
|
||||||
SkyColoring::dayColors,
|
|
||||||
SkyColoring::eveningColors,
|
|
||||||
SkyColoring::nightColors,
|
|
||||||
SkyColoring::morningLightColor,
|
|
||||||
SkyColoring::dayLightColor,
|
|
||||||
SkyColoring::eveningLightColor,
|
|
||||||
SkyColoring::nightLightColor,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SkySatellite {
|
|
||||||
class Layer {
|
|
||||||
private inner class ImageDelegate : ReadWriteProperty<Layer, String> {
|
|
||||||
private var value: String? = null
|
|
||||||
|
|
||||||
override fun getValue(thisRef: Layer, property: KProperty<*>): String {
|
|
||||||
return value ?: throw IllegalStateException("Property is not initialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setValue(thisRef: Layer, property: KProperty<*>, value: String) {
|
|
||||||
val split = value.split('?')
|
|
||||||
this.value = split[0]
|
|
||||||
|
|
||||||
for (prop in 1 until split.size) {
|
|
||||||
val splitProp = split[prop].split('=')
|
|
||||||
|
|
||||||
if (splitProp.size == 1) {
|
|
||||||
throw IllegalArgumentException("Invalid property: ${split[prop]}, near $prop, in $value")
|
|
||||||
}
|
|
||||||
|
|
||||||
when (val propName = splitProp[0]) {
|
|
||||||
"hueshift" -> hueShift = splitProp[1].toInt()
|
|
||||||
"addmask" -> mask = splitProp[1]
|
|
||||||
else -> LOGGER.warn("Unknown property $propName near $prop in $value")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var scale = 1.0
|
|
||||||
var image by ImageDelegate()
|
|
||||||
var hueShift = 0
|
|
||||||
var mask: String? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
var pos = Vector2d.ZERO
|
|
||||||
var layers = Array(0) { Layer() }
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(::SkySatellite,
|
|
||||||
SkySatellite::pos,
|
|
||||||
SkySatellite::layers,
|
|
||||||
)
|
|
||||||
|
|
||||||
val LAYER_ADAPTER = BuilderAdapter(::Layer,
|
|
||||||
Layer::scale,
|
|
||||||
Layer::image,
|
|
||||||
Layer::hueShift,
|
|
||||||
Layer::mask,
|
|
||||||
)
|
|
||||||
|
|
||||||
private val LOGGER = LogManager.getLogger(SkySatellite::class.java)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world
|
|
||||||
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
|
||||||
|
|
||||||
enum class SkyType(vararg aliases: String) : IStringSerializable {
|
|
||||||
ATMOSPHERIC,
|
|
||||||
BARREN,
|
|
||||||
;
|
|
||||||
|
|
||||||
private val aliases: Array<String> = Array(aliases.size) { aliases[it].uppercase() }
|
|
||||||
|
|
||||||
override fun match(name: String): Boolean {
|
|
||||||
for (alias in aliases)
|
|
||||||
if (name == alias)
|
|
||||||
return true
|
|
||||||
|
|
||||||
return name == this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter) {
|
|
||||||
out.value(this.name)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
|
||||||
|
|
||||||
class WorldProperties {
|
|
||||||
var nonCombat = false
|
|
||||||
|
|
||||||
fun immutable(): ImmutableWorldProperties {
|
|
||||||
return ImmutableWorldProperties(
|
|
||||||
nonCombat = nonCombat
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(::WorldProperties,
|
|
||||||
WorldProperties::nonCombat,
|
|
||||||
)
|
|
||||||
|
|
||||||
fun registerGson(gsonBuilder: GsonBuilder) {
|
|
||||||
gsonBuilder.registerTypeAdapter(WorldProperties::class.java, ADAPTER)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ImmutableWorldProperties(
|
|
||||||
val nonCombat: Boolean
|
|
||||||
)
|
|
@ -1,25 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
|
||||||
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
|
||||||
|
|
||||||
enum class BeamUpRule(vararg aliases: String) : IStringSerializable {
|
|
||||||
NOWHERE,
|
|
||||||
ANYWHERE_WITH_WARNING("AnywhereWithWarning"),
|
|
||||||
ANYWHERE("Anywhere"),
|
|
||||||
;
|
|
||||||
|
|
||||||
private val aliases: Array<String> = Array(aliases.size) { aliases[it].uppercase() }
|
|
||||||
|
|
||||||
override fun match(name: String): Boolean {
|
|
||||||
for (alias in aliases)
|
|
||||||
if (name == alias)
|
|
||||||
return true
|
|
||||||
|
|
||||||
return name == this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter) {
|
|
||||||
out.value(this.name)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.SkyParameters
|
|
||||||
import ru.dbotthepony.kstarbound.defs.world.WorldProperties
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.BuilderAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.EnumAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
class DungeonWorldDef {
|
|
||||||
var type by Delegates.notNull<DungeonType>()
|
|
||||||
var dungeonWorld by Delegates.notNull<String>()
|
|
||||||
var seed by Delegates.notNull<Long>()
|
|
||||||
|
|
||||||
var spawningEnabled = false
|
|
||||||
var beamUpRule by Delegates.notNull<BeamUpRule>()
|
|
||||||
|
|
||||||
var disableDeathDrops = true
|
|
||||||
|
|
||||||
var worldProperties: WorldProperties? = null
|
|
||||||
var skyParameters = SkyParameters()
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Milliseconds
|
|
||||||
*/
|
|
||||||
var tempWorldDeleteTime = -1L
|
|
||||||
|
|
||||||
var persistent = false
|
|
||||||
var useUniverseClock = false
|
|
||||||
|
|
||||||
var planetType: String? = null
|
|
||||||
var planetSize: String? = null
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
val ADAPTER = BuilderAdapter(::DungeonWorldDef,
|
|
||||||
DungeonWorldDef::type,
|
|
||||||
DungeonWorldDef::dungeonWorld,
|
|
||||||
DungeonWorldDef::seed,
|
|
||||||
DungeonWorldDef::spawningEnabled,
|
|
||||||
DungeonWorldDef::beamUpRule,
|
|
||||||
DungeonWorldDef::disableDeathDrops,
|
|
||||||
DungeonWorldDef::worldProperties,
|
|
||||||
DungeonWorldDef::skyParameters,
|
|
||||||
DungeonWorldDef::tempWorldDeleteTime,
|
|
||||||
DungeonWorldDef::persistent,
|
|
||||||
DungeonWorldDef::useUniverseClock,
|
|
||||||
DungeonWorldDef::planetType,
|
|
||||||
DungeonWorldDef::planetSize,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
|
||||||
|
|
||||||
class CDungeonWorldDef {
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world.dungeon
|
|
||||||
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
|
||||||
|
|
||||||
enum class DungeonType(vararg aliases: String) : IStringSerializable {
|
|
||||||
FLOATING("FloatingDungeon"),
|
|
||||||
TERRESTRIAL,
|
|
||||||
;
|
|
||||||
|
|
||||||
private val aliases: Array<String> = Array(aliases.size) { aliases[it].uppercase() }
|
|
||||||
|
|
||||||
override fun match(name: String): Boolean {
|
|
||||||
for (alias in aliases)
|
|
||||||
if (name == alias)
|
|
||||||
return true
|
|
||||||
|
|
||||||
return name == this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter) {
|
|
||||||
out.value(this.name)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user