diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt index dce62ae5..ff7f0ecc 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Main.kt @@ -71,7 +71,7 @@ fun main() { for (y in 0 .. 31) { for (x in 0 .. 31) { val materialID = reader.readUnsignedShort() - val getMat = Starbound.tilesAccessID[materialID] + val getMat = Starbound.TILE_BY_ID[materialID] if (getMat != null) { chunk.foreground[x, y].material = getMat @@ -84,7 +84,7 @@ fun main() { val colorVariant = reader.readUnsignedByte() val modifier = reader.readUnsignedShort() - val getModifier = Starbound.tileModifiersByIDAccess[modifier] + val getModifier = Starbound.TILE_MODIFIER_BY_ID[modifier] chunk.foreground[x, y].color = colorVariant chunk.foreground[x, y].setHueShift(colorShift) @@ -98,7 +98,7 @@ fun main() { chunk.foreground[x, y].setModifierHueShift(modifierHueShift) val materialID2 = reader.readUnsignedShort() - val getMat2 = Starbound.tilesAccessID[materialID2] + val getMat2 = Starbound.TILE_BY_ID[materialID2] if (getMat2 != null) { chunk.background[x, y].material = getMat2 @@ -112,7 +112,7 @@ fun main() { val colorVariant2 = reader.readUnsignedByte() val modifier2 = reader.readUnsignedShort() - val getModifier2 = Starbound.tileModifiersByIDAccess[modifier2] + val getModifier2 = Starbound.TILE_MODIFIER_BY_ID[modifier2] if (getModifier2 != null && getMat2 != null) { chunk.background[x, y].modifier = getModifier2 @@ -136,7 +136,7 @@ fun main() { val indestructible = reader.readBoolean() val unknown = reader.readUnsignedByte() - val getLiquid = Starbound.liquidByIDAccess[liquid] + val getLiquid = Starbound.LIQUID_BY_ID[liquid] if (getLiquid != null) { val state = chunk.setLiquid(x, y, getLiquid)!! @@ -163,7 +163,7 @@ fun main() { //client.world!!.parallax = Starbound.parallaxAccess["garden"] for (i in 0 .. 16) { - val item = ItemEntity(client.world!!, Starbound.itemAccess["money"]!!) + val item = ItemEntity(client.world!!, Starbound.ITEM["money"]!!) item.position = Vector2d(600.0 + 16.0 + i, 721.0 + 48.0) item.spawn() diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 9336c472..7e74d20d 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -109,16 +109,16 @@ object Starbound { private val items = Object2ObjectOpenHashMap() - val liquidAccess: Map = Collections.unmodifiableMap(liquid) - val liquidByIDAccess: Map = Collections.unmodifiableMap(liquidByID) - val tileModifiersAccess: Map = Collections.unmodifiableMap(tileModifiers) - val tileModifiersByIDAccess: Map = Collections.unmodifiableMap(tileModifiersByID) - val tilesAccess: Map = Collections.unmodifiableMap(tiles) - val tilesAccessID: Map = Collections.unmodifiableMap(tilesByMaterialID) - val projectilesAccess: Map = Collections.unmodifiableMap(projectiles) - val parallaxAccess: Map = Collections.unmodifiableMap(parallax) - val functionsAccess: Map = Collections.unmodifiableMap(functions) - val itemAccess: Map = Collections.unmodifiableMap(items) + val LIQUID: Map = Collections.unmodifiableMap(liquid) + val LIQUID_BY_ID: Map = Collections.unmodifiableMap(liquidByID) + val TILE_MODIFIER: Map = Collections.unmodifiableMap(tileModifiers) + val TILE_MODIFIER_BY_ID: Map = Collections.unmodifiableMap(tileModifiersByID) + val TILE: Map = Collections.unmodifiableMap(tiles) + val TILE_BY_ID: Map = Collections.unmodifiableMap(tilesByMaterialID) + val PROJECTILE: Map = Collections.unmodifiableMap(projectiles) + val PARALLAX: Map = Collections.unmodifiableMap(parallax) + val FUNCTION: Map = Collections.unmodifiableMap(functions) + val ITEM: Map = Collections.unmodifiableMap(items) val STRING_INTERNER: Interner = Interners.newStrongInterner() @@ -134,7 +134,7 @@ object Starbound { val NULLABLE_STRING_ADAPTER: TypeAdapter = STRING_ADAPTER.nullSafe() - val gson: Gson = GsonBuilder() + val GSON: Gson = GsonBuilder() .enableComplexMapKeySerialization() .serializeNulls() .setDateFormat(DateFormat.LONG) @@ -192,7 +192,7 @@ object Starbound { Int::class.java -> TypeAdapters.INTEGER as TypeAdapter Long::class.java -> TypeAdapters.LONG as TypeAdapter Boolean::class.java -> TypeAdapters.BOOLEAN as TypeAdapter - else -> gson.getAdapter(type) + else -> GSON.getAdapter(type) } } @@ -365,7 +365,7 @@ object Starbound { callback("Loading $listedFile") assetFolder = listedFile.computeDirectory() - val tileDef = gson.fromJson(listedFile.reader(), TileDefinition::class.java) + val tileDef = GSON.fromJson(listedFile.reader(), TileDefinition::class.java) check(tiles[tileDef.materialName] == null) { "Already has material with name ${tileDef.materialName} loaded!" } check(tilesByMaterialID[tileDef.materialId] == null) { "Already has material with ID ${tileDef.materialId} loaded!" } @@ -392,7 +392,7 @@ object Starbound { callback("Loading $listedFile") assetFolder = listedFile.computeDirectory() - val def = gson.fromJson(listedFile.reader(), ConfigurableProjectile::class.java).assemble(listedFile.computeDirectory()) + val def = GSON.fromJson(listedFile.reader(), ConfigurableProjectile::class.java).assemble(listedFile.computeDirectory()) check(projectiles[def.projectileName] == null) { "Already has projectile with ID ${def.projectileName} loaded!" } projectiles[def.projectileName] = def } catch(err: Throwable) { @@ -419,7 +419,7 @@ object Starbound { val readObject = JsonParser.parseReader(listedFile.reader()) as JsonObject for (key in readObject.keySet()) { - val def = gson.fromJson(readObject[key], JsonFunction::class.java) + val def = GSON.fromJson(readObject[key], JsonFunction::class.java) functions[key] = def } } catch(err: Throwable) { @@ -442,7 +442,7 @@ object Starbound { callback("Loading $listedFile") assetFolder = listedFile.computeDirectory() - val def = gson.fromJson(listedFile.reader(), ParallaxPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ParallaxPrototype::class.java) parallax[listedFile.name.substringBefore('.')] = def } catch(err: Throwable) { LOGGER.error("Loading parallax file $listedFile", err) @@ -466,7 +466,7 @@ object Starbound { callback("Loading $listedFile") assetFolder = listedFile.computeDirectory() - val tileDef = gson.fromJson(listedFile.reader(), MaterialModifier::class.java) + val tileDef = GSON.fromJson(listedFile.reader(), MaterialModifier::class.java) check(tileModifiers[tileDef.modName] == null) { "Already has material with name ${tileDef.modName} loaded!" } check(tileModifiersByID[tileDef.modId] == null) { "Already has material with ID ${tileDef.modId} loaded!" } @@ -493,7 +493,7 @@ object Starbound { callback("Loading $listedFile") assetFolder = listedFile.computeDirectory() - val liquidDef = gson.fromJson(listedFile.reader(), LiquidDefinition::class.java) + val liquidDef = GSON.fromJson(listedFile.reader(), LiquidDefinition::class.java) check(liquid.put(liquidDef.name, liquidDef) == null) { "Already has liquid with name ${liquidDef.name} loaded!" } check(liquidByID.put(liquidDef.liquidId, liquidDef) == null) { "Already has liquid with ID ${liquidDef.liquidId} loaded!" } @@ -522,25 +522,25 @@ object Starbound { assetFolder = listedFile.computeDirectory() if (listedFile.name.endsWith(".item")) { - val def = gson.fromJson(listedFile.reader(), ItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ItemPrototype::class.java) check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } else if (listedFile.name.endsWith(".currency")) { - val def = gson.fromJson(listedFile.reader(), CurrencyItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), CurrencyItemPrototype::class.java) check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } else if (listedFile.name.endsWith(".head")) { - val def = gson.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) def.armorType = ArmorPieceType.HEAD check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } else if (listedFile.name.endsWith(".chest")) { - val def = gson.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) def.armorType = ArmorPieceType.CHEST check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } else if (listedFile.name.endsWith(".legs")) { - val def = gson.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) def.armorType = ArmorPieceType.LEGS check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } else if (listedFile.name.endsWith(".back")) { - val def = gson.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) + val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java) def.armorType = ArmorPieceType.BACK check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt index 92cc459e..8f2e6976 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/render/TileRenderer.kt @@ -70,14 +70,14 @@ class TileRenderers(val state: GLStateTracker) { fun getTileRenderer(defName: String): TileRenderer { return tileRenderersCache.computeIfAbsent(defName) { - val def = Starbound.tilesAccess[defName] // TODO: Пустой рендерер + val def = Starbound.TILE[defName] // TODO: Пустой рендерер return@computeIfAbsent TileRenderer(state, def!!) } } fun getModifierRenderer(defName: String): TileRenderer { return modifierRenderersCache.computeIfAbsent(defName) { - val def = Starbound.tileModifiersAccess[defName] // TODO: Пустой рендерер + val def = Starbound.TILE_MODIFIER[defName] // TODO: Пустой рендерер return@computeIfAbsent TileRenderer(state, def!!) } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/AtlasConfiguration.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/AtlasConfiguration.kt index 2105916c..e1e1308f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/AtlasConfiguration.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/image/AtlasConfiguration.kt @@ -190,8 +190,8 @@ class AtlasConfiguration private constructor( val sprites = LinkedHashMap() if (frameGrid is JsonObject) { - val size = Starbound.gson.fromJson(frameGrid["size"] ?: throw JsonSyntaxException("Missing frameGrid.size"), Vector2i::class.java) - val dimensions = Starbound.gson.fromJson(frameGrid["dimensions"] ?: throw JsonSyntaxException("Missing frameGrid.dimensions"), Vector2i::class.java) + val size = Starbound.GSON.fromJson(frameGrid["size"] ?: throw JsonSyntaxException("Missing frameGrid.size"), Vector2i::class.java) + val dimensions = Starbound.GSON.fromJson(frameGrid["dimensions"] ?: throw JsonSyntaxException("Missing frameGrid.dimensions"), Vector2i::class.java) require(size.x >= 0) { "Invalid size.x: ${size.x}" } require(size.y >= 0) { "Invalid size.y: ${size.y}" } @@ -230,7 +230,7 @@ class AtlasConfiguration private constructor( } for ((spriteName, coords) in frameList.entrySet()) { - sprites[spriteName] = Sprite(spriteName, Starbound.gson.fromJson(coords, Vector4i::class.java)) + sprites[spriteName] = Sprite(spriteName, Starbound.GSON.fromJson(coords, Vector4i::class.java)) } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt index 2e769615..f2c2bac2 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configurable.kt @@ -149,11 +149,11 @@ private val LOGGER = LogManager.getLogger() */ private fun constructAction(input: JsonObject): IConfigurableAction? { return when (val elem = (input["action"] ?: throw IllegalArgumentException("Action has no, well, `action` key to specify whatever is it.")).asString) { - "config" -> Starbound.gson.fromJson(input, ActionConfig::class.java) - "projectile" -> Starbound.gson.fromJson(input, ActionProjectile::class.java) - "sound" -> Starbound.gson.fromJson(input, ActionSound::class.java) - "loop" -> Starbound.gson.fromJson(input, ActionLoop::class.java) - "actions" -> Starbound.gson.fromJson(input, ActionActions::class.java) + "config" -> Starbound.GSON.fromJson(input, ActionConfig::class.java) + "projectile" -> Starbound.GSON.fromJson(input, ActionProjectile::class.java) + "sound" -> Starbound.GSON.fromJson(input, ActionSound::class.java) + "loop" -> Starbound.GSON.fromJson(input, ActionLoop::class.java) + "actions" -> Starbound.GSON.fromJson(input, ActionActions::class.java) else -> { if (!MISSING_ACTIONS.contains(elem)) { MISSING_ACTIONS.add(elem) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt index 2e12b722..68f745ed 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/projectile/Configured.kt @@ -67,7 +67,7 @@ data class CActionProjectile( override val name: String = "projectile" override fun execute(projectile: Projectile) { - val def = Starbound.projectilesAccess[type] + val def = Starbound.PROJECTILE[type] if (def == null) { LOGGER.error("Tried to create unknown projectile '{}' as result of reap of '{}'!", type, projectile.def.projectileName) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt index e0f88da9..1d04dad9 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/tile/RenderTemplate.kt @@ -305,7 +305,7 @@ data class RenderTemplate( } return cache.computeIfAbsent(path) { - return@computeIfAbsent Starbound.gson.fromJson(Starbound.locate(it).reader(), RenderTemplate::class.java) + return@computeIfAbsent Starbound.GSON.fromJson(Starbound.locate(it).reader(), RenderTemplate::class.java) } } }