private void _queueAnimation(object[] args) { // queueAnimation(string partyMemberSelector, string animationName, [Script onStartCallback], [Script onFinishCallback]) string partyMemberSelector = (string)args[0]; string animationName = (string)args[1]; Script onStartCallback = args.Length <= 2 ? null : (Script)args[2]; Script onFinishCallback = args.Length <= 3 ? null : (Script)args[3]; PartyMember partyMember = getPartyMemberFromSelector(partyMemberSelector); AnimationState animationState = partyMember.BattleEntity.AnimationState; Animation animation = animationState.Data.SkeletonData.FindAnimation(animationName); if (animation == null) { throw new Exception("Animation '" + animationName + "' could not be found"); } float animationStateTime = animationState.Time; float timeToCurrentAnimationEnd = animationState.Animation.Duration - (animationStateTime % animationState.Animation.Duration); animationState.AddAnimation(animation, false, animationStateTime + timeToCurrentAnimationEnd); animationState.AddAnimation(partyMember.GetBattleEntityIdleAnimationName(), true); if (onStartCallback != null) { addNestedScriptRunner(onStartCallback, timeToCurrentAnimationEnd); } if (onFinishCallback != null) { addNestedScriptRunner(onFinishCallback, timeToCurrentAnimationEnd + animation.Duration); } }
private void _playAnimation(object[] args) { // playAnimation(string partyMemberSelector, string animationName, [Script onFinishCallback]) string partyMemberSelector = (string)args[0]; string animationName = (string)args[1]; Script onFinishCallback = args.Length <= 2 ? null : (Script)args[2]; PartyMember partyMember = getPartyMemberFromSelector(partyMemberSelector); AnimationState animationState = partyMember.BattleEntity.AnimationState; Animation animation = animationState.Data.SkeletonData.FindAnimation(animationName); if (animation == null) { throw new Exception("Animation '" + animationName + "' could not be found"); } animationState.SetAnimation(animation, false); animationState.AddAnimation(partyMember.GetBattleEntityIdleAnimationName(), true); if (onFinishCallback != null) { addNestedScriptRunner(onFinishCallback, animation.Duration); } }