diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt index 7a84a806..fc71da19 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/Starbound.kt @@ -749,6 +749,13 @@ class Starbound : ISBFileLocator { 1 } + state.setTableFunction("monsterMovementSettings", this) { args -> + val name = args.getString() + val monster = monsterTypes[name] ?: throw NoSuchElementException("No such monster type $name") + args.push(gson.toJsonTree(monster.value.baseParameters.movementSettings)) + 1 + } + state.pop() state.load(polyfill, "@starbound.jar!/scripts/polyfill.lua") diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/JumpProfile.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/JumpProfile.kt similarity index 79% rename from src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/JumpProfile.kt rename to src/main/kotlin/ru/dbotthepony/kstarbound/defs/JumpProfile.kt index 856e064b..157222b1 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/JumpProfile.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/JumpProfile.kt @@ -1,4 +1,4 @@ -package ru.dbotthepony.kstarbound.defs.player +package ru.dbotthepony.kstarbound.defs import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory @@ -7,4 +7,4 @@ data class JumpProfile( val jumpSpeed: Double, val jumpInitialPercentage: Double, val jumpHoldTime: Double, -) \ No newline at end of file +) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/MovementParameters.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/MovementParameters.kt new file mode 100644 index 00000000..2b222caa --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/MovementParameters.kt @@ -0,0 +1,22 @@ +package ru.dbotthepony.kstarbound.defs + +import com.google.common.collect.ImmutableList +import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory +import ru.dbotthepony.kvector.vector.ndouble.Vector2d + +@JsonFactory +data class MovementParameters( + val flySpeed: Double? = null, + val airFriction: Double? = null, + val airJumpProfile: JumpProfile? = null, + val airForce: Double? = null, + + val runSpeed: Double? = null, + val walkSpeed: Double? = null, + val mass: Double? = null, + + // TODO: А оно вообще используется? Как по мне движок старбаунда генерирует коллизию из пикселей текстуры + val collisionPoly: ImmutableList? = null, + val crouchingPoly: ImmutableList? = null, + val standingPoly: ImmutableList? = null, +) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterTypeDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterTypeDefinition.kt index bf3db1dc..b7393d94 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterTypeDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/monster/MonsterTypeDefinition.kt @@ -4,7 +4,10 @@ import com.google.common.collect.ImmutableList import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet import ru.dbotthepony.kstarbound.defs.AssetReference +import ru.dbotthepony.kstarbound.defs.DirectAssetReference +import ru.dbotthepony.kstarbound.defs.IScriptable import ru.dbotthepony.kstarbound.defs.IThingWithDescription +import ru.dbotthepony.kstarbound.defs.MovementParameters import ru.dbotthepony.kstarbound.defs.RegistryReference import ru.dbotthepony.kstarbound.defs.animation.AnimationDefinition import ru.dbotthepony.kstarbound.defs.item.TreasurePoolDefinition @@ -20,5 +23,12 @@ data class MonsterTypeDefinition( val animation: AssetReference, // [ { "default" : "poptopTreasure", "bow" : "poptopHunting" } ], val dropPools: ImmutableList>>, - // val baseParameters -) : IThingWithDescription + val baseParameters: BaseParameters +) : IThingWithDescription { + @JsonFactory + data class BaseParameters( + val movementSettings: MovementParameters? = null, + override val scriptDelta: Int = 1, + override val scripts: ImmutableList + ) : IScriptable +} diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/MovementParameters.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/MovementParameters.kt deleted file mode 100644 index dd51ecf0..00000000 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/MovementParameters.kt +++ /dev/null @@ -1,11 +0,0 @@ -package ru.dbotthepony.kstarbound.defs.player - -import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory - -@JsonFactory -data class MovementParameters( - val flySpeed: Double? = null, - val airFriction: Double? = null, - val airJumpProfile: JumpProfile? = null, - val airForce: Double? = null, -) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/PlayerDefinition.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/PlayerDefinition.kt index 62e40649..f6ec416f 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/PlayerDefinition.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/defs/player/PlayerDefinition.kt @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableMap import com.google.common.collect.ImmutableSet import com.google.gson.JsonObject import ru.dbotthepony.kstarbound.defs.AssetReference +import ru.dbotthepony.kstarbound.defs.MovementParameters import ru.dbotthepony.kstarbound.defs.RegistryReference import ru.dbotthepony.kstarbound.defs.Species import ru.dbotthepony.kstarbound.util.SBPattern