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; }
private void CheckAmmoInventory(MyInventoryBase inventory, MyPhysicalInventoryItem item, MyFixedPoint amount) { var ammoMag = item.Content as MyObjectBuilder_AmmoMagazine; if (ammoMag != null) { var myInventory = inventory as MyInventory; if (myInventory == null) { return; } var magId = ammoMag.GetObjectId(); if (AmmoInventories.ContainsKey(magId)) { lock (AmmoInventories[magId]) { var hasIntentory = AmmoInventories[magId].ContainsKey(myInventory); if (!hasIntentory && amount > 0) { AmmoInventories[magId][myInventory] = amount; Session.FutureEvents.Schedule(CheckReload, magId, 1); } else if (hasIntentory && AmmoInventories[magId][myInventory] + amount > 0) { AmmoInventories[magId][myInventory] += amount; Session.FutureEvents.Schedule(CheckReload, magId, 1); } else if (hasIntentory) { MyFixedPoint pointRemoved; AmmoInventories[magId].TryRemove(myInventory, out pointRemoved); } } } } Session.AmmoMoveTriggered++; }
internal void FatBlockAdded(MyCubeBlock myCubeBlock) { try { var battery = myCubeBlock as MyBatteryBlock; if (battery != null) { if (Batteries.Add(battery)) { SourceCount++; } UpdatePowerSources = true; } else if (myCubeBlock is IMyCargoContainer || myCubeBlock is IMyAssembler || myCubeBlock is IMyShipConnector || myCubeBlock is MyCockpit) { MyInventory inventory; if (myCubeBlock.TryGetInventory(out inventory) && Inventories.Add(inventory)) { inventory.InventoryContentChanged += CheckAmmoInventory; foreach (var item in inventory.GetItems()) { var ammoMag = item.Content as MyObjectBuilder_AmmoMagazine; if (ammoMag != null && AmmoInventories.ContainsKey(ammoMag.GetObjectId())) { CheckAmmoInventory(inventory, item, item.Amount); } } } } else if (myCubeBlock is IMyUserControllableGun || myCubeBlock is MyConveyorSorter) { ScanBlockGroups = true; } } catch (Exception ex) { Log.Line($"Exception in Controller FatBlockAdded: {ex}"); } }