From 215ae8429e133f7d2a3c386b4161d16bc81e96ca Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 22 Jan 2023 18:43:45 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D0=BC=D1=81?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/ru/dbotthepony/kstarbound/Main.kt | 2 +- .../ru/dbotthepony/kstarbound/Starbound.kt | 1 + .../kstarbound/client/ClientWorld.kt | 17 +----- .../dbotthepony/kstarbound/defs/Animation.kt | 14 ----- .../kstarbound/defs/ParticleDefinition.kt | 8 --- .../kstarbound/defs/RawPrototype.kt | 1 + .../defs/parallax/ParallaxPrototype.kt | 27 +++++++++ .../ParallaxPrototypeLayer.kt} | 56 ++++++------------- .../defs/{ => util}/MutableFlattener.kt | 2 +- 9 files changed, 50 insertions(+), 78 deletions(-) delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt delete mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParticleDefinition.kt create mode 100644 src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt rename src/main/kotlin/ru/dbotthepony/kstarbound/defs/{ParallaxPrototype.kt => parallax/ParallaxPrototypeLayer.kt} (54%) rename src/main/kotlin/ru/dbotthepony/kstarbound/defs/{ => util}/MutableFlattener.kt (94%) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt index 52136e2e..81a59540 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt @@ -166,7 +166,7 @@ fun main() { val item = Starbound.ITEM.values.random() val rand = java.util.Random() - for (i in 0 .. 240) { + for (i in 0 .. 10) { val item = ItemEntity(client.world!!, item) item.position = Vector2d(600.0 + 16.0 + i, 721.0 + 48.0) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 6ae37dcb..52538d14 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -30,6 +30,7 @@ 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.liquid.LiquidDefinition +import ru.dbotthepony.kstarbound.defs.parallax.ParallaxPrototype import ru.dbotthepony.kstarbound.defs.projectile.* import ru.dbotthepony.kstarbound.defs.tile.MaterialModifier import ru.dbotthepony.kstarbound.defs.tile.RenderParameters diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt index 5086d1d7..aca8142e 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/ClientWorld.kt @@ -1,32 +1,17 @@ package ru.dbotthepony.kstarbound.client import org.lwjgl.opengl.GL46.* -import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNIT import ru.dbotthepony.kstarbound.PIXELS_IN_STARBOUND_UNITf -import ru.dbotthepony.kstarbound.client.gl.BlendFunc -import ru.dbotthepony.kstarbound.client.gl.GLFrameBuffer -import ru.dbotthepony.kstarbound.client.gl.GLTexture2D import ru.dbotthepony.kstarbound.client.gl.vertex.QuadTransformers -import ru.dbotthepony.kstarbound.client.gl.vertex.quad import ru.dbotthepony.kstarbound.client.gl.vertex.quadZ import ru.dbotthepony.kstarbound.client.render.ILayeredRenderer import ru.dbotthepony.kstarbound.client.render.renderLayeredList -import ru.dbotthepony.kstarbound.defs.ParallaxPrototype +import ru.dbotthepony.kstarbound.defs.parallax.ParallaxPrototype import ru.dbotthepony.kstarbound.math.encasingChunkPosAABB import ru.dbotthepony.kstarbound.util.DoubleEdgeProgression import ru.dbotthepony.kstarbound.world.* import ru.dbotthepony.kstarbound.world.entities.Entity import ru.dbotthepony.kvector.util2d.AABB -import ru.dbotthepony.kvector.vector.Color -import ru.dbotthepony.kvector.vector.ndouble.Vector2d -import ru.dbotthepony.kvector.vector.nfloat.Vector2f -import ru.dbotthepony.kvector.vector.nint.Vector2i -import java.nio.ByteBuffer -import java.nio.ByteOrder -import kotlin.math.PI -import kotlin.math.cos -import kotlin.math.roundToInt -import kotlin.math.sin class ClientWorld( val client: StarboundClient, diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt deleted file mode 100644 index 55e3b4e0..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/Animation.kt +++ /dev/null @@ -1,14 +0,0 @@ -package ru.dbotthepony.kstarbound.defs - -import ru.dbotthepony.kvector.vector.nint.Vector2i - -class AnimationDefinitionBuilder { - var frames: String? = null - var variants: Int? = null - var frameNumber: Int? = null - var animationCycle: Double? = null - var offset: Vector2i? = null -} - -class AnimationDefinition { -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParticleDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParticleDefinition.kt deleted file mode 100644 index 3fdcab53..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParticleDefinition.kt +++ /dev/null @@ -1,8 +0,0 @@ -package ru.dbotthepony.kstarbound.defs - -class ParticleDefinitionBuilder { - var kind: String? = null - var animation: String? = null - var size: Double? = null - var timeToLive: Double? = null -} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/RawPrototype.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/RawPrototype.kt index 4f524d1f..be7dd3dc 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/RawPrototype.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/RawPrototype.kt @@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.defs.util.enrollMap +import ru.dbotthepony.kstarbound.defs.util.flattenMap import ru.dbotthepony.kstarbound.io.json.INativeJsonHolder /** diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt new file mode 100644 index 00000000..2e4ac46c --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototype.kt @@ -0,0 +1,27 @@ +package ru.dbotthepony.kstarbound.defs.parallax + +import com.google.gson.GsonBuilder +import ru.dbotthepony.kstarbound.io.json.BuilderAdapter + +class ParallaxPrototype { + var verticalOrigin = 0.0 + + var layers = Array(0) { ParallaxPrototypeLayer() } + + companion object { + val ADAPTER = BuilderAdapter( + ::ParallaxPrototype, + ParallaxPrototype::verticalOrigin, + ParallaxPrototype::layers, + ) + + fun registerGson(gsonBuilder: GsonBuilder) { + gsonBuilder.registerTypeAdapter(ParallaxPrototype::class.java, ADAPTER) + gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer::class.java, ParallaxPrototypeLayer.ADAPTER) + gsonBuilder.registerTypeAdapter( + ParallaxPrototypeLayer.Parallax::class.java, + ParallaxPrototypeLayer.LAYER_PARALLAX_ADAPTER + ) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParallaxPrototype.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt similarity index 54% rename from src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParallaxPrototype.kt rename to src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt index abb70af5..b1c36353 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/ParallaxPrototype.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/parallax/ParallaxPrototypeLayer.kt @@ -1,6 +1,5 @@ -package ru.dbotthepony.kstarbound.defs +package ru.dbotthepony.kstarbound.defs.parallax -import com.google.gson.GsonBuilder import com.google.gson.JsonSyntaxException import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader @@ -10,25 +9,6 @@ import ru.dbotthepony.kstarbound.io.json.BuilderAdapter import ru.dbotthepony.kvector.vector.ndouble.Vector2d import kotlin.properties.Delegates -class ParallaxPrototype { - var verticalOrigin = 0.0 - - var layers = Array(0) { ParallaxPrototypeLayer() } - - companion object { - val ADAPTER = BuilderAdapter(::ParallaxPrototype, - ParallaxPrototype::verticalOrigin, - ParallaxPrototype::layers, - ) - - fun registerGson(gsonBuilder: GsonBuilder) { - gsonBuilder.registerTypeAdapter(ParallaxPrototype::class.java, ADAPTER) - gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer::class.java, ParallaxPrototypeLayer.ADAPTER) - gsonBuilder.registerTypeAdapter(ParallaxPrototypeLayer.Parallax::class.java, ParallaxPrototypeLayer.LAYER_PARALLAX_ADAPTER) - } - } -} - class ParallaxPrototypeLayer { class Parallax(val x: Double, val y: Double) @@ -81,23 +61,23 @@ class ParallaxPrototypeLayer { } 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, + 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/MutableFlattener.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/util/MutableFlattener.kt similarity index 94% rename from src/main/kotlin/ru/dbotthepony/kstarbound/defs/MutableFlattener.kt rename to src/main/kotlin/ru/dbotthepony/kstarbound/defs/util/MutableFlattener.kt index c9d3fbb7..e59e51cb 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/MutableFlattener.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/util/MutableFlattener.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.kstarbound.defs +package ru.dbotthepony.kstarbound.defs.util import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap