// Protected: #region Protected protected override void InstallPatches() { BaseChestOverlay.Install(); ChestOverlay.Install(); ChestContainer.Install(); ModEntry.Install(); }
/********* ** Private methods *********/ /// <summary>Get the underlying storage item from a container, if applicable.</summary> /// <param name="container">The container instance.</param> /// <returns>Returns the storage item if found, else <c>null</c>.</returns> private static Item GetStorageItem(IContainer container) { return(container switch { ChestContainer instance => instance.Chest, StorageFurnitureContainer instance => instance.Furniture, _ => null });
public override void OnInspectorGUI() { DrawDefaultInspector(); chestContainer = (ChestContainer)target; var stagePrefab = chestContainer.gameObject.scene; var EditorScenes = EditorSceneManager.GetActiveScene(); if (stagePrefab == null) { return; } if (EditorScenes.name != stagePrefab.name) { return; } EditorUtility.SetDirty(target); EditorGUILayout.Space(); EditorGUILayout.LabelField("Container Editor", EditorStyles.boldLabel); currentDatabase = (ObjectDatabase)EditorGUILayout.ObjectField(currentDatabase, typeof(ObjectDatabase), false, GUILayout.MaxWidth(200)); tempContainer = chestContainer.itemContainer; EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginVertical("Box"); { List <string> options = new List <string>(); List <Item> items = new List <Item>(); if (currentDatabase != null) { itemType = (ItemData_Type)EditorGUILayout.EnumPopup("Item type", itemType); if (itemType == ItemData_Type.Ammo) { items.AddRange(currentDatabase.Data.allItemAmmo); } else if (itemType == ItemData_Type.Junk) { items.AddRange(currentDatabase.Data.allItemJunk); } else if (itemType == ItemData_Type.Key) { items.AddRange(currentDatabase.Data.allItemKey); } else if (itemType == ItemData_Type.Weapon) { items.AddRange(currentDatabase.Data.allItemWeapon); } else if (itemType == ItemData_Type.Misc) { items.AddRange(currentDatabase.Data.allItemMiscs); } items.OrderBy(z => z); foreach (Item item in items) { options.Add(item.ID); } } selectedItem = EditorGUILayout.Popup("Item", selectedItem, options.ToArray()); if (items.Count > selectedItem) { if (items[selectedItem] != null) { currentItem = items[selectedItem]; } } if (GUILayout.Button("Add Item", GUILayout.Width(100))) { if (currentItem != null) { ItemData newItem = new ItemData(); newItem.ID = currentItem.ID; newItem.DatabaseName = currentDatabase.Data.name; newItem.count = 1; newItem.item_Type = MainUtility.Check_ItemType(currentItem); tempContainer.all_InventoryItem.Add(newItem); } else { Debug.LogError("No item!"); } } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); { foreach (ItemData itemDat in tempContainer.all_InventoryItem) { EditorGUILayout.BeginHorizontal("Box"); { GenericMenu menu = new GenericMenu(); itemDat.count = EditorGUILayout.IntField(itemDat.count, GUILayout.Width(40)); if (GUILayout.Button(itemDat.DatabaseName + " | " + itemDat.ID, buttonStyle)) { menu.AddItem(new GUIContent("Empty"), false, EmptyFunc); menu.AddItem(new GUIContent("Duplicate"), false, Context_Duplicate, itemDat); menu.AddItem(new GUIContent("Delete"), false, Context_Delete, itemDat); menu.ShowAsContext(); } } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Chest Container"); chestContainer.itemContainer = tempContainer; } }