public static void AddTroopToStarportReserve(SmartEntity starport, TroopTypeVO troop) { if (starport != null) { int num = StorageSpreadUtils.GetStarportFillSize(starport); num += troop.Size; StorageSpreadUtils.SetStarportFillSize(starport, num); } }
public static void UpdateAllStarportFullnessMeters() { GamePlayer worldOwner = GameUtils.GetWorldOwner(); Dictionary <string, InventoryEntry> internalStorage = worldOwner.Inventory.Troop.GetInternalStorage(); StaticDataController staticDataController = Service.StaticDataController; List <TroopTypeVO> list = new List <TroopTypeVO>(); foreach (string current in internalStorage.Keys) { list.Add(staticDataController.Get <TroopTypeVO>(current)); } List <StarportNode> list2 = new List <StarportNode>(); NodeList <StarportNode> starportNodeList = Service.BuildingLookupController.StarportNodeList; for (StarportNode starportNode = starportNodeList.Head; starportNode != null; starportNode = starportNode.Next) { if (!ContractUtils.IsBuildingConstructing((SmartEntity)starportNode.BuildingComp.Entity)) { list2.Add(starportNode); } } List <TroopTypeVO> arg_DE_0 = list; if (StorageSpreadUtils.< > f__mg$cache1 == null) { StorageSpreadUtils.< > f__mg$cache1 = new Comparison <TroopTypeVO>(StorageSpreadUtils.CompareTroop); } arg_DE_0.Sort(StorageSpreadUtils.< > f__mg$cache1); int count = list.Count; int[] array = new int[count]; for (int i = 0; i < count; i++) { array[i] = internalStorage[list[i].Uid].Amount; } List <StarportNode> arg_147_0 = list2; if (StorageSpreadUtils.< > f__mg$cache2 == null) { StorageSpreadUtils.< > f__mg$cache2 = new Comparison <StarportNode>(StorageSpreadUtils.CompareStarportNode); } arg_147_0.Sort(StorageSpreadUtils.< > f__mg$cache2); int num = 0; int count2 = list2.Count; Int32PriorityList int32PriorityList = new Int32PriorityList(); int[] array2 = new int[count2]; for (int j = 0; j < count2; j++) { int storage = list2[j].BuildingComp.BuildingType.Storage; array2[j] = storage; num += storage; int priority = -j; int32PriorityList.Add(j, priority); } int num2 = 0; while (num2 < count && num > 0) { int size = list[num2].Size; int num3 = array[num2]; while (num3 > 0 && num > 0) { bool flag = false; for (int k = 0; k < count2; k++) { int element = int32PriorityList.GetElement(k); int num4 = array2[element]; if (size <= num4) { array2[element] -= size; num -= size; int num5 = int32PriorityList.GetPriority(k); int32PriorityList.RemoveAt(k); num5 -= size * count2; int32PriorityList.Add(element, num5); flag = true; break; } } if (!flag) { int num6 = size; int num7 = 0; while (num7 < count2 && num6 > 0) { int num8 = array2[num7]; if (num8 > 0) { int num9 = (num6 >= num8) ? num8 : num6; array2[num7] -= num9; num -= num9; num6 -= num9; } num7++; } } num3--; } num2++; } for (int l = 0; l < count2; l++) { BuildingComponent buildingComp = list2[l].BuildingComp; int storage2 = buildingComp.BuildingType.Storage; int num10 = storage2 - array2[l]; SmartEntity starport = (SmartEntity)buildingComp.Entity; StorageSpreadUtils.SetStarportFullnessPercent(starport, (float)num10 / (float)storage2); StorageSpreadUtils.SetStarportFillSize(starport, num10); } }
public unsafe static long $Invoke10(long instance, long *args) { StorageSpreadUtils.SetStarportFillSize((Entity)GCHandledObjects.GCHandleToObject(*args), *(int *)(args + 1)); return(-1L); }