Add is animation playing condition.

This commit is contained in:
Davide Tantillo 2025-12-15 12:17:18 +01:00
parent e06739647e
commit 57363110c3
5 changed files with 69 additions and 0 deletions

View File

@ -63,6 +63,23 @@
"type": "string" "type": "string"
} }
] ]
},
{
"id": "is-animation-playing",
"scriptName": "IsAnimationPlaying",
"isTrigger": false,
"params": [
{
"id": "animation-name",
"type": "string",
"initial-value": ""
},
{
"id": "track-index",
"type": "number",
"initial-value": -1
}
]
} }
], ],
"actions": [ "actions": [

View File

@ -26,4 +26,7 @@ C3.Plugins.EsotericSoftware_SpineConstruct3.Cnds =
IsInsideSlot (this: SpineC3Instance, x: number, y: number, slotName: string) { IsInsideSlot (this: SpineC3Instance, x: number, y: number, slotName: string) {
return this.isInsideSlot(x, y, slotName); return this.isInsideSlot(x, y, slotName);
}, },
IsAnimationPlaying (this: SpineC3Instance, animationName: string, trackIndex: number) {
return this.isAnimationPlaying(animationName, trackIndex);
},
}; };

View File

@ -310,6 +310,25 @@ class SpineC3Instance extends globalThis.ISDKWorldInstanceBase {
return this.isPointInPolygon(vertices, hullLength, coords.x, coords.y); return this.isPointInPolygon(vertices, hullLength, coords.x, coords.y);
} }
public isAnimationPlaying (animationName: string, trackIndex: number) {
if (!this.state) return false;
if (trackIndex === -1) {
for (const track of this.state.tracks) {
if (!track) continue;
if (animationName === "" || track.animation?.name === animationName) return true;
}
return false;
}
const track = this.state.tracks[trackIndex];
if (!track) return false;
if (animationName === "") return true;
return track.animation?.name === animationName;
}
private isPointInPolygon (vertices: NumberArrayLike, hullLength: number, px: number, py: number) { private isPointInPolygon (vertices: NumberArrayLike, hullLength: number, px: number, py: number) {
if (hullLength < 6) { if (hullLength < 6) {
throw new Error("A polygon must have at least 3 vertices (6 numbers in the array). "); throw new Error("A polygon must have at least 3 vertices (6 numbers in the array). ");

View File

@ -137,6 +137,21 @@
"desc": "Name of the slot to check" "desc": "Name of the slot to check"
} }
} }
},
"is-animation-playing": {
"list-name": "Is animation playing",
"display-text": "Is animation {0} playing on track {1}",
"description": "Check if animation is playing. Use empty string for animation or -1 for track to match any value.",
"params": {
"animation-name": {
"name": "Animation name",
"desc": "Animation name. Empty string matches any animation."
},
"track-index": {
"name": "Track index",
"desc": "Track index. Use -1 to check all tracks."
}
}
} }
}, },
"actions": { "actions": {

View File

@ -137,6 +137,21 @@
"desc": "要检查的插槽名称" "desc": "要检查的插槽名称"
} }
} }
},
"is-animation-playing": {
"list-name": "动画是否正在播放",
"display-text": "动画{0}是否在轨道{1}上播放",
"description": "检查动画是否正在播放。使用空字符串匹配任何动画,使用-1匹配所有轨道。",
"params": {
"animation-name": {
"name": "动画名称",
"desc": "动画名称。空字符串匹配任何动画。"
},
"track-index": {
"name": "轨道索引",
"desc": "轨道索引。使用-1检查所有轨道。"
}
}
} }
}, },
"actions": { "actions": {