mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
more canisters
This commit is contained in:
@@ -173,10 +173,10 @@ id;classname;tags
|
|||||||
65536;net.torvald.terrarum.modulebasegame.gameitems.ItemFileRef;BASEOBJECT
|
65536;net.torvald.terrarum.modulebasegame.gameitems.ItemFileRef;BASEOBJECT
|
||||||
|
|
||||||
# fluids on storage
|
# fluids on storage
|
||||||
# FUTURE QUEST: autogenerate them using CONTAINERS CODEX
|
# FUTURE QUEST: autogenerate them using CANISTERS CODEX
|
||||||
# with new ItemID scheme:
|
# with new ItemID scheme:
|
||||||
# basegame_2<fluid@basegame:1
|
# basegame_2<fluid@basegame:1
|
||||||
# stands for a wooden bucket (CONTAINERS basegame_2) holding a block of water (fluid@basegame:1)
|
# stands for a wooden bucket (CANISTERS basegame_2) holding a block of water (fluid@basegame:1)
|
||||||
#
|
#
|
||||||
# FLUIDSTORAGE: required tag for buckets/canisters
|
# FLUIDSTORAGE: required tag for buckets/canisters
|
||||||
# OPENSTORAGE: cannot hold gas. Canisters need LIDDEDSTORAGE/SEALEDSTORAGE
|
# OPENSTORAGE: cannot hold gas. Canisters need LIDDEDSTORAGE/SEALEDSTORAGE
|
||||||
|
|||||||
|
@@ -14,6 +14,7 @@ import net.torvald.terrarum.gamecontroller.IME
|
|||||||
import net.torvald.terrarum.gameitems.FixtureInteractionBlocked
|
import net.torvald.terrarum.gameitems.FixtureInteractionBlocked
|
||||||
import net.torvald.terrarum.gameitems.GameItem
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
import net.torvald.terrarum.gameitems.ItemID
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.itemproperties.CanistersCodex
|
||||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
@@ -942,6 +943,18 @@ object ModMgr {
|
|||||||
watchdogs["$moduleName.${watchdog.javaClass.simpleName}"] = watchdog
|
watchdogs["$moduleName.${watchdog.javaClass.simpleName}"] = watchdog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object GameCanistersLoader {
|
||||||
|
const val canisterPath = "canisters/"
|
||||||
|
|
||||||
|
init {
|
||||||
|
Terrarum.canistersCodex = CanistersCodex()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic operator fun invoke(module: String) {
|
||||||
|
Terrarum.canistersCodex.fromModule(module, canisterPath + "canisters.csv")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class JarFileLoader(urls: Array<URL>) : URLClassLoader(urls) {
|
private class JarFileLoader(urls: Array<URL>) : URLClassLoader(urls) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import net.torvald.terrarum.gameactors.ActorWithBody
|
|||||||
import net.torvald.terrarum.gameactors.ActorWithBody.Companion.METER
|
import net.torvald.terrarum.gameactors.ActorWithBody.Companion.METER
|
||||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||||
import net.torvald.terrarum.gameworld.fmod
|
import net.torvald.terrarum.gameworld.fmod
|
||||||
|
import net.torvald.terrarum.itemproperties.CanistersCodex
|
||||||
import net.torvald.terrarum.itemproperties.CraftingCodex
|
import net.torvald.terrarum.itemproperties.CraftingCodex
|
||||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||||
@@ -86,6 +87,7 @@ object Terrarum : Disposable {
|
|||||||
var oreCodex = OreCodex(); internal set
|
var oreCodex = OreCodex(); internal set
|
||||||
var audioCodex = AudioCodex(); internal set
|
var audioCodex = AudioCodex(); internal set
|
||||||
var weatherCodex = WeatherCodex(); internal set
|
var weatherCodex = WeatherCodex(); internal set
|
||||||
|
var canistersCodex = CanistersCodex(); internal set
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|||||||
75
src/net/torvald/terrarum/itemproperties/CanistersCodex.kt
Normal file
75
src/net/torvald/terrarum/itemproperties/CanistersCodex.kt
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package net.torvald.terrarum.itemproperties
|
||||||
|
|
||||||
|
import net.torvald.terrarum.App.printdbg
|
||||||
|
import net.torvald.terrarum.blockproperties.intVal
|
||||||
|
import net.torvald.terrarum.gameitems.ItemID
|
||||||
|
import net.torvald.terrarum.utils.CSVFetcher
|
||||||
|
import org.apache.commons.csv.CSVRecord
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2025-04-29.
|
||||||
|
*/
|
||||||
|
class CanistersCodex {
|
||||||
|
|
||||||
|
@Transient val CanisterProps = HashMap<ItemID, CanisterProp>() // itemID is <modulename>_<index>
|
||||||
|
|
||||||
|
@Transient private val nullProp = CanisterProp()
|
||||||
|
|
||||||
|
|
||||||
|
operator fun get(canister: ItemID?): CanisterProp {
|
||||||
|
if (canister == null || canister.substringAfter('_').substringBefore(':').substringBefore('@') == "0") {
|
||||||
|
return nullProp
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return CanisterProps[canister]!!
|
||||||
|
}
|
||||||
|
catch (e: NullPointerException) {
|
||||||
|
throw NullPointerException("CanisterProp with id $canister does not exist.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOrNull(blockID: ItemID?): CanisterProp? {
|
||||||
|
return CanisterProps[blockID]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Later entry (possible from other modules) will replace older ones
|
||||||
|
*/
|
||||||
|
fun fromModule(module: String, path: String, registerHook: (CanisterProp) -> Unit = {}) {
|
||||||
|
printdbg(this, "Building fluid properties table")
|
||||||
|
try {
|
||||||
|
register(module, CSVFetcher.readFromModule(module, path), registerHook)
|
||||||
|
}
|
||||||
|
catch (e: IOException) { e.printStackTrace() }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun register(module: String, records: List<CSVRecord>, registerHook: (CanisterProp) -> Unit) {
|
||||||
|
records.forEach {
|
||||||
|
setProp(module, it.intVal("id"), it)
|
||||||
|
val tileId = "${module}_${it.intVal("id")}"
|
||||||
|
CanisterProps[tileId]?.let(registerHook)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setProp(module: String, key: Int, record: CSVRecord) {
|
||||||
|
val prop = CanisterProp()
|
||||||
|
prop.tags = record.get("tags").split(',').map { it.trim().toUpperCase() }.toHashSet()
|
||||||
|
prop.id = "${module}_$key"
|
||||||
|
prop.itemID = record.get("itemid")
|
||||||
|
|
||||||
|
CanisterProps[prop.id] = prop
|
||||||
|
|
||||||
|
printdbg(this, "Setting canister prop ${prop.id}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2025-04-29.
|
||||||
|
*/
|
||||||
|
class CanisterProp {
|
||||||
|
var id: ItemID = ""
|
||||||
|
var itemID: ItemID = ""
|
||||||
|
@Transient var tags = HashSet<String>()
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ class EntryPoint : ModuleEntryPoint() {
|
|||||||
ModMgr.GameLanguageLoader.invoke(moduleName)
|
ModMgr.GameLanguageLoader.invoke(moduleName)
|
||||||
ModMgr.GameAudioLoader.invoke(moduleName)
|
ModMgr.GameAudioLoader.invoke(moduleName)
|
||||||
ModMgr.GameWeatherLoader.invoke(moduleName)
|
ModMgr.GameWeatherLoader.invoke(moduleName)
|
||||||
|
ModMgr.GameCanistersLoader.invoke(moduleName)
|
||||||
|
|
||||||
WeatherCodex.weatherById["titlescreen"] =
|
WeatherCodex.weatherById["titlescreen"] =
|
||||||
WeatherCodex.getById("generic01")?.copy(identifier = "titlescreen", windSpeed = 1f) ?: WeatherMixer.DEFAULT_WEATHER
|
WeatherCodex.getById("generic01")?.copy(identifier = "titlescreen", windSpeed = 1f) ?: WeatherMixer.DEFAULT_WEATHER
|
||||||
|
|||||||
Reference in New Issue
Block a user