Более правильные имена

This commit is contained in:
DBotThePony 2023-01-02 00:11:55 +07:00
parent 3da8450a2c
commit 7eaccacc68
Signed by: DBot
GPG Key ID: DCC23B5715498507
7 changed files with 42 additions and 42 deletions

View File

@ -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()

View File

@ -109,16 +109,16 @@ object Starbound {
private val items = Object2ObjectOpenHashMap<String, IItemDefinition>()
val liquidAccess: Map<String, LiquidDefinition> = Collections.unmodifiableMap(liquid)
val liquidByIDAccess: Map<Int, LiquidDefinition> = Collections.unmodifiableMap(liquidByID)
val tileModifiersAccess: Map<String, MaterialModifier> = Collections.unmodifiableMap(tileModifiers)
val tileModifiersByIDAccess: Map<Int, MaterialModifier> = Collections.unmodifiableMap(tileModifiersByID)
val tilesAccess: Map<String, TileDefinition> = Collections.unmodifiableMap(tiles)
val tilesAccessID: Map<Int, TileDefinition> = Collections.unmodifiableMap(tilesByMaterialID)
val projectilesAccess: Map<String, ConfiguredProjectile> = Collections.unmodifiableMap(projectiles)
val parallaxAccess: Map<String, ParallaxPrototype> = Collections.unmodifiableMap(parallax)
val functionsAccess: Map<String, JsonFunction> = Collections.unmodifiableMap(functions)
val itemAccess: Map<String, IItemDefinition> = Collections.unmodifiableMap(items)
val LIQUID: Map<String, LiquidDefinition> = Collections.unmodifiableMap(liquid)
val LIQUID_BY_ID: Map<Int, LiquidDefinition> = Collections.unmodifiableMap(liquidByID)
val TILE_MODIFIER: Map<String, MaterialModifier> = Collections.unmodifiableMap(tileModifiers)
val TILE_MODIFIER_BY_ID: Map<Int, MaterialModifier> = Collections.unmodifiableMap(tileModifiersByID)
val TILE: Map<String, TileDefinition> = Collections.unmodifiableMap(tiles)
val TILE_BY_ID: Map<Int, TileDefinition> = Collections.unmodifiableMap(tilesByMaterialID)
val PROJECTILE: Map<String, ConfiguredProjectile> = Collections.unmodifiableMap(projectiles)
val PARALLAX: Map<String, ParallaxPrototype> = Collections.unmodifiableMap(parallax)
val FUNCTION: Map<String, JsonFunction> = Collections.unmodifiableMap(functions)
val ITEM: Map<String, IItemDefinition> = Collections.unmodifiableMap(items)
val STRING_INTERNER: Interner<String> = Interners.newStrongInterner()
@ -134,7 +134,7 @@ object Starbound {
val NULLABLE_STRING_ADAPTER: TypeAdapter<String?> = 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<T>
Long::class.java -> TypeAdapters.LONG as TypeAdapter<T>
Boolean::class.java -> TypeAdapters.BOOLEAN as TypeAdapter<T>
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!" }
}

View File

@ -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!!)
}
}

View File

@ -190,8 +190,8 @@ class AtlasConfiguration private constructor(
val sprites = LinkedHashMap<String, Sprite>()
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))
}
}

View File

@ -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)

View File

@ -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)

View File

@ -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)
}
}
}