Skip to content

Commit

Permalink
add namespace to controllers + anims
Browse files Browse the repository at this point in the history
  • Loading branch information
12rcu committed Aug 24, 2024
1 parent 084ddbd commit ecf31c6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
10 changes: 10 additions & 0 deletions .fleet/run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"configurations": [
{
"type": "gradle",
"name": "Gradle Test",
"tasks": ["test"],
},

]
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ open class BehaviourEntity(val entityData: Entity.Data) : OverwriteComponents(en
* add a behaviour animation
*
* ```
* animation {
* animation("walk") {
* timeline {
*
* }
Expand All @@ -55,7 +55,7 @@ open class BehaviourEntity(val entityData: Entity.Data) : OverwriteComponents(en
* ```
*/
open fun animation(name: String, settings: BehAnimation.() -> Unit) {
unsafeRawAnimations.animation("animation.${entityData.name}.$name", settings)
unsafeRawAnimations.animation("animation.${entityData.addon.config.namespace}.${entityData.name}.$name", settings)
addSharedAnimation("animation.${entityData.name}.$name", name)
}

Expand Down Expand Up @@ -89,7 +89,7 @@ open class BehaviourEntity(val entityData: Entity.Data) : OverwriteComponents(en
* @param from the original entity where the animation was defined
*/
open fun addSharedAnimation(originalName: String, localName: String = originalName, from: Entity) {
addSharedAnimation("animation.${from.name}.$originalName", localName)
addSharedAnimation("animation.${entityData.addon.config.namespace}.${from.name}.$originalName", localName)
}

/**
Expand All @@ -108,7 +108,7 @@ open class BehaviourEntity(val entityData: Entity.Data) : OverwriteComponents(en
* @param data the controller
*/
open fun animController(name: String, query: Molang = Query.True, data: AnimationControllers.Controller.() -> Unit) {
val id = "controller.animation.${entityData.name}.$name"
val id = "controller.animation.${entityData.addon.config.namespace}.${entityData.name}.$name"
unsafeRawControllers.animController(id, data)
addSharedController(id, query, name)
}
Expand Down Expand Up @@ -142,7 +142,7 @@ open class BehaviourEntity(val entityData: Entity.Data) : OverwriteComponents(en
* @param query when the controller should be active - optional, default always
*/
open fun addSharedController(originalName: String, localName: String = originalName, from: Entity, query: Molang) {
addSharedController("controller.animation.${from.name}.$originalName", query, localName)
addSharedController("controller.animation.${entityData.addon.config.namespace}.${from.name}.$originalName", query, localName)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ open class RenderPart(val partName: String, query: Molang, val entityData: Entit
)
} else {
unsafeRenderController.apply {
controllers("${entityData.name}.$partName") {
controllers("${entityData.addon.config.namespace}.${entityData.name}.$partName") {
texture("Texture.default")
}
}
Expand All @@ -313,7 +313,7 @@ open class RenderPart(val partName: String, query: Molang, val entityData: Entit
materials.forEach { (bone, material) ->
this@description.material(materialEntityId(bone), material)
}
renderController("controller.render.${entityData.name}.$partName", Query(query))
renderController("controller.render.${entityData.addon.config.namespace}.${entityData.name}.$partName", Query(query))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ open class ResourceEntity(val entityData: Entity.Data) {
query: Molang = Query.True,
data: AnimationControllers.Controller.() -> Unit
) {
val idName = "controller.animation.${entityData.name}.${name.removePrefix("controller.animation.")}"
val idName = "controller.animation.${entityData.addon.config.namespace}.${entityData.name}.${name.removePrefix("controller.animation.")}"
unsafeControllers.animController(idName, data)

unsafeRawEntity.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class AnimControllerTest {
assert(
containsKeyChain(
"animation_controllers",
"controller.animation.my_anim_test.my_anim_controller",
"controller.animation.${config.namespace}.my_anim_test.my_anim_controller",
"initial_state"
)
)
assert(
containsKeyChainValue(
value = "(variable.my_var == 0)",
"animation_controllers",
"controller.animation.my_anim_test.my_anim_controller",
"controller.animation.${config.namespace}.my_anim_test.my_anim_controller",
"states",
"default",
"transitions",
Expand All @@ -72,7 +72,7 @@ class AnimControllerTest {
assert(
containsKeyChain(
"animation_controllers",
"controller.animation.my_anim_test.my_anim_controller",
"controller.animation.${config.namespace}.my_anim_test.my_anim_controller",
"states",
"success",
"on_entry"
Expand Down

0 comments on commit ecf31c6

Please sign in to comment.