| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using GadgetCore.API;
- using GadgetCore.API.ConfigMenu;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- namespace VanitySlots
- {
- [Gadget("VanitySlots", RequiredOnClients: false)]
- public class VanitySlots : Gadget<VanitySlots>
- {
- public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
- public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
- public override IGadgetConfigMenu GetConfigMenu() { return null; }
- public override string GetModDescription()
- {
- return "A mod that adds vanity slots to the players inventory.";
- }
- protected override void Initialize()
- {
- Logger.Log("Vanity Slots v" + Info.Mod.Version);
- Core.logger = Logger;
- SceneManager.sceneLoaded += OnSceneLoaded;
- }
- internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
- {
- if (scene.buildIndex == 1)
- {
- try
- {
- var storageMenu = GameObject.Find("Main Camera").transform.Find("inventoryMain").gameObject;
- var newSlots = UnityEngine.Object.Instantiate(storageMenu).transform.GetChild(0).GetChild(1).gameObject;
- Component.DestroyImmediate(newSlots.GetComponent<AnimIcon>());
- newSlots.transform.SetParent(storageMenu.transform);
- newSlots.name = "inventoryMainVanitySlots";
- newSlots.transform.localPosition = new Vector3(0, 0, 0);
- newSlots.transform.localScale = new Vector3(1, 1, 1);
- newSlots.SetActive(true);
- newSlots.GetComponent<Renderer>().material = new Material(Shader.Find("Unlit/Transparent"))
- {
- mainTexture = GadgetCoreAPI.LoadTexture2D("inventoryMainVanitySlots.png")
- };
- CreateSlot(storageMenu, 0);
- CreateSlot(storageMenu, 1);
- CreateSlot(storageMenu, 2);
- }
- catch (System.Exception e) { Core.logger.Log(e.Message); }
- }
- }
- private static void CreateSlot(GameObject menu, int id)
- {
- var originalSlot = menu.transform.Find("" + (6 + 6 * id));
- var slot = UnityEngine.Object.Instantiate(originalSlot, originalSlot.transform.parent).gameObject;
- slot.name = "vanity_slot_" + id;
- slot.layer = 0;
- slot.transform.SetParent(menu.transform);
- slot.transform.localPosition = originalSlot.transform.localPosition + new Vector3(-0.1495f, 0, 0);
- Core.itemStore.SetSlotGameObject(id, slot);
- Core.itemStore.UpdateUI();
- }
- }
- }
|