public static LSEffect CreateEffect(string effectCode, Transform spawnParent)
        {
            if (!IsValid(effectCode))
            {
                return(null);
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.parent = spawnParent;
            Fire(effect);
            return(effect);
        }
 public static void EndEffect(LSEffect effect)
 {
     if (EffectActive [effect.ID] == false)
     {
         return;
     }
     effect.Deactivate();
     EffectPool [effect.MyEffectCode].Add(effect);
     EffectActive [effect.ID] = false;
     Effects [effect.ID]      = null;
     OpenSlots.Add(effect.ID);
 }
        public static LSEffect CreateEffect(string effectCode, Vector3 position)
        {
            if (!IsValid(effectCode))
            {
                return(null);
            }
            LSEffect effect = CreateEffect(effectCode);

            effect.CachedTransform.position = position;
            Fire(effect);
            return(effect);
        }
        public static LSEffect CreateEffect(string effectCode)
        {
            if (!IsValid(effectCode))
            {
                return(null);
            }

            LSEffect effect = GenEffect(effectCode, -1);

            EffectActive [effect.ID] = true;
            Effects [effect.ID]      = effect;
            return(effect);
        }
 void HitAgent(RTSAgent agent)
 {
     if (this.UseEffects && this.AttachEndEffectToTarget)
     {
         LSEffect lSEffect = EffectManager.CreateEffect(this.HitFX);
         lSEffect.CachedTransform.parent        = agent.VisualCenter;
         lSEffect.CachedTransform.localPosition = Vector3.up;
         lSEffect.CachedTransform.rotation      = this.cachedTransform.rotation;
         lSEffect.Initialize();
     }
     this.HitEffect(agent);
     if (onHitAgent != null)
     {
         onHitAgent(agent);
     }
 }
 private void Hit(bool destroy = true)
 {
     this.OnHit();
     if (this.onHit.IsNotNull())
     {
         this.onHit();
     }
     if (this.TargetCurrent)
     {
         if (this.UseEffects)
         {
             if (this.AttachEndEffectToTarget)
             {
                 LSEffect lSEffect = EffectManager.CreateEffect(this.HitFX);
                 lSEffect.CachedTransform.parent        = this.Target.VisualCenter;
                 lSEffect.CachedTransform.localPosition = Vector3.up;
                 lSEffect.CachedTransform.rotation      = this.cachedTransform.rotation;
                 lSEffect.Initialize();
             }
             else
             {
                 //Certain targeting types collide with a target
                 if (this.TargetingBehavior == TargetingType.Homing)
                 {
                     EffectManager.CreateCollisionEffect(this.HitFX, this, Target.Body);
                 }
                 else
                 {
                     EffectManager.CreateEffect(this.HitFX, this.cachedTransform.position, this.cachedTransform.rotation);
                 }
             }
         }
     }
     if (destroy)
     {
         ProjectileManager.EndProjectile(this);
     }
 }
 public static void Fire(LSEffect effect)
 {
     effect.Initialize();
 }
        public void LateInit()
        {
            if (this.TargetingBehavior != TargetingType.Timed)
            {
                this.cachedTransform.position = this.Position.ToVector3();
                this.speedPerFrame            = this.Speed / 32L;
            }

            switch (this.TargetingBehavior)
            {
            case TargetingType.Timed:
                this.CountDown = this.Delay;

                break;

            case TargetingType.Positional:
            case TargetingType.Homing:
                long f         = this.Position.ToVector2d().Distance(this.TargetPosition);
                long timeToHit = f.Div(this.Speed);
                if (this._visualArc)
                {
                    this.arcStartHeight = this.Position.z;
                    if (timeToHit > 0)
                    {
                        this.arcStartVerticalSpeed = (this.TargetHeight - this.Position.z).Div(timeToHit) + timeToHit.Mul(Gravity);
                    }
                }
                else
                {
                    if (timeToHit > 0)
                    {
                        this.linearHeightSpeed = (this.TargetHeight - Position.z).Div(timeToHit).Abs() / LockstepManager.FrameRate;
                    }
                }
                Forward = TargetPosition - this.Position.ToVector2d();
                Forward.Normalize();
                break;

            case TargetingType.Directional:

                Vector3d vel = this.Direction;
                vel.Mul(speedPerFrame);
                this.Velocity = vel;


                break;
            }
            if (this.CanRotate)
            {
                this.cachedTransform.LookAt(this.Direction.ToVector3());
            }
            this.UpdateVisuals();

            if (this.onInitialize.IsNotNull())
            {
                this.onInitialize.Invoke();
            }

            if (UseEffects)
            {
                LSEffect effect = EffectManager.CreateEffect(this.StartFX, this.Position.ToVector3(), this.cachedTransform.rotation);
                if (effect != null)
                {
                    effect.StartPos = this.Position.ToVector3();
                    effect.EndPos   = this.TargetPosition.ToVector3(this.TargetHeight.ToFloat());
                    if (this.Target != null)
                    {
                        effect.Target = Target.transform;
                    }
                }
            }
        }