示例#1
0
        public void PostAnimationEvent(ActionUsingNode node, string eventName)
        {
            if (Events.TryGetValue(eventName, out var animationEvent))
            {
                animationEvent.Trigger(node, eventName);
            }
            ActionStateEvents state = AnimationEvents.ToStateEvent(eventName);

            if (state == ActionStateEvents.Activate)
            {
                node.Entity.Post(new ActionStateEvent(node.Entity, node.Entity, node.Animator.GetEventPosition, node.Animator.GetEventRotation, ActionStateEvents.Activate));
            }
            if (state == ActionStateEvents.None)
            {
                return;
            }
            var stateEvent = new ActionStateEvent(node.Entity, Action.GetEntity(), node.Animator.GetEventPosition, node.Animator.GetEventRotation, state);

            if (Action.Fx != null)
            {
                Action.Fx.TriggerEvent(stateEvent);
            }
            for (int i = 0; i < ScriptedEvents.Count; i++)
            {
                if (ScriptedEvents[i].Event != state)
                {
                    continue;
                }
                PostAnimationEvent(stateEvent);
                break;
            }
        }
示例#2
0
        public void ProcessAnimationAction(AnimationEventTemplate aeTemplate, ActionTemplate action, string animEvent)
        {
            var character = aeTemplate.Entity.FindTemplate <CharacterTemplate>();
            var ae        = new ActionEvent(character, character, aeTemplate.AnimEvent.Position,
                                            aeTemplate.AnimEvent.Rotation, AnimationEvents.ToStateEvent(animEvent));

            if (ae.State == ActionState.Activate)
            {
                Debug.DrawLine(
                    aeTemplate.AnimEvent.Position, aeTemplate.AnimEvent.Rotation.GetPosition(aeTemplate.AnimEvent.Position, 2.5f),
                    Color.red, 5f);
            }
            var animationList = action.Config.GetEventHandler(animEvent);

            if (animationList != null)
            {
                for (int i = 0; i < animationList.Count; i++)
                {
                    animationList[i].Trigger(ae, animEvent);
                }
            }
            if (ae.State != ActionState.None)
            {
                aeTemplate.Entity.Post(ae);
                action.Entity.PostNoGlobal(ae);
            }
            if (ae.State == ActionState.Start)
            {
                for (int i = 0; i < action.Config.Costs.Count; i++)
                {
                    action.Config.Costs[i].ProcessCost(ae.Origin, action.Entity);
                }
            }
        }