internal void CleanUp() { RegisterMyGridEvents(false); foreach (var grid in SubGrids) { if (grid == MyGrid) { continue; } RemSubGrids.Add(grid); } AddSubGrids.Clear(); SubGridChanges(); SubGrids.Clear(); Obstructions.Clear(); TargetAis.Clear(); EntitiesInRange.Clear(); Batteries.Clear(); Targets.Clear(); SortedTargets.Clear(); BlockGroups.Clear(); Weapons.Clear(); WeaponsIdx.Clear(); WeaponBase.Clear(); AmmoInventories.Clear(); Inventories.Clear(); LiveProjectile.Clear(); DeadProjectiles.Clear(); ControllingPlayers.Clear(); SourceCount = 0; BlockCount = 0; MyOwner = 0; PointDefense = false; FadeOut = false; SupressMouseShoot = false; OverPowered = false; UpdatePowerSources = false; AvailablePowerChanged = false; PowerIncrease = false; RequestedPowerChanged = false; RequestIncrease = false; DbReady = false; Focus.Clean(); MyShieldTmp = null; MyShield = null; MyPlanetTmp = null; MyPlanet = null; TerminalSystem = null; LastWeaponTerminal = null; LastTerminal = null; PowerDistributor = null; }
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++; }
public void UpdatePlayerContext(PlayerContext context) { World = context.World; Me = context.Wizards.Single(x => x.IsMe); CurrentBuildings = new Dictionary <long, Building>(); CurrentWizards = new Dictionary <long, Wizard>(); CurrentMinions = new Dictionary <long, Minion>(); CurrentProjectiles = new Dictionary <long, Projectile>(); foreach (var unit in context.World.Buildings) { DeadBuildings.Remove(unit.Id); AllBuildings[unit.Id] = unit; CurrentBuildings[unit.Id] = unit; } foreach (var unit in context.World.Wizards) { DeadWizards.Remove(unit.Id); AllWizards[unit.Id] = unit; CurrentWizards[unit.Id] = unit; } foreach (var unit in context.World.Minions) { DeadMinions.Remove(unit.Id); AllMinions[unit.Id] = unit; CurrentMinions[unit.Id] = unit; } foreach (var unit in context.World.Projectiles) { DeadProjectiles.Remove(unit.Id); AllProjectiles[unit.Id] = unit; CurrentProjectiles[unit.Id] = unit; } foreach (var diedUnit in AllBuildings.Except(CurrentBuildings).Where(x => x.Value.IsUnion(Me) || x.Value.Life <= 36)) { DeadBuildings[diedUnit.Key] = new DeadUnitInfo(context.World, diedUnit.Value, Me); } foreach (var diedUnit in AllWizards.Except(CurrentWizards).Where(x => x.Value.IsUnion(Me) || x.Value.Life <= 36)) { DeadWizards[diedUnit.Key] = new DeadUnitInfo(context.World, diedUnit.Value, Me); } foreach (var diedUnit in AllMinions.Except(CurrentMinions).Where(x => x.Value.IsUnion(Me) || x.Value.Life <= 36)) { DeadMinions[diedUnit.Key] = new DeadUnitInfo(context.World, diedUnit.Value, Me); } foreach (var diedUnit in AllProjectiles.Except(CurrentProjectiles)) { bool isTargetTree = context.World.Trees.Any(x => x.GetDistanceTo(diedUnit.Value) < 220); DeadProjectiles[diedUnit.Key] = new DeadUnitInfo(context.World, diedUnit.Value, Me, isTargetTree); } AllBuildings = CurrentBuildings; AllWizards = CurrentWizards; AllMinions = CurrentMinions; AllProjectiles = CurrentProjectiles; CurrentBuildingTargets = new Dictionary <long, List <LivingUnit> >(); foreach (var building in CurrentBuildings) { var buildingUnit = building.Value; var attackRange = buildingUnit.Type == BuildingType.GuardianTower ? Game.GuardianTowerAttackRange : Game.FactionBaseAttackRange; var maxDamage = buildingUnit.Type == BuildingType.GuardianTower ? Game.GuardianTowerDamage : Game.FactionBaseDamage; List <LivingUnit> p1Units = new List <LivingUnit>(); List <LivingUnit> p2Units = new List <LivingUnit>(); foreach (var minion in CurrentMinions) { FindBuildingTarget(minion.Value, buildingUnit, attackRange, maxDamage, p1Units, p2Units); } foreach (var wizard in CurrentWizards) { FindBuildingTarget(wizard.Value, buildingUnit, attackRange, maxDamage, p1Units, p2Units); } var buildingTargets = p1Units.Count > 0 ? p1Units : p2Units; CurrentBuildingTargets[building.Key] = buildingTargets; } DeadProjectiles = DeadProjectiles .Where(x => x.Value.ProjectileType == ProjectileType.MagicMissile && context.World.TickIndex < x.Value.TickIndex + 5 * 4) .ToDictionary(x => x.Key, y => y.Value); WorldUpdated?.Invoke(this, EventArgs.Empty); }