Правильные имена адаптеров типов
This commit is contained in:
parent
2a4ad28e3e
commit
b3636e5a55
@ -6,7 +6,7 @@ import com.google.gson.TypeAdapter
|
|||||||
import com.google.gson.stream.JsonReader
|
import com.google.gson.stream.JsonReader
|
||||||
import com.google.gson.stream.JsonToken
|
import com.google.gson.stream.JsonToken
|
||||||
import com.google.gson.stream.JsonWriter
|
import com.google.gson.stream.JsonWriter
|
||||||
import ru.dbotthepony.kstarbound.io.json.KTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ class ParallaxPrototype {
|
|||||||
var layers = Array(0) { ParallaxPrototypeLayer() }
|
var layers = Array(0) { ParallaxPrototypeLayer() }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ParallaxPrototype,
|
val ADAPTER = BuilderAdapter(::ParallaxPrototype,
|
||||||
ParallaxPrototype::verticalOrigin,
|
ParallaxPrototype::verticalOrigin,
|
||||||
ParallaxPrototype::layers,
|
ParallaxPrototype::layers,
|
||||||
)
|
)
|
||||||
@ -80,7 +80,7 @@ class ParallaxPrototypeLayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val ADAPTER = KTypeAdapter(::ParallaxPrototypeLayer,
|
val ADAPTER = BuilderAdapter(::ParallaxPrototypeLayer,
|
||||||
ParallaxPrototypeLayer::timeOfDayCorrelation,
|
ParallaxPrototypeLayer::timeOfDayCorrelation,
|
||||||
ParallaxPrototypeLayer::offset,
|
ParallaxPrototypeLayer::offset,
|
||||||
ParallaxPrototypeLayer::repeatY,
|
ParallaxPrototypeLayer::repeatY,
|
||||||
|
@ -3,7 +3,7 @@ package ru.dbotthepony.kstarbound.defs.item
|
|||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.SpriteReference
|
import ru.dbotthepony.kstarbound.defs.animation.SpriteReference
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.ListAdapter
|
import ru.dbotthepony.kstarbound.io.json.ListAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.asJsonObject
|
import ru.dbotthepony.kstarbound.io.json.asJsonObject
|
||||||
import ru.dbotthepony.kstarbound.io.json.asList
|
import ru.dbotthepony.kstarbound.io.json.asList
|
||||||
@ -263,11 +263,11 @@ data class ItemDefinition(
|
|||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val INVENTORY_ICON_ADAPTER = KConcreteTypeAdapter.Builder(InventoryIcon::class)
|
val INVENTORY_ICON_ADAPTER = FactoryAdapter.Builder(InventoryIcon::class)
|
||||||
.auto(InventoryIcon::image)
|
.auto(InventoryIcon::image)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(ItemDefinition::class)
|
val ADAPTER = FactoryAdapter.Builder(ItemDefinition::class)
|
||||||
.auto(ItemDefinition::itemName)
|
.auto(ItemDefinition::itemName)
|
||||||
.auto(ItemDefinition::price)
|
.auto(ItemDefinition::price)
|
||||||
.auto(ItemDefinition::rarity)
|
.auto(ItemDefinition::rarity)
|
||||||
@ -323,20 +323,20 @@ data class ItemDefinition(
|
|||||||
|
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val FOSSIL_ADAPTER = KConcreteTypeAdapter.Builder(FossilSetDescription::class)
|
val FOSSIL_ADAPTER = FactoryAdapter.Builder(FossilSetDescription::class)
|
||||||
.auto(FossilSetDescription::price)
|
.auto(FossilSetDescription::price)
|
||||||
.auto(FossilSetDescription::shortdescription)
|
.auto(FossilSetDescription::shortdescription)
|
||||||
.auto(FossilSetDescription::description)
|
.auto(FossilSetDescription::description)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val ARMOR_FRAMES_ADAPTER = KConcreteTypeAdapter.Builder(ArmorFrames::class)
|
val ARMOR_FRAMES_ADAPTER = FactoryAdapter.Builder(ArmorFrames::class)
|
||||||
.auto(ArmorFrames::body, transformer = Starbound::readingFolderTransformer)
|
.auto(ArmorFrames::body, transformer = Starbound::readingFolderTransformer)
|
||||||
.auto(ArmorFrames::backSleeve, transformer = Starbound::readingFolderTransformerNullable)
|
.auto(ArmorFrames::backSleeve, transformer = Starbound::readingFolderTransformerNullable)
|
||||||
.auto(ArmorFrames::frontSleeve, transformer = Starbound::readingFolderTransformerNullable)
|
.auto(ArmorFrames::frontSleeve, transformer = Starbound::readingFolderTransformerNullable)
|
||||||
.build()
|
.build()
|
||||||
.ifString { ArmorFrames(Starbound.readingFolderTransformer(it), null, null) }
|
.ifString { ArmorFrames(Starbound.readingFolderTransformer(it), null, null) }
|
||||||
|
|
||||||
val STATUS_EFFECT_ADAPTER = KConcreteTypeAdapter.Builder(StatusEffect::class)
|
val STATUS_EFFECT_ADAPTER = FactoryAdapter.Builder(StatusEffect::class)
|
||||||
.auto(StatusEffect::levelFunction)
|
.auto(StatusEffect::levelFunction)
|
||||||
.auto(StatusEffect::stat)
|
.auto(StatusEffect::stat)
|
||||||
.auto(StatusEffect::baseMultiplier)
|
.auto(StatusEffect::baseMultiplier)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.liquid
|
package ru.dbotthepony.kstarbound.defs.liquid
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ data class LiquidDefinition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(LiquidDefinition::class)
|
val ADAPTER = FactoryAdapter.Builder(LiquidDefinition::class)
|
||||||
.auto(LiquidDefinition::name)
|
.auto(LiquidDefinition::name)
|
||||||
.auto(LiquidDefinition::liquidId)
|
.auto(LiquidDefinition::liquidId)
|
||||||
.auto(LiquidDefinition::description)
|
.auto(LiquidDefinition::description)
|
||||||
@ -39,7 +39,7 @@ data class LiquidDefinition(
|
|||||||
.auto(LiquidDefinition::textureMovementFactor)
|
.auto(LiquidDefinition::textureMovementFactor)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val INTERACTION_ADAPTER = KConcreteTypeAdapter.Builder(Interaction::class)
|
val INTERACTION_ADAPTER = FactoryAdapter.Builder(Interaction::class)
|
||||||
.auto(Interaction::liquid)
|
.auto(Interaction::liquid)
|
||||||
.auto(Interaction::liquidResult)
|
.auto(Interaction::liquidResult)
|
||||||
.auto(Interaction::materialResult)
|
.auto(Interaction::materialResult)
|
||||||
|
@ -8,7 +8,7 @@ import org.apache.logging.log4j.LogManager
|
|||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.defs.*
|
import ru.dbotthepony.kstarbound.defs.*
|
||||||
import ru.dbotthepony.kstarbound.io.json.ConfigurableTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.ConfigurableTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.KTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
@ -182,7 +182,7 @@ class ActionConfig : IConfigurableAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ActionConfig, ActionConfig::file).ignoreProperty("action")
|
val ADAPTER = BuilderAdapter(::ActionConfig, ActionConfig::file).ignoreProperty("action")
|
||||||
|
|
||||||
private val cache = HashMap<String, CActionConfig>()
|
private val cache = HashMap<String, CActionConfig>()
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ class ActionProjectile : IConfigurableAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ActionProjectile,
|
val ADAPTER = BuilderAdapter(::ActionProjectile,
|
||||||
ActionProjectile::type,
|
ActionProjectile::type,
|
||||||
ActionProjectile::angle,
|
ActionProjectile::angle,
|
||||||
ActionProjectile::inheritDamageFactor,
|
ActionProjectile::inheritDamageFactor,
|
||||||
@ -220,7 +220,7 @@ class ActionSound : IConfigurableAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ActionSound,
|
val ADAPTER = BuilderAdapter(::ActionSound,
|
||||||
ActionSound::options,
|
ActionSound::options,
|
||||||
).ignoreProperty("action")
|
).ignoreProperty("action")
|
||||||
}
|
}
|
||||||
@ -238,7 +238,7 @@ class ActionLoop : IConfigurableAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ActionLoop,
|
val ADAPTER = BuilderAdapter(::ActionLoop,
|
||||||
ActionLoop::count,
|
ActionLoop::count,
|
||||||
ActionLoop::body,
|
ActionLoop::body,
|
||||||
).ignoreProperty("action")
|
).ignoreProperty("action")
|
||||||
@ -256,7 +256,7 @@ class ActionActions : IConfigurableAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::ActionActions,
|
val ADAPTER = BuilderAdapter(::ActionActions,
|
||||||
ActionActions::list,
|
ActionActions::list,
|
||||||
).ignoreProperty("action")
|
).ignoreProperty("action")
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.tile
|
package ru.dbotthepony.kstarbound.defs.tile
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
|
|
||||||
data class MaterialModifier(
|
data class MaterialModifier(
|
||||||
val modId: Int,
|
val modId: Int,
|
||||||
@ -22,7 +22,7 @@ data class MaterialModifier(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(MaterialModifier::class)
|
val ADAPTER = FactoryAdapter.Builder(MaterialModifier::class)
|
||||||
.auto(MaterialModifier::modId)
|
.auto(MaterialModifier::modId)
|
||||||
.auto(MaterialModifier::modName)
|
.auto(MaterialModifier::modName)
|
||||||
.auto(MaterialModifier::itemDrop)
|
.auto(MaterialModifier::itemDrop)
|
||||||
|
@ -2,7 +2,7 @@ package ru.dbotthepony.kstarbound.defs.tile
|
|||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
|
|
||||||
const val TILE_COLOR_VARIANTS = 9
|
const val TILE_COLOR_VARIANTS = 9
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ data class RenderParameters(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderParameters::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderParameters::class)
|
||||||
.auto(
|
.auto(
|
||||||
RenderParameters::texture,
|
RenderParameters::texture,
|
||||||
RenderParameters::variants,
|
RenderParameters::variants,
|
||||||
|
@ -10,7 +10,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArraySet
|
|||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
import ru.dbotthepony.kstarbound.io.json.EnumAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.util.WriteOnce
|
import ru.dbotthepony.kstarbound.util.WriteOnce
|
||||||
import ru.dbotthepony.kstarbound.world.ITileGetter
|
import ru.dbotthepony.kstarbound.world.ITileGetter
|
||||||
@ -26,7 +26,7 @@ data class RenderPiece(
|
|||||||
val variantStride: Vector2i? = null,
|
val variantStride: Vector2i? = null,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderPiece::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderPiece::class)
|
||||||
.auto(
|
.auto(
|
||||||
RenderPiece::texture,
|
RenderPiece::texture,
|
||||||
RenderPiece::textureSize,
|
RenderPiece::textureSize,
|
||||||
@ -82,7 +82,7 @@ data class RenderRuleList(
|
|||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
private val LOGGED = ObjectArraySet<String>()
|
private val LOGGED = ObjectArraySet<String>()
|
||||||
|
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(Entry::class)
|
val ADAPTER = FactoryAdapter.Builder(Entry::class)
|
||||||
.auto(
|
.auto(
|
||||||
Entry::type,
|
Entry::type,
|
||||||
Entry::matchHue,
|
Entry::matchHue,
|
||||||
@ -117,7 +117,7 @@ data class RenderRuleList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderRuleList::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderRuleList::class)
|
||||||
.autoList(RenderRuleList::entries)
|
.autoList(RenderRuleList::entries)
|
||||||
.auto(RenderRuleList::join)
|
.auto(RenderRuleList::join)
|
||||||
.build()
|
.build()
|
||||||
@ -206,7 +206,7 @@ data class RenderMatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderMatch::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderMatch::class)
|
||||||
.autoList(RenderMatch::pieces)
|
.autoList(RenderMatch::pieces)
|
||||||
.autoList(RenderMatch::matchAllPoints)
|
.autoList(RenderMatch::matchAllPoints)
|
||||||
.autoList(RenderMatch::matchAnyPoints)
|
.autoList(RenderMatch::matchAnyPoints)
|
||||||
@ -215,13 +215,13 @@ data class RenderMatch(
|
|||||||
.auto(RenderMatch::haltOnSubMatch)
|
.auto(RenderMatch::haltOnSubMatch)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val PIECE_ADAPTER = KConcreteTypeAdapter.Builder(Piece::class)
|
val PIECE_ADAPTER = FactoryAdapter.Builder(Piece::class)
|
||||||
.auto(Piece::name)
|
.auto(Piece::name)
|
||||||
.auto(Piece::offset)
|
.auto(Piece::offset)
|
||||||
.inputAsList()
|
.inputAsList()
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val MATCHER_ADAPTER = KConcreteTypeAdapter.Builder(Matcher::class)
|
val MATCHER_ADAPTER = FactoryAdapter.Builder(Matcher::class)
|
||||||
.auto(Matcher::offset)
|
.auto(Matcher::offset)
|
||||||
.auto(Matcher::ruleName)
|
.auto(Matcher::ruleName)
|
||||||
.inputAsList()
|
.inputAsList()
|
||||||
@ -240,7 +240,7 @@ data class RenderMatchList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderMatchList::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderMatchList::class)
|
||||||
.auto(RenderMatchList::name)
|
.auto(RenderMatchList::name)
|
||||||
.autoList(RenderMatchList::list)
|
.autoList(RenderMatchList::list)
|
||||||
.inputAsList()
|
.inputAsList()
|
||||||
@ -261,7 +261,7 @@ data class RenderTemplate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(RenderTemplate::class)
|
val ADAPTER = FactoryAdapter.Builder(RenderTemplate::class)
|
||||||
.mapAsObject(RenderTemplate::pieces, RenderPiece::class.java)
|
.mapAsObject(RenderTemplate::pieces, RenderPiece::class.java)
|
||||||
.auto(RenderTemplate::representativePiece)
|
.auto(RenderTemplate::representativePiece)
|
||||||
.list(RenderTemplate::matches, RenderMatchList::class.java)
|
.list(RenderTemplate::matches, RenderMatchList::class.java)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.tile
|
package ru.dbotthepony.kstarbound.defs.tile
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.io.json.KConcreteTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.FactoryAdapter
|
||||||
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
import ru.dbotthepony.kstarbound.registerTypeAdapter
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ data class TileDefinition(
|
|||||||
override val renderParameters: RenderParameters,
|
override val renderParameters: RenderParameters,
|
||||||
) : IRenderableTile {
|
) : IRenderableTile {
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KConcreteTypeAdapter.Builder(TileDefinition::class)
|
val ADAPTER = FactoryAdapter.Builder(TileDefinition::class)
|
||||||
.auto(
|
.auto(
|
||||||
TileDefinition::materialId,
|
TileDefinition::materialId,
|
||||||
TileDefinition::materialName,
|
TileDefinition::materialName,
|
||||||
|
@ -7,7 +7,7 @@ import com.google.gson.stream.JsonWriter
|
|||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import ru.dbotthepony.kstarbound.io.ColorTypeAdapter
|
import ru.dbotthepony.kstarbound.io.ColorTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.KTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||||
import ru.dbotthepony.kvector.vector.Color
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
import kotlin.properties.ReadWriteProperty
|
import kotlin.properties.ReadWriteProperty
|
||||||
@ -26,7 +26,7 @@ class SkyParameters {
|
|||||||
var seed = 0L
|
var seed = 0L
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::SkyParameters,
|
val ADAPTER = BuilderAdapter(::SkyParameters,
|
||||||
SkyParameters::spaceLevel,
|
SkyParameters::spaceLevel,
|
||||||
SkyParameters::ambientLightLevel,
|
SkyParameters::ambientLightLevel,
|
||||||
SkyParameters::skyType,
|
SkyParameters::skyType,
|
||||||
@ -85,7 +85,7 @@ class SkyColoring {
|
|||||||
var nightLightColor = Color.TRANSLUCENT
|
var nightLightColor = Color.TRANSLUCENT
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::SkyColoring,
|
val ADAPTER = BuilderAdapter(::SkyColoring,
|
||||||
SkyColoring::mainColor,
|
SkyColoring::mainColor,
|
||||||
SkyColoring::morningColors,
|
SkyColoring::morningColors,
|
||||||
SkyColoring::dayColors,
|
SkyColoring::dayColors,
|
||||||
@ -138,12 +138,12 @@ class SkySatellite {
|
|||||||
var layers = Array(0) { Layer() }
|
var layers = Array(0) { Layer() }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::SkySatellite,
|
val ADAPTER = BuilderAdapter(::SkySatellite,
|
||||||
SkySatellite::pos,
|
SkySatellite::pos,
|
||||||
SkySatellite::layers,
|
SkySatellite::layers,
|
||||||
)
|
)
|
||||||
|
|
||||||
val LAYER_ADAPTER = KTypeAdapter(::Layer,
|
val LAYER_ADAPTER = BuilderAdapter(::Layer,
|
||||||
Layer::scale,
|
Layer::scale,
|
||||||
Layer::image,
|
Layer::image,
|
||||||
Layer::hueShift,
|
Layer::hueShift,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.world
|
package ru.dbotthepony.kstarbound.defs.world
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import ru.dbotthepony.kstarbound.io.json.KTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||||
|
|
||||||
class WorldProperties {
|
class WorldProperties {
|
||||||
var nonCombat = false
|
var nonCombat = false
|
||||||
@ -13,7 +13,7 @@ class WorldProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::WorldProperties,
|
val ADAPTER = BuilderAdapter(::WorldProperties,
|
||||||
WorldProperties::nonCombat,
|
WorldProperties::nonCombat,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import com.google.gson.GsonBuilder
|
|||||||
import ru.dbotthepony.kstarbound.defs.world.SkyParameters
|
import ru.dbotthepony.kstarbound.defs.world.SkyParameters
|
||||||
import ru.dbotthepony.kstarbound.defs.world.WorldProperties
|
import ru.dbotthepony.kstarbound.defs.world.WorldProperties
|
||||||
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.CustomEnumTypeAdapter
|
||||||
import ru.dbotthepony.kstarbound.io.json.KTypeAdapter
|
import ru.dbotthepony.kstarbound.io.json.BuilderAdapter
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
class DungeonWorldDef {
|
class DungeonWorldDef {
|
||||||
@ -32,7 +32,7 @@ class DungeonWorldDef {
|
|||||||
var planetSize: String? = null
|
var planetSize: String? = null
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ADAPTER = KTypeAdapter(::DungeonWorldDef,
|
val ADAPTER = BuilderAdapter(::DungeonWorldDef,
|
||||||
DungeonWorldDef::type,
|
DungeonWorldDef::type,
|
||||||
DungeonWorldDef::dungeonWorld,
|
DungeonWorldDef::dungeonWorld,
|
||||||
DungeonWorldDef::seed,
|
DungeonWorldDef::seed,
|
||||||
|
@ -22,11 +22,9 @@ import kotlin.reflect.full.isSuperclassOf
|
|||||||
* Создаёт пустые классы, а после наполняет их данными, что подходит для builder'ов с очень
|
* Создаёт пустые классы, а после наполняет их данными, что подходит для builder'ов с очень
|
||||||
* большим количеством возможных данных внутри.
|
* большим количеством возможных данных внутри.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
* Подходит для игровых структур которые могут быть "разобраны" и пересобраны.
|
* Подходит для игровых структур которые могут быть "разобраны" и пересобраны.
|
||||||
*/
|
*/
|
||||||
class KTypeAdapter<T>(val factory: () -> T, vararg fields: KMutableProperty1<T, *>) : TypeAdapter<T>() {
|
class BuilderAdapter<T>(val factory: () -> T, vararg fields: KMutableProperty1<T, *>) : TypeAdapter<T>() {
|
||||||
private val mappedFields = Object2ObjectArrayMap<String, KMutableProperty1<T, in Any?>>()
|
private val mappedFields = Object2ObjectArrayMap<String, KMutableProperty1<T, in Any?>>()
|
||||||
// потому что returnType медленный
|
// потому что returnType медленный
|
||||||
private val mappedFieldsReturnTypes = Object2ObjectArrayMap<String, KType>()
|
private val mappedFieldsReturnTypes = Object2ObjectArrayMap<String, KType>()
|
||||||
@ -52,7 +50,7 @@ class KTypeAdapter<T>(val factory: () -> T, vararg fields: KMutableProperty1<T,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ignoreProperty(vararg value: String): KTypeAdapter<T> {
|
fun ignoreProperty(vararg value: String): BuilderAdapter<T> {
|
||||||
ignoreProperties.addAll(value)
|
ignoreProperties.addAll(value)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
@ -60,12 +58,12 @@ class KTypeAdapter<T>(val factory: () -> T, vararg fields: KMutableProperty1<T,
|
|||||||
var missingPropertiesAreFatal = true
|
var missingPropertiesAreFatal = true
|
||||||
var missingLogLevel = Level.ERROR
|
var missingLogLevel = Level.ERROR
|
||||||
|
|
||||||
fun missingPropertiesAreFatal(flag: Boolean): KTypeAdapter<T> {
|
fun missingPropertiesAreFatal(flag: Boolean): BuilderAdapter<T> {
|
||||||
missingPropertiesAreFatal = flag
|
missingPropertiesAreFatal = flag
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun missingLogLevel(level: Level): KTypeAdapter<T> {
|
fun missingLogLevel(level: Level): BuilderAdapter<T> {
|
||||||
missingLogLevel = level
|
missingLogLevel = level
|
||||||
return this
|
return this
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ private data class PackedProperty<Clazz : Any, T>(
|
|||||||
/**
|
/**
|
||||||
* TypeAdapter для классов которые создаются единожды и более не меняются ("бетонных классов").
|
* TypeAdapter для классов которые создаются единожды и более не меняются ("бетонных классов").
|
||||||
*/
|
*/
|
||||||
class KConcreteTypeAdapter<T : Any> private constructor(
|
class FactoryAdapter<T : Any> private constructor(
|
||||||
val bound: KClass<T>,
|
val bound: KClass<T>,
|
||||||
private val types: ImmutableList<PackedProperty<T, *>>,
|
private val types: ImmutableList<PackedProperty<T, *>>,
|
||||||
val asJsonArray: Boolean,
|
val asJsonArray: Boolean,
|
||||||
@ -354,7 +354,7 @@ class KConcreteTypeAdapter<T : Any> private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Позволяет построить класс [KConcreteTypeAdapter] на основе заданных параметров
|
* Позволяет построить класс [FactoryAdapter] на основе заданных параметров
|
||||||
*/
|
*/
|
||||||
class Builder<T : Any>(val clazz: KClass<T>) {
|
class Builder<T : Any>(val clazz: KClass<T>) {
|
||||||
private val types = ArrayList<PackedProperty<T, *>>()
|
private val types = ArrayList<PackedProperty<T, *>>()
|
||||||
@ -489,8 +489,8 @@ class KConcreteTypeAdapter<T : Any> private constructor(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun build(): KConcreteTypeAdapter<T> {
|
fun build(): FactoryAdapter<T> {
|
||||||
return KConcreteTypeAdapter(
|
return FactoryAdapter(
|
||||||
bound = clazz,
|
bound = clazz,
|
||||||
types = ImmutableList.copyOf(types),
|
types = ImmutableList.copyOf(types),
|
||||||
asJsonArray = asList,
|
asJsonArray = asList,
|
Loading…
Reference in New Issue
Block a user