public override void Unload()
 {
     if (m_centerSphere != null)
     {
         m_centerSphere.Close();
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public static void ApplyOperation(MyEntity entity, MyTrashRemovalOperation operation)
 {
     if ((operation & MyTrashRemovalOperation.Remove) == MyTrashRemovalOperation.Remove)
     {
         entity.Close();
         return;
     }
     if ((operation & MyTrashRemovalOperation.Stop) == MyTrashRemovalOperation.Stop && entity.Physics != null)
     {
         entity.Physics.LinearVelocity = Vector3.Zero;
         entity.Physics.AngularVelocity = Vector3.Zero;
     }
     if ((operation & MyTrashRemovalOperation.Depower) == MyTrashRemovalOperation.Depower)
     {
         var grid = entity as MyCubeGrid;
         if (grid != null)
         {
             grid.ChangePowerProducerState(MyMultipleEnabledEnum.AllDisabled, 0);
         }
     }
 }
        private static void RemoveEdge(long removerEntityId, long entityIdToRemove)
        {
            MyEntity holderEntity;

            MyEntities.TryGetEntityById(removerEntityId, out holderEntity);
            var holderPlayer = holderEntity != null
                ? MyAPIGateway.Players.GetPlayerControllingEntity(holderEntity)
                : null;

            MyEntity removeEntity = null;

            MyEntities.TryGetEntityById(entityIdToRemove, out removeEntity);

            if (removeEntity == null)
            {
                MyEventContext.ValidationFailed();
                return;
            }

            #region Validation

            if (!MyEventContext.Current.IsLocallyInvoked)
            {
                if (holderEntity == null || holderPlayer == null ||
                    MyEventContext.Current.Sender.Value != holderPlayer.SteamUserId)
                {
                    MyEventContext.ValidationFailed();
                    return;
                }

                if (MyAreaPermissionSystem.Static != null && !MyAreaPermissionSystem.Static.HasPermission(
                        holderPlayer.IdentityId, removeEntity.GetPosition(), MyPermissionsConstants.QuickDeconstruct))
                {
                    holderPlayer.ShowNotification("You cannot quick deconstruct here", 2000, null,
                                                  new Vector4(1, 0, 0, 1));
                    return;
                }

                string err;
                if (!ValidateQuickRemove(holderPlayer, removeEntity, out err))
                {
                    MyEventContext.ValidationFailed();
                    if (!string.IsNullOrEmpty(err))
                    {
                        holderPlayer.ShowNotification(err, 2000, null, new Vector4(1, 0, 0, 1));
                    }
                    return;
                }
            }

            #endregion

            var block = removeEntity?.Get <MyBlockComponent>();
            if (block != null)
            {
                block.GridData.RemoveBlock(block.Block);
            }
            else
            {
                removeEntity.Close();
            }

            EntityRemoved?.Invoke(holderEntity, holderPlayer, removeEntity);
        }
Exemplo n.º 5
0
 internal void CloseChildEntity(MyEntity child)
 {
     RemoveChildEntity(child);
     child.Close();
 }
Exemplo n.º 6
0
 public override void Unload()
 {
     m_centerSphere.Close();
 }
Exemplo n.º 7
0
 public override void Unload()
 {
     StopParticles();
     m_hammer.Close();
 }
        private void ConsumeEntity(MyEntity ent)
        {
            if (!MySession.Static.IsServer)
            {
                return;
            }
            if (ent.Closed || ent.MarkedForClose)
            {
                return;
            }
            var item = (ent as MyFloatingObject)?.Item ?? ent.Components.Get <MyInventoryItemComponent>()?.Item;

            var itemId = item?.DefinitionId;
            var amount = item?.Amount ?? 1;

            if (item == null)
            {
                var grid = ent.Components.Get <MyGridDataComponent>();
                if (grid == null)
                {
                    return;
                }
                if (grid.BlockCount != 1 || ent.Physics == null)
                {
                    return;
                }
                var block = grid.Blocks.FirstOrDefault();
                if (block == null)
                {
                    return;
                }
                itemId = block.DefinitionId;
            }

            foreach (var k in _inventories.Components)
            {
                // Check constraint
                if (!k.CanAddItems(itemId.Value, 1))
                {
                    return;
                }

                var count = Math.Min(amount, k.ComputeAmountThatFits(itemId.Value));
                if (count == 0)
                {
                    continue;
                }

                if (!k.AddItems(itemId.Value, count))
                {
                    continue;
                }

                amount -= count;
                if (amount > 0)
                {
                    continue;
                }
                ent.Close();
                return;
            }
        }