private object OnLootSpawn(LootContainer container) { if (INIT) { if (container?.inventory?.itemList == null) { return(null); } while (container.inventory.itemList.Count > 0) { var item = container.inventory.itemList[0]; item.RemoveFromContainer(); item.Remove(0f); } container.PopulateLoot(); foreach (Item i in container.inventory.itemList) { if (i.IsBlueprint()) { i.amount = 0; } else if (!i.hasCondition) { i.amount *= ScrapRate; } } return(container); } return(null); }
void RepopulateContainer(LootContainer container) { if (container != null) { ClearContainer(container); container.PopulateLoot(); ModifyContainerContents(container); } }
void RepopulateContainer(LootContainer container) { if (container != null) { ClearContainer(container); container.PopulateLoot(); // looks like this loads the vanilla loot only, it doesn't seem to be affected by Multiplier or ItemListMultiplier if (Convert.ToBoolean(Config["ExtraLoot", "Enabled"]) && Convert.ToBoolean(Config["ExtraLoot", "VanillaLootTablesOnly"])) // Extra Loot Items { SpawnExtraVanillaLoot(container); } // Check for blueprint drops to remove if (Convert.ToBoolean(Config["_Settings", "DisableBlueprintDrops"])) { int count = 0; int itemsToReplace = 0; bool foundBlueprint = true; List <Item> ItemsToRemove = new List <Item>(); while (count < 3 && foundBlueprint) { for (int i = 0; i < itemsToReplace; i++) { SpawnItem(container); } // iterate through inventory to find blueprints and mark for removal. foreach (Item lootitem in container.inventory.itemList) { if (lootitem.IsBlueprint()) { ItemsToRemove.Add(lootitem); continue; } } if (ItemsToRemove.Count > 0) { itemsToReplace = ItemsToRemove.Count; foreach (Item k in ItemsToRemove) { //Puts("" + k + " was removed from " + container + " at " + container.GetEstimatedWorldPosition()); container.inventory.itemList.Remove(k); k.RemoveFromContainer(); } ItemsToRemove.Clear(); } else { foundBlueprint = false; } count++; } } ModifyContainerContents(container); } }
private object OnLootSpawn(LootContainer lootContainer) { if (lootContainer?.inventory?.itemList == null) { return(null); } foreach (var item in lootContainer.inventory.itemList.ToList()) { item.RemoveFromWorld(); item.RemoveFromContainer(); } lootContainer.PopulateLoot(); foreach (var item in lootContainer.inventory.itemList.ToList()) { var itemBlueprint = ItemManager.FindItemDefinition(item.info.shortname).Blueprint; if (_configuration.ReplaceItems && itemBlueprint != null && itemBlueprint.isResearchable) { var slot = item.position; item.RemoveFromWorld(); item.RemoveFromContainer(); var blueprint = ItemManager.CreateByName("blueprintbase"); blueprint.blueprintTarget = item.info.itemid; blueprint.MoveToContainer(lootContainer.inventory, slot); } else { object multiplier; if (_configuration.Multipliers.TryGetValue(item.info.shortname, out multiplier)) { item.amount *= Convert.ToInt32(multiplier); } } } if (lootContainer.shouldRefreshContents) { lootContainer.Invoke(new Action(lootContainer.SpawnLoot), UnityEngine.Random.Range(lootContainer.minSecondsBetweenRefresh, lootContainer.maxSecondsBetweenRefresh)); } return(true); }
void PopulateLoot(LootContainer loot, int mul = 1) { if (handledContainers.Contains(loot) || loot.ShortPrefabName == "stocking_large_deployed" || loot.ShortPrefabName == "stocking_small_deployed") { return; } handledContainers.Add(loot); var inv = loot.inventory; for (int i = inv.itemList.Count - 1; i >= 0; i--) { inv.itemList[i].Remove(); } inv.itemList.Clear(); LootStorage lootStorage; if (lootConfig.TryGetValue(loot.ShortPrefabName, out lootStorage)) { if (loot.ShortPrefabName.Contains("barrel")) { loot.inventory.capacity = 2; } if (loot.ShortPrefabName.Contains("crate_normal")) { loot.inventory.capacity = 4; } bool set; foreach (var lootItem in lootStorage.GetRandomItems(inv.capacity, out set)) { var def = itemDefinitions[lootItem.shortname]; var amount = Math.Min(set ? lootItem.amount : lootItem.amount * mul, def.stackable); inv.AddItem(def, amount); } } else { loot.PopulateLoot(); } }
private void OnLootSpawn(LootContainer lootContainer) { if (lootContainer?.inventory?.itemList == null) { return; } foreach (var item in lootContainer.inventory.itemList.ToList()) { item.RemoveFromWorld(); item.RemoveFromContainer(); } lootContainer.PopulateLoot(); foreach (var item in lootContainer.inventory.itemList.ToList()) { var itemBlueprint = ItemManager.FindItemDefinition(item.info.shortname).Blueprint; if (_configuration.ReplaceItems && itemBlueprint != null && itemBlueprint.isResearchable) { var slot = item.position; item.RemoveFromWorld(); item.RemoveFromContainer(); var blueprint = ItemManager.CreateByName("blueprintbase"); blueprint.blueprintTarget = item.info.itemid; blueprint.MoveToContainer(lootContainer.inventory, slot); } else { object multiplier; if (_configuration.Multipliers.TryGetValue(item.info.shortname, out multiplier)) { item.amount *= Convert.ToInt32(multiplier); } } } }