From 1bffac60147b2d2893d6b8da252fb3c0025d0da9 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Mon, 6 Feb 2023 20:55:36 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D1=81=D1=82=D0=B0=D1=80=D0=B5=D0=B2?= =?UTF-8?q?=D1=88=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D1=8B=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=80=D0=B5=D0=B4=D0=B5=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BB=D0=BB=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B0=20=D0=B8=20=D0=BC=D0=B8=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ru/dbotthepony/kstarbound/Starbound.kt | 22 --- .../defs/parallax/ParallaxPrototype.kt | 18 --- .../defs/parallax/ParallaxPrototypeLayer.kt | 83 ---------- .../kstarbound/defs/world/SkyParameters.kt | 148 ------------------ .../kstarbound/defs/world/SkyType.kt | 24 --- .../kstarbound/defs/world/WorldProperties.kt | 28 ---- .../defs/world/dungeon/BeamUpRule.kt | 25 --- .../defs/world/dungeon/Configurable.kt | 52 ------ .../defs/world/dungeon/Configured.kt | 5 - .../defs/world/dungeon/DungeonType.kt | 24 --- 10 files changed, 429 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyParameters.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyType.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/WorldProperties.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/BeamUpRule.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configurable.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configured.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/DungeonType.kt diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 562fc294..378e6a01 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -32,18 +32,11 @@ import ru.dbotthepony.kstarbound.defs.item.LeveledStatusEffect import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype 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.player.BlueprintLearnList import ru.dbotthepony.kstarbound.defs.player.PlayerDefinition import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier 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.json.AABBTypeAdapter import ru.dbotthepony.kstarbound.io.json.AABBiTypeAdapter @@ -161,21 +154,6 @@ class Starbound : ISBFileLocator { registerTypeAdapter(Vector4dTypeAdapter) 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.INTERPOLATION_ADAPTER) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt deleted file mode 100644 index a18afe22..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt +++ /dev/null @@ -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, - ) - } -} \ No newline at end of file diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt deleted file mode 100644 index 761d4416..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt +++ /dev/null @@ -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() - - 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() - var baseCount = 1 - - companion object { - val LAYER_PARALLAX_ADAPTER = object : TypeAdapter() { - 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, - ) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyParameters.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyParameters.kt deleted file mode 100644 index e83de053..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyParameters.kt +++ /dev/null @@ -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() { - 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 { - 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) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyType.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyType.kt deleted file mode 100644 index 150b4a45..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/SkyType.kt +++ /dev/null @@ -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 = 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) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/WorldProperties.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/WorldProperties.kt deleted file mode 100644 index ce421351..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/WorldProperties.kt +++ /dev/null @@ -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 -) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/BeamUpRule.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/BeamUpRule.kt deleted file mode 100644 index d9173190..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/BeamUpRule.kt +++ /dev/null @@ -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 = 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) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configurable.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configurable.kt deleted file mode 100644 index 485e811c..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configurable.kt +++ /dev/null @@ -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() - var dungeonWorld by Delegates.notNull() - var seed by Delegates.notNull() - - var spawningEnabled = false - var beamUpRule by Delegates.notNull() - - 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, - ) - } -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configured.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configured.kt deleted file mode 100644 index 6c2a71ed..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/Configured.kt +++ /dev/null @@ -1,5 +0,0 @@ -package ru.dbotthepony.kstarbound.defs.world.dungeon - -class CDungeonWorldDef { - -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/DungeonType.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/DungeonType.kt deleted file mode 100644 index 827333aa..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/world/dungeon/DungeonType.kt +++ /dev/null @@ -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 = 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) - } -}