public void OnActionSpawn(ActionEvent state)
        {
            var focus = state.Target;

            if (focus == null)
            {
                return;
            }
            var rect = World.Get <CharacterRectSystem>().GetEntityRect(focus.Entity);

            //if (focus == null || !focus.HasComponent<PlayerComponent>()) {
            //    return;
            //}
            if (rect == null)
            {
                return;
            }
            if (_matSource == null)
            {
                _matSource = GetComponent <Renderer>();
            }
            ItemPool.Spawn(
                LazyDb.Main.ParticleUIHolder,
                entity => {
                var altParticle = entity.GetComponent <UIAnimation>();
                if (altParticle == null)
                {
                    Debug.LogErrorFormat(
                        "{0} tried to convert to UI animation for {1} targeting {2} at state {3} spawn {4}",
                        name,
                        state.State,
                        focus.Get <LabelComponent>(),
                        state,
                        entity.name);
                    ItemPool.Despawn(entity);
                    return;
                }
                altParticle.transform.SetParent(rect.RectTr);
                altParticle.Play(_animationUi, _matSource != null ? _matSource.sharedMaterial : null);
                ItemPool.Despawn(gameObject);
            });
        }
Esempio n. 2
0
 public void Trigger(ActionEvent ae, string eventName)
 {
     ItemPool.Spawn(Data,
                    model => {
         if (model != null)
         {
             var spawn = ae.Origin.Entity.Get <SpawnPivotComponent>();
             if (spawn != null)
             {
                 spawn.SetNewChild(model.Transform);
             }
             else
             {
                 ae.Origin.Tr.SetParent(model.Transform);
                 model.Transform.ResetPos();
             }
             ae.Action.Entity.Add(new RenderingComponent(model.GetComponent <IRenderingComponent>()));
         }
     });
 }
Esempio n. 3
0
        public static bool GetSpawnPositionRotation(this ActionEvent ae, out Vector3 pos, out Quaternion rot)
        {
            if (ae.Action != null)
            {
                var actionEntity = ae.Action.Entity;
                var spawnPivot   = actionEntity.Get <SpawnPivotComponent>();
                if (spawnPivot != null)
                {
                    pos = spawnPivot.position;
                    rot = spawnPivot.rotation;
                    return(true);
                }
                var actionTr = actionEntity.Get <TransformComponent>();
                if (actionTr != null)
                {
                    pos = actionTr.position;
                    rot = actionTr.rotation;
                    return(true);
                }
                var actionPivots = ae.Origin.Entity.Get <ActionPivotsComponent>();
                if (actionPivots != null)
                {
                    pos = (ae.Action.Config.Primary ? actionPivots.PrimaryPivot : actionPivots.SecondaryPivot).position;
                    rot = (ae.Action.Config.Primary ? actionPivots.PrimaryPivot : actionPivots.SecondaryPivot).rotation;
                    return(true);
                }
            }
            var transformComponent = ae.Origin.Tr;

            if (transformComponent != null)
            {
                pos = transformComponent.position;
                rot = transformComponent.rotation;
                return(true);
            }
            pos = ae.Position;
            rot = ae.Rotation;
            return(false);
        }
        public void Trigger(ActionEvent ae, string eventName)
        {
            var     origin = ae.Origin;
            Vector3 originPos;
            Vector3 target;

            if (origin.Tags.Contain(EntityTags.Player))
            {
                originPos = PlayerInputSystem.GetLookTargetRay.origin;
                target    = PlayerInputSystem.GetMouseRaycastPosition(ae.Action.Config.Range);
            }
            else
            {
                originPos = ae.Position;
                target    = ae.Origin.Target.GetPosition;
            }
            var actionEntity = ae.Action.Entity;
            var ray          = new Ray(originPos, (target - originPos).normalized);

            if (CollisionCheckSystem.Raycast(actionEntity, ray, RayDistance, LimitToEnemy) == null && RaySize > 0.01f)
            {
                CollisionCheckSystem.SphereCast(actionEntity, ray, RayDistance, RaySize, LimitToEnemy);
            }
        }
Esempio n. 5
0
        public void Trigger(ActionEvent ae, string eventName)
        {
            var spawnPos    = ae.Origin.AnimationEvent.Position;
            var spawnRot    = ae.Origin.AnimationEvent.Rotation;
            var spawnEntity = World.Get <ProjectileSystem>().SpawnProjectile(
                ae.Action.Entity, Data, ae.Position,
                spawnPos, spawnRot);

            if (spawnEntity != null)
            {
                if (ae.Action.Fx != null)
                {
                    var afx = spawnEntity.Get <ActionFxComponent>();
                    if (afx != null)
                    {
                        afx.ChangeFx(ae.Action.Fx.Value);
                    }
                    else
                    {
                        spawnEntity.Add(new ActionFxComponent(ae.Action.Fx.Value));
                    }
                }
            }
        }
Esempio n. 6
0
 public void Trigger(ActionEvent ae, string eventName)
 {
     _timer.Restart();
 }
Esempio n. 7
0
 public void TriggerEvent(ActionEvent actionEvent)
 {
     TriggerEvent(actionEvent.State, actionEvent.Position, actionEvent.Rotation, actionEvent.Target != null ? actionEvent.Target :
                  actionEvent.Origin);
 }
 public void Trigger(ActionEvent ae, string eventName)
 {
     World.Get <EntityEventSystem>().Post(new CameraPositionForceEvent(Shake));
 }
Esempio n. 9
0
 public void OnUsage(ActionEvent ae, ActionCommand cmd)
 {
     WeaponAttack.OnUsage(ae, cmd, Stats.WeaponAttackDamage);
 }