public void RefreshEarnedLoot() { this.ResetEarnedLoot(); Dictionary <string, int> buildingDamageMap = Service.BattleController.GetBuildingDamageMap(); NodeList <LootNode> nodeList = Service.EntityController.GetNodeList <LootNode>(); for (LootNode lootNode = nodeList.Head; lootNode != null; lootNode = lootNode.Next) { int damagePercent = 0; if (buildingDamageMap.ContainsKey(lootNode.BuildingComp.BuildingTO.Key)) { damagePercent = buildingDamageMap[lootNode.BuildingComp.BuildingTO.Key]; } this.EarnCalculatedLoot(lootNode.LootComp, damagePercent); } foreach (KeyValuePair <string, LootComponent> current in this.deadLootedEntities) { this.EarnLootFromDeath(current.Value); } Service.EventManager.SendEvent(EventId.LootEarnedUpdated, null); }
public void PlaceEffects() { this.Cleanup(); EntityController entityController = Service.Get <EntityController>(); NodeList <LootNode> nodeList = entityController.GetNodeList <LootNode>(); LootNode lootNode = nodeList.Head; while (lootNode != null) { BuildingTypeVO buildingType = lootNode.BuildingComp.BuildingType; if (this.currentSetupType == "setupTypeCollection") { if (buildingType.Type == BuildingType.Resource) { goto IL_69; } } else if (!(this.currentSetupType == "setupTypeLooting") || buildingType.IsLootable) { goto IL_69; } IL_F4: lootNode = lootNode.Next; continue; IL_69: Bounds gameObjectBounds = UnityUtils.GetGameObjectBounds(lootNode.View.MainGameObject); Vector3 position = lootNode.View.MainTransform.position; position.y = gameObjectBounds.center.y; CurrencyType currency = buildingType.Currency; if (buildingType.Type == BuildingType.HQ || currency == CurrencyType.None) { this.CreateEffect(lootNode.Entity, CurrencyType.Credits, position); this.CreateEffect(lootNode.Entity, CurrencyType.Materials, position); this.CreateEffect(lootNode.Entity, CurrencyType.Contraband, position); goto IL_F4; } this.CreateEffect(lootNode.Entity, currency, position); goto IL_F4; } }
private void DistributLootWithHQWeighted(CurrencyType type, Dictionary <string, int> buildingOverride, int totalAmount, int hqFixedAmount) { NodeList <LootNode> nodeList = Service.EntityController.GetNodeList <LootNode>(); List <LootNode> list = new List <LootNode>(); int num = 0; int num2 = 0; for (LootNode lootNode = nodeList.Head; lootNode != null; lootNode = lootNode.Next) { if (lootNode.BuildingComp.BuildingType.Currency == type || lootNode.BuildingComp.BuildingType.Currency == CurrencyType.None) { if (buildingOverride != null && buildingOverride.ContainsKey(lootNode.BuildingComp.BuildingTO.Key)) { int num3 = buildingOverride[lootNode.BuildingComp.BuildingTO.Key]; lootNode.LootComp.SetLootQuantity(type, num3); this.totalLootAvailable[(int)type] += lootNode.LootComp.LootQuantities[(int)type]; BuildingTypeVO buildingType = lootNode.BuildingComp.BuildingType; if (buildingType.Type == BuildingType.Resource || buildingType.Type == BuildingType.Storage) { Service.StorageEffects.UpdateFillStateFX(lootNode.Entity, buildingType, (float)num3 / (float)buildingType.Storage, 0f); } } else { list.Add(lootNode); num++; if (lootNode.BuildingComp.BuildingType.Type == BuildingType.HQ) { num2++; } } } } if (num2 * hqFixedAmount > totalAmount) { num2 = totalAmount / hqFixedAmount; } int num4 = num - num2; int num5 = 0; int num6 = 0; if (num4 > 0) { num5 = (totalAmount - hqFixedAmount * num2) % num4; num6 = (totalAmount - hqFixedAmount * num2) / num4; } int num7 = 0; for (int i = 0; i < list.Count; i++) { LootNode lootNode2 = list[i]; if (lootNode2.BuildingComp.BuildingType.Type == BuildingType.HQ && num7 < num2) { lootNode2.LootComp.SetLootQuantity(type, hqFixedAmount + num5); num5 = 0; num7++; } else { int num8 = num6; if (num2 == 0) { num8 += num5; num5 = 0; } lootNode2.LootComp.SetLootQuantity(type, num8); } this.totalLootAvailable[(int)type] += lootNode2.LootComp.LootQuantities[(int)type]; } }