Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Added new features for reading animation evend data values.
Browse files Browse the repository at this point in the history
  • Loading branch information
eaquex authored and MikalDev committed Feb 28, 2022
1 parent 8023201 commit 5bba19e
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 5 deletions.
43 changes: 42 additions & 1 deletion src/aces.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@
}
]
},
{
"id": "on-any-event",
"scriptName": "OnAnyEvent",
"isTrigger": true,
"params": [
{
"id": "track-index",
"type": "number",
"initial-value": 0
}
]
},
{
"id": "is-bone-control-property-active",
"scriptName": "IsBoneControlPropertyActive",
Expand Down Expand Up @@ -1130,7 +1142,36 @@
"highlight": false,
"returnType": "number",
"params": []
}
},
{
"id": "get-event-name",
"expressionName": "GetEventName",
"scriptName": "GetEventName",
"highlight": false,
"returnType": "string",
"params": []
},
{
"id": "get-event-track-index",
"expressionName": "GetEventTrackIndex",
"scriptName": "GetEventTrackIndex",
"highlight": false,
"returnType": "string",
"params": []
},
{
"id": "get-event-data",
"expressionName": "GetEventData",
"scriptName": "GetEventData",
"highlight": false,
"returnType": "any",
"params": [
{
"id": "field",
"type": "string"
}
]
}
]
}
}
4 changes: 3 additions & 1 deletion src/c3runtime/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
OnEvent(eventName, trackIndex) {
return (this.completeEventName === eventName) && (this.completeEventTrackIndex === trackIndex);
},

OnAnyEvent(trackIndex) {
return (this.completeEventTrackIndex === trackIndex);
},
IsBoneControlPropertyActive(bone, propertyIndex) {
let properties=['x','y','rotation','scaleX','scaleY'];
let property = properties[propertyIndex];
Expand Down
17 changes: 17 additions & 0 deletions src/c3runtime/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@
},
SkeletonScale(){
return this.skeletonScale;
},
GetEventName() {
return this.completeEventName;
},
GetEventTrackIndex() {
return this.completeEventTrackIndex;
},
GetEventData(field) {
const fieldList = ["float", "int", "string", "balance", "volume", "audiopath", "event", "track"]

if (!(fieldList.includes(field)))
return "";

if (!(field in this.completeEventData))
return "";

return this.completeEventData[field];
}
};
}
34 changes: 32 additions & 2 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
this.completeEventName = ""
this.textureWidth = 0;
this.textureHeight = 0;
this.completeEventData = { }


// @ts-ignore
const wi = this.GetWorldInfo();
Expand Down Expand Up @@ -290,6 +292,7 @@
stateData.defaultMix = this.defaultMix;
// @ts-ignore
var state = new spine.AnimationState(stateData);

state.setAnimation(0, animationName, true);
// Record animation assigned for listener
this.trackAnimations[0] = this.animationName;
Expand All @@ -304,9 +307,22 @@
},
event: (trackEntry, event) => {
this.completeEventName = event.data.name;
this.completeEventTrackIndex = trackEntry.trackIndex;
this.completeEventTrackIndex = trackEntry.trackIndex;

this.completeEventData = {
'float' : event.floatValue,
'int' : event.intValue,
'string' : event.stringValue,
'balance' : event.balance,
'volume' : event.volume,
'audiopath' : event.data.audioPath,
'event' : event.data.name,
'track' : trackEntry.trackIndex
}

// @ts-ignore
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyEvent);
}
};

Expand Down Expand Up @@ -496,9 +512,22 @@
},
event: (trackEntry, event) => {
this.completeEventName = event.data.name;
this.completeEventTrackIndex = trackEntry.trackIndex;
this.completeEventTrackIndex = trackEntry.trackIndex;

this.completeEventData = {
'float' : event.floatValue,
'int' : event.intValue,
'string' : event.stringValue,
'balance' : event.balance,
'volume' : event.volume,
'audiopath' : event.data.audioPath,
'event' : event.data.name,
'track' : trackEntry.trackIndex
}

// @ts-ignore
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnEvent);
this.Trigger(C3.Plugins.Gritsenko_Spine.Cnds.OnAnyEvent);
}
};
}
Expand Down Expand Up @@ -648,6 +677,7 @@
this.spineError = null
this.animationSpeed = null;
this.completeEventName = null;
this.completeEventData = null;
this.skeletonRenderQuality = null;
this.textureWidth = null;
this.textureHeight = null;
Expand Down
33 changes: 32 additions & 1 deletion src/lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@
}
}
},
"on-any-event": {
"list-name": "On any animation event",
"display-text": "On any event on track {0}",
"description": "Triggered on any event on specified track.",
"params": {
"track-index": {
"name": "Track index",
"desc": "Track index"
}
}
},
"is-bone-control-property-active": {
"list-name": "Is bone control property active",
"display-text": "Is {0} {1} control active",
Expand Down Expand Up @@ -1085,7 +1096,27 @@
"description": "Skeleton scale",
"translated-name": "SkeletonScale",
"params": {}
}
},
"get-event-name": {
"description": "Get current event name on the current track",
"translated-name": "GetEventName",
"params": {}
},
"get-event-track-index": {
"description": "Get track index of the current event",
"translated-name": "GetEventTrackIndex",
"params": {}
},
"get-event-data": {
"description": "Get value field of the current event",
"translated-name": "GetEventData",
"params": {
"field": {
"name": "Field",
"desc": "The field of the event data to read (float,int,string,balance,volume,audiopath,event,track)"
}
}
}
}
}
}
Expand Down

0 comments on commit 5bba19e

Please sign in to comment.