root.monsterSkillParameter

This commit is contained in:
DBotThePony 2023-04-21 19:51:38 +07:00
parent 62b8ca34ed
commit f04df9feda
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 28 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import ru.dbotthepony.kstarbound.defs.item.impl.ItemPrototype
import ru.dbotthepony.kstarbound.defs.item.impl.LegsArmorItemPrototype
import ru.dbotthepony.kstarbound.defs.item.impl.LiquidItemPrototype
import ru.dbotthepony.kstarbound.defs.item.impl.MaterialItemPrototype
import ru.dbotthepony.kstarbound.defs.monster.MonsterSkillDefinition
import ru.dbotthepony.kstarbound.defs.npc.NpcTypeDefinition
import ru.dbotthepony.kstarbound.defs.npc.TenantDefinition
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
@ -148,6 +149,9 @@ class Starbound : ISBFileLocator {
private val _treasurePools = ObjectRegistry("treasure pools", TreasurePoolDefinition::name)
val treasurePools = _treasurePools.view
private val _monsterSkills = ObjectRegistry("monster skills", MonsterSkillDefinition::name)
val monsterSkills = _monsterSkills.view
val gson: Gson = with(GsonBuilder()) {
serializeNulls()
setDateFormat(DateFormat.LONG)
@ -724,6 +728,14 @@ class Starbound : ISBFileLocator {
1
}
state.setTableFunction("monsterSkillParameter", this) { args ->
val name = args.getString()
val param = args.getString()
// parity: если скила не существует, то оригинальный движок просто возвращает nil
args.push(monsterSkills[name]?.value?.config?.get(param))
1
}
state.pop()
state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua")
@ -918,6 +930,7 @@ class Starbound : ISBFileLocator {
loadStage(callback, _npcTypes, ext2files["npctype"] ?: listOf())
loadStage(callback, _projectiles, ext2files["projectile"] ?: listOf())
loadStage(callback, _tenants, ext2files["tenant"] ?: listOf())
loadStage(callback, _monsterSkills, ext2files["monsterskill"] ?: listOf())
pathStack.block("/") {
//playerDefinition = gson.fromJson(locate("/player.config").reader(), PlayerDefinition::class.java)

View File

@ -0,0 +1,15 @@
package ru.dbotthepony.kstarbound.defs.monster
import com.google.common.collect.ImmutableMap
import com.google.gson.JsonElement
import ru.dbotthepony.kstarbound.defs.image.ImageReference
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
@JsonFactory
data class MonsterSkillDefinition(
val name: String,
val label: String? = null,
val image: ImageReference? = null,
val config: ImmutableMap<String, JsonElement> = ImmutableMap.of(),
val animationParameters: ImmutableMap<String, JsonElement> = ImmutableMap.of(),
)