Esempio n. 1
0
 public override void Start(ActionUsingNode node)
 {
     base.Start(node);
     node.LastProcessedAnimationEvent = "";
     node.CurrentState = ActionUsingNode.State.Starting;
     node.Animator.PlayAnimation(Animation, true, node.ActionEvent.Action);
 }
Esempio n. 2
0
        public void Trigger(ActionUsingNode node, string eventName)
        {
            var     entity = node.Entity;
            Vector3 originPos;

            if (entity.Tags.Contain(EntityTags.Player))
            {
                originPos = PlayerInputSystem.GetLookTargetRay.origin;
            }
            else
            {
                var animData = entity.Find <AnimatorComponent>();
                originPos = animData?.Value?.GetEventPosition ?? (node.Tr != null ? node.Tr.position : Vector3.zero);
            }
            var            target       = node.ActionEvent.Target;
            var            actionEntity = node.ActionEvent.Action.GetEntity();
            var            ray          = new Ray(originPos, (target - originPos).normalized);
            CollisionEvent?ce           = CollisionCheckSystem.Raycast(actionEntity, ray, RayDistance, LimitToEnemy);

            if (ce == null && RaySize > 0.01f)
            {
                ce = CollisionCheckSystem.SphereCast(actionEntity, ray, RayDistance, RaySize, LimitToEnemy);
            }
            if (ce != null)
            {
                var stateEvent = new ActionStateEvent(node.Entity, ce.Value.Target.Entity, ce.Value.HitPoint, Quaternion.LookRotation(ce.Value.HitNormal), StateEvent);
                node.Entity.Post(stateEvent);
            }
        }
        public void Trigger(ActionUsingNode node, string eventName)
        {
            var    entity    = node.Entity;
            var    cmdTarget = entity.Get <CommandTarget>();
            Entity target;

            if (cmdTarget != null && cmdTarget.Target != null)
            {
                target = cmdTarget.Target;
            }
            else
            {
                target = node.Entity;
            }
            if (target == null)
            {
                return;
            }
            var sourceNode = entity.FindNode <CollidableNode>();
            var targetNode = target.FindNode <CollidableNode>();

            if (sourceNode == null || targetNode == null)
            {
                return;
            }
            CollisionExtensions.GenerateHitLocDir(sourceNode.Tr, targetNode.Tr, targetNode.Collider, out var hitPoint, out var dir);
            var ce = new CollisionEvent(entity, sourceNode, targetNode, hitPoint, dir);

            target.Post(ce);
            entity.Post(new PerformedCollisionEvent(sourceNode, targetNode, ce.HitPoint, ce.HitNormal));
            var stateEvent = new ActionStateEvent(node.Entity, ce.Target.Entity, ce.HitPoint, Quaternion.LookRotation(ce.HitNormal), StateEvent);

            node.Entity.Post(stateEvent);
        }
Esempio n. 4
0
        public override void Start(ActionUsingNode node)
        {
            base.Start(node);
            var model = ItemPool.Spawn(UnityDirs.Models, ModelData, Vector3.zero, Quaternion.identity);

            if (model != null)
            {
                node.ParentSpawn(model.Transform);
                node.ActionEvent.Action.Entity.Add(new RenderingComponent(model.GetComponent <IRenderingComponent>()));
                node.ActionEvent.Action.Entity.Add(new TransformComponent(model.transform));
            }
            var dmgComponent = node.Entity.GetOrAdd <BlockDamage>();

            if (!node.Entity.Tags.Contain(EntityTags.Player))
            {
                dmgComponent.DamageBlockers.Add(BlockDamageFlat);
                _isWaiting = true;
                _vitalStat = null;
                return;
            }
            _vitalStat = node.Stats.GetVital(TargetVital);
            var skillMulti = 1f;

            if (!string.IsNullOrEmpty(_skill))
            {
                var skillValue = node.Entity.FindStatValue(_skill);
                skillMulti = Mathf.Clamp(1 - (skillValue * CostVital.SkillPercent), CostVital.SkillMaxReduction, 1);
            }
            dmgComponent.CollisionHandlers.Add(EvadeDamageWithStats);
            _fxComponent = node.ActionEvent.Action.Fx;
            _finalCost   = Cost * skillMulti;
        }
Esempio n. 5
0
        public void Trigger(ActionUsingNode node, string eventName)
        {
            var    target = node.ActionEvent.Target;
            Entity spawnEntity;

            if (node.ActionEvent.SpawnPivot != null)
            {
                spawnEntity = World.Get <ProjectileSystem>().SpawnProjectile(node.ActionEvent.Action.Entity, Data, target,
                                                                             node.ActionEvent.SpawnPivot.position, node.ActionEvent.SpawnPivot.rotation);
            }
            else
            {
                var animData = node.Animator;
                var spawnPos = animData?.GetEventPosition ?? (node.Tr != null ? node.Tr.position : Vector3.zero);
                var spawnRot = animData?.GetEventRotation ?? (node.Tr != null ? node.Tr.rotation : Quaternion.identity);
                DebugExtension.DebugPoint(spawnPos, Color.blue, 1f, 1f);
                spawnEntity = World.Get <ProjectileSystem>().SpawnProjectile(node.ActionEvent.Action.Entity, Data, node.ActionEvent.Target,
                                                                             spawnPos, spawnRot);
            }
            if (spawnEntity != null)
            {
                if (node.ActionEvent.Action.Fx != null)
                {
                    var afx = spawnEntity.Get <ActionFxComponent>();
                    if (afx != null)
                    {
                        afx.ChangeFx(node.ActionEvent.Action.Fx);
                    }
                    else
                    {
                        spawnEntity.Add(new ActionFxComponent(node.ActionEvent.Action.Fx));
                    }
                }
            }
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
        public override void End(ActionUsingNode node)
        {
            base.End(node);
            _vitalStat = null;
            var tr = node.ActionEvent.Action.Entity.Get <TransformComponent>();

            if (tr != null)
            {
                ItemPool.Despawn(tr.gameObject);
                node.ActionEvent.Action.Entity.Remove(tr);
                node.ActionEvent.Action.Entity.Remove <RenderingComponent>();
            }
            var blockDamage = node.Entity.Get <BlockDamage>();

            if (blockDamage != null)
            {
                if (_isWaiting)
                {
                    blockDamage.DamageBlockers.Remove(BlockDamageFlat);
                }
                else
                {
                    blockDamage.CollisionHandlers.Remove(EvadeDamageWithStats);
                }
            }
        }
Esempio n. 8
0
 private void Complete(ActionUsingNode node)
 {
     for (int i = 0; i < node.ActionEvent.Action.Costs.Count; i++)
     {
         node.ActionEvent.Action.Costs[i].ProcessCost(node.Entity);
     }
     StopEvent(node);
 }
 public override void Evaluate(ActionUsingNode node)
 {
     if (!_currentSpawn.Tags.Contain(EntityTags.Moving))
     {
         node.AdvanceEvent();
         _currentSpawn.Destroy(); // this doesn't respect pooling
         _currentSpawn = null;
     }
 }
Esempio n. 10
0
        public void Trigger(ActionUsingNode node, string eventName)
        {
            var model = ItemPool.Spawn(UnityDirs.Models, Data, Vector3.zero, Quaternion.identity);

            if (model != null)
            {
                node.ParentSpawn(model.Transform);
                node.ActionEvent.Action.Entity.Add(new RenderingComponent(model.GetComponent <IRenderingComponent>()));
            }
        }
Esempio n. 11
0
        public override void Evaluate(ActionUsingNode node)
        {
            var elapsed = (TimeManager.Time - _start);

            if (elapsed >= MaxChargeTime || (_input != null && !_input.Handler.GetButton(ChargeInput)))
            {
                var chargeComponent = node.ActionEvent.Action.Entity.GetOrAdd <ChargeComponent>();
                chargeComponent.CurrentCharge = ForceRange.Lerp(Mathf.Clamp01(elapsed / MaxChargeTime));
                node.AdvanceEvent();
            }
        }
Esempio n. 12
0
 private void UpdateNode(ref ActionUsingNode node)
 {
     if (node.CurrentState != ActionUsingNode.State.Disabled && node.Entity.IsDead())
     {
         StopEvent(node);
         return;
     }
     if (node.CurrentState != ActionUsingNode.State.Disabled && node.ActionEvent.Current != null)
     {
         node.ActionEvent.Current.Evaluate(node);
     }
 }
Esempio n. 13
0
 public void AdvanceEvent(ActionUsingNode node)
 {
     node.ActionEvent.Current.End(node);
     if (node.ActionEvent.IsLastIndex)
     {
         Complete(node);
         return;
     }
     node.ActionEvent = new ActionEvent(node.ActionEvent);
     //if (node.ActionEvent.Current.IsMainLayer) {
     //    node.Entity.Post(new ActionStateEvent(node.Entity, node.ActionEvent.ActionEntity, node.ActionEvent.SpawnPivot.position, node.ActionEvent.SpawnPivot.rotation, ActionStateEvents.Activate));
     //}
     node.ActionEvent.Current.Start(node);
 }
Esempio n. 14
0
 public override void Evaluate(ActionUsingNode node)
 {
     if (_isWaiting)
     {
         if (TimeManager.Time >= node.ActionEvent.TimeStart + WaitTime)
         {
             node.AdvanceEvent();
         }
         return;
     }
     if (!PlayerInputSystem.GetButton(ChargeInput) || _vitalStat.Current < Cost)
     {
         node.AdvanceEvent();
     }
 }
Esempio n. 15
0
        public override void Start(ActionUsingNode node)
        {
            base.Start(node);
            var entity      = node.Entity;
            var spawnEntity = World.Get <ProjectileSystem>().SpawnProjectile(entity, Data, node.ActionEvent);

            if (spawnEntity != null)
            {
                Vector3 target = node.ActionEvent.Target;
                spawnEntity.ParentId = entity.Id;
                spawnEntity.Add(new SimplerMover());
                //spawnEntity.AddObserver(this);
                spawnEntity.Post(new StartMoveEvent(spawnEntity, target, null));
            }
        }
Esempio n. 16
0
        public override void Evaluate(ActionUsingNode node)
        {
            switch (node.CurrentState)
            {
            case ActionUsingNode.State.Disabled:
                return;

            case ActionUsingNode.State.Starting:
                if (node.Animator.CurrentAnimation == Animation)
                {
                    node.CurrentState = ActionUsingNode.State.Running;
                }
                else
                {
                    return;
                }
                break;

            case ActionUsingNode.State.Running:
                if (node.Animator.CurrentAnimation != Animation)
                {
                    World.Get <ActionSystem>().AdvanceEvent(node);
                    return;
                }
                break;
            }
            if (!string.IsNullOrEmpty(node.Animator.CurrentAnimationEvent) && node.LastProcessedAnimationEvent != node.Animator.CurrentAnimationEvent)
            {
                node.LastProcessedAnimationEvent = node.Animator.CurrentAnimationEvent;
                if (!string.IsNullOrEmpty(node.LastProcessedAnimationEvent))
                {
                    node.ActionEvent.Current.PostAnimationEvent(node, node.LastProcessedAnimationEvent);
                }
            }
            if (node.Animator.CurrentAnimationRemaining <= 0)
            {
                node.AdvanceEvent();
            }
        }
Esempio n. 17
0
 public virtual void End(ActionUsingNode node)
 {
 }
Esempio n. 18
0
 public abstract void Evaluate(ActionUsingNode node);
Esempio n. 19
0
 public virtual void Start(ActionUsingNode node)
 {
 }
Esempio n. 20
0
 public override void Start(ActionUsingNode node)
 {
     base.Start(node);
     _start = TimeManager.Time;
     _input = node.Entity.Get <PlayerInputComponent>();
 }
Esempio n. 21
0
 public void Trigger(ActionUsingNode node, string eventName)
 {
     node.Entity.Post(new ChangePositionEvent(node.Entity, FindPosition(node.Tr.position, node.Tr.forward, Distance)));
     //Player.Controller.Teleport(FindPosition(msg.Owner.Tr.position, msg.Owner.Tr.forward, current.Distance));
 }
Esempio n. 22
0
 public ActionSystem()
 {
     NodeFilter <ActionUsingNode> .Setup(ActionUsingNode.GetTypes());
 }
Esempio n. 23
0
 public void StopEvent(ActionUsingNode node)
 {
     node.Entity.Tags.Remove(EntityTags.PerformingCommand);
     node.Stop();
 }
Esempio n. 24
0
 public void Trigger(ActionUsingNode node, string eventName)
 {
     FirstPersonCamera.AddForce(Shake, false);
 }