mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 19:14:05 +09:00
blocks now have properly formatted ids
This commit is contained in:
@@ -29,13 +29,11 @@ object BlockCodex {
|
||||
println("[BlockCodex] Building block properties table")
|
||||
|
||||
records.forEach {
|
||||
if (intVal(it, "sid") == -1) {
|
||||
if (intVal(it, "blid") == -1) {
|
||||
setProp(nullProp, it)
|
||||
}
|
||||
else {
|
||||
setProp(
|
||||
blockProps[idDamageToIndex(intVal(it, "id"), intVal(it, "sid"))], it
|
||||
)
|
||||
setProp(blockProps[intVal(it, "blid")], it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,15 +42,13 @@ object BlockCodex {
|
||||
}
|
||||
}
|
||||
|
||||
fun get(index: Int, subID: Int): BlockProp {
|
||||
fun get(index: Int): BlockProp {
|
||||
try {
|
||||
blockProps[idDamageToIndex(index, subID)].id
|
||||
return blockProps[index]
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
throw NullPointerException("Blockprop with id $index and subID $subID does not exist.")
|
||||
throw NullPointerException("Blockprop with id $index does not exist.")
|
||||
}
|
||||
|
||||
return blockProps[idDamageToIndex(index, subID)]
|
||||
}
|
||||
|
||||
operator fun get(rawIndex: Int?): BlockProp {
|
||||
@@ -71,14 +67,13 @@ object BlockCodex {
|
||||
private fun setProp(prop: BlockProp, record: CSVRecord) {
|
||||
prop.nameKey = record.get("name")
|
||||
|
||||
prop.id = idDamageToIndex(intVal(record, "id"), intVal(record, "sid"))
|
||||
prop.id = intVal(record, "blid")
|
||||
prop.drop = intVal(record, "drid")
|
||||
|
||||
prop.opacity = intVal(record, "opacity")
|
||||
prop.strength = intVal(record, "strength")
|
||||
prop.density = intVal(record, "dsty")
|
||||
prop.luminosity = intVal(record, "lumcolor")
|
||||
prop.drop = intVal(record, "drop")
|
||||
prop.dropDamage = intVal(record, "ddmg")
|
||||
prop.friction = intVal(record, "friction")
|
||||
prop.viscosity = intVal(record, "vscs")
|
||||
|
||||
@@ -90,7 +85,7 @@ object BlockCodex {
|
||||
|
||||
prop.dynamicLuminosityFunction = intVal(record, "dlfn")
|
||||
|
||||
print(formatNum3(intVal(record, "id")) + ":" + formatNum2(intVal(record, "sid")))
|
||||
print("${intVal(record, "blid")}")
|
||||
println("\t" + prop.nameKey)
|
||||
}
|
||||
|
||||
@@ -107,16 +102,5 @@ object BlockCodex {
|
||||
|
||||
private fun boolVal(rec: CSVRecord, s: String) = intVal(rec, s) != 0
|
||||
|
||||
fun idDamageToIndex(index: Int, damage: Int) = index * PairedMapLayer.RANGE + damage
|
||||
|
||||
private fun formatNum3(i: Int): String {
|
||||
if (i < 10)
|
||||
return "00" + i
|
||||
else if (i < 100)
|
||||
return "0" + i
|
||||
else
|
||||
return i.toString()
|
||||
}
|
||||
|
||||
private fun formatNum2(i: Int) = if (i < 10) "0" + i else i.toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user