Beispiel #1
0
        public void Execute()
        {
            if (Entity == null || !Entity.InScene || Entity.MarkedForClose)
            {
                return;
            }
            var computedDamage = UtilsStatic.ComputeAmmoDamage(Entity);

            var damage = computedDamage * Shield.DsState.State.ModulateKinetic;

            if (computedDamage < 0)
            {
                damage = computedDamage;
            }

            var rayDir    = Vector3D.Normalize(Entity.Physics.LinearVelocity);
            var ray       = new RayD(Entity.PositionComp.WorldVolume.Center, rayDir);
            var intersect = CustomCollision.IntersectEllipsoid(ref Shield.DetectMatrixOutsideInv, Shield.DetectionMatrix, ref ray);
            var hitDist   = intersect ?? 0;
            var hitPos    = ray.Position + (ray.Direction * -hitDist);

            if (Session.Instance.MpActive)
            {
                Shield.AddShieldHit(Entity.EntityId, damage, Session.Instance.MPExplosion, null, true, hitPos);
                Entity.Close();
                Entity.InScene = false;
            }
            else
            {
                Shield.EnergyHit           = DefenseShields.HitType.Energy;
                Shield.WorldImpactPosition = hitPos;
                Shield.ImpactSize          = damage;
                UtilsStatic.CreateFakeSmallExplosion(hitPos);
                Entity.Close();
                Entity.InScene = false;
            }
            Shield.WebDamage     = true;
            Shield.Absorb       += damage;
            Shield.EnergyDamage += damage;

            Session.Instance.MissilePool.Return(this);
        }