public void SpawnIntoContainer(ItemContainer container) { if (this.subSpawn != null && this.subSpawn.Length != 0) { this.SubCategoryIntoContainer(container); return; } if (this.items != null) { ItemAmountRanged[] itemAmountRangedArray = this.items; for (int i = 0; i < (int)itemAmountRangedArray.Length; i++) { ItemAmountRanged itemAmountRanged = itemAmountRangedArray[i]; if (itemAmountRanged != null) { Item item = null; if (!itemAmountRanged.itemDef.spawnAsBlueprint) { item = ItemManager.CreateByItemID(itemAmountRanged.itemid, (int)itemAmountRanged.GetAmount(), (ulong)0); } else { ItemDefinition blueprintBaseDef = this.GetBlueprintBaseDef(); if (blueprintBaseDef == null) { goto Label0; } Item item1 = ItemManager.Create(blueprintBaseDef, 1, (ulong)0); item1.blueprintTarget = itemAmountRanged.itemDef.itemid; item = item1; } if (item != null) { item.OnVirginSpawn(); if (!item.MoveToContainer(container, -1, true)) { if (!container.playerOwner) { item.Remove(0f); } else { item.Drop(container.playerOwner.GetDropPosition(), container.playerOwner.GetDropVelocity(), new Quaternion()); } } } } Label0: } } }
private void FillItemAmount(ItemAmountRanged[] amounts, ItemAmountRangedData[] amountRangedDatas, string parent) { for (var i = 0; i < amountRangedDatas.Length; i++) { var itemAmountData = amountRangedDatas[i]; var def = GetItem(itemAmountData.Shortname); if (def == null) { Puts("Item does not exist: {0} for: {1}", itemAmountData.Shortname, parent); continue; } if (itemAmountData.Amount <= 0) { Puts("Item amount too low: {0} for: {1}", itemAmountData.Shortname, parent); continue; } amounts[i] = new ItemAmountRanged(def, itemAmountData.Amount); } }