Ejemplo n.º 1
0
        internal void NearByShield()
        {
            NearByFriendlyShields.Clear();
            for (int i = 0; i < NearByShieldsTmp.Count; i++)
            {
                var shield     = NearByShieldsTmp[i];
                var shieldGrid = MyEntities.GetEntityByIdOrDefault(shield.Id) as MyCubeGrid;

                if (shieldGrid != null)
                {
                    if (shield.Id == MyGrid.EntityId || MyGrid.IsSameConstructAs(shieldGrid))
                    {
                        MyShield = shield.ShieldEnt;
                    }
                    else
                    {
                        TargetInfo info;
                        var        found    = Targets.TryGetValue(shield.ShieldBlock.CubeGrid, out info);
                        var        relation = found ? info.EntInfo.Relationship : shield.ShieldBlock.IDModule.GetUserRelationToOwner(AiOwner);
                        var        friendly = relation == MyRelationsBetweenPlayerAndBlock.Owner || relation == MyRelationsBetweenPlayerAndBlock.FactionShare || relation == MyRelationsBetweenPlayerAndBlock.Friends;

                        if (friendly)
                        {
                            NearByFriendlyShields.Add(shield.ShieldEnt);
                            FriendlyShieldNear = true;
                        }
                        ShieldNear = true;
                    }
                }
            }
            NearByShieldsTmp.Clear();
        }
Ejemplo n.º 2
0
        internal void CleanUp()
        {
            AiCloseTick = Session.Tick;

            MyGrid.Components.Remove <AiComponent>();

            for (int i = 0; i < MIds.Length; i++)
            {
                MIds[i] = 0;
            }

            if (Session.IsClient)
            {
                Session.SendUpdateRequest(MyGrid.EntityId, PacketType.ClientAiRemove);
            }

            Data.Repo.ControllingPlayers.Clear();
            Data.Repo.ActiveTerminal = 0;

            CleanSortedTargets();
            Construct.Clean();
            Obstructions.Clear();
            ObstructionsTmp.Clear();
            TargetAis.Clear();
            TargetAisTmp.Clear();
            EntitiesInRange.Clear();
            Batteries.Clear();
            Targets.Clear();
            Weapons.Clear();
            WeaponsIdx.Clear();
            WeaponBase.Clear();
            LiveProjectile.Clear();
            DeadProjectiles.Clear();
            NearByShieldsTmp.Clear();
            NearByFriendlyShields.Clear();
            StaticsInRange.Clear();
            StaticsInRangeTmp.Clear();
            TestShields.Clear();
            NewEntities.Clear();
            SubGridsRegistered.Clear();
            SourceCount           = 0;
            BlockCount            = 0;
            AiOwner               = 0;
            ProjectileTicker      = 0;
            NearByEntities        = 0;
            NearByEntitiesTmp     = 0;
            MyProjectiles         = 0;
            AccelChecked          = false;
            PointDefense          = false;
            FadeOut               = false;
            SuppressMouseShoot    = false;
            OverPowered           = false;
            UpdatePowerSources    = false;
            AvailablePowerChanged = false;
            PowerIncrease         = false;
            RequestedPowerChanged = false;
            RequestIncrease       = false;
            DbReady               = false;
            GridInit              = false;
            TouchingWater         = false;
            Data.Clean();

            MyShield         = null;
            MyPlanetTmp      = null;
            MyPlanet         = null;
            TerminalSystem   = null;
            LastTerminal     = null;
            PowerDistributor = null;
            PowerBlock       = null;
            MyGrid           = null;
            PowerDistributor = null;
            Session          = null;
            Closed           = true;
            CanShoot         = true;
            Version++;
        }