Encounter / Assets / Scripts / InventoryManagement / InventoryManipulator.cs
InventoryManipulator.cs
Raw
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using static UnityEngine.EventSystems.EventTrigger;

/// <summary>
/// Handles the inventory management of the system
/// </summary>
public class InventoryManipulator : MonoBehaviour
{
    public static InventoryManipulator Instance {  get; private set; }

    enum ActiveLocations
    {
        Helmet          = 7,
        Chest           = 8,
        Boots           = 9,
        Necklace        = 4,
        RingOne         = 5,
        RingTwo         = 6,
        PrimeWeapon     = 10,
        SecondWeapon    = 11,
        Relic           = 12
    }

    #region Variables
    [Header("General GameObject Elements")]
    [SerializeField] private GameObject itemScreen;
    [SerializeField] private GameObject spellScreen;
    [SerializeField] private GameObject abilityScreen;
    [SerializeField] private GameObject partyScreen;
    private GameObject currScreenInstance;
    private int screenRefs;

    [Header("Inventory Entity UI Elements")]
    [SerializeField] private GameObject entityPrefab;
    [SerializeField] private Transform[] entitySpritePositions;
    [SerializeField] private GameObject[] entityButtons;
    [SerializeField] private TextMeshProUGUI entityName;           // The text field that shows the shown entity's name
    [SerializeField] private TextMeshProUGUI entityLevel;           // The text field that indicates the shown entity's level
    [SerializeField] private TextMeshProUGUI hpValue;              // The text field that will indicate the health value of the shown entity
    [SerializeField] private TextMeshProUGUI mpValue;              // The text field that will indicate the mana value of the shown entity
    [SerializeField] private TextMeshProUGUI armorValue;           // The text field that will indicate the armor value of the shown entity
    [SerializeField] private TextMeshProUGUI goldCount;            // Reference to the text field that indicates how much collective gold the player has
    [SerializeField] private GameObject skillAvailEffect;

    [Header("Inventory Holder Locations")]
    [SerializeField] private Transform helmetLocation;              // 7
    [SerializeField] private Transform chestLocation;               // 8
    [SerializeField] private Transform bootsLocation;               // 9
    [SerializeField] private Transform necklaceLocation;            // 4
    [SerializeField] private Transform ringOneLocation;             // 5
    [SerializeField] private Transform ringTwoLocation;             // 6
    [SerializeField] private Transform weaponOneLocation;           // 10
    [SerializeField] private Transform weaponTwoLocation;           // 11
    [SerializeField] private Transform relicLocation;               // 12
    private Dictionary<int, GameObject> activeObjectContainers;

    [Header("Inventory Item UI Elements")]
    [SerializeField] private GameObject gridObjectPrefab;           // Prefab reference to the grid that the objects spawn on  
    [SerializeField] private GameObject itemUIPrefab;               // Prefab reference for spawning objects
    [SerializeField] private Transform itemSpawnField;              // Reference to the transform that the items will be spawned in
    [SerializeField] private Transform helperInstanceRef;           // Reference to the transform component that the helpers should spawn in
    private List<GameObject> grids;                                 // Reference to the instantiated grid components from the grid object prefab
    private Dictionary<Item, int> inactiveItemCollection;           // References to all of the items in the user's inventory that are not active

    [Header("Inventory Spell UI Elements")]
    [SerializeField] private GameObject spellUIPrefab;            // Spell GUI prefab reference for instantiation
    [SerializeField] private Transform spellSpawnField;           // Reference to the transform field that the spell prefabs will spawn in

    [Header("Inventory Ability UI Elements")]
    [SerializeField] private GameObject abilityUIPrefab;            // Ability GUI prefab reference for instantiation
    [SerializeField] private Transform abilitySpawnField;           // Reference to the transform field that the ability prefab will spawn in

    private GameObject playerObject;
    private Player playerComponent;
    private Entity currentComponent;
    private GameObject[] allyObjects;
    private Ally[] allies;
    private Inventory playerInven;
    private Inventory[] allyInvens;
    private Inventory currentInven;

    private bool initializing;
    private int previousInventorySelected;
    private Task initialization;

    private bool IsTwoHanded;

    private readonly Color ImmovableColor = new Color(.65f, .65f, .65f, 1f);
    #endregion

    public bool IsNaked
    {
        get
        {
            Dictionary<ApparelSO.Location, Apparel> invenCheck = currentComponent.GetInventory().GetActiveApparelLocations();
            return invenCheck[ApparelSO.Location.Head] == null && invenCheck[ApparelSO.Location.Chest] == null && invenCheck[ApparelSO.Location.Leggings] == null;
        }
    }

    private void Awake()
        => Instance = this;
    private void Start()
    {
        // Begin Initialization
        initialization                  = null;
        initializing                    = true;
        previousInventorySelected       = -1;
        playerObject                    = GameManager.Instance.GetPlayerObject();
        playerComponent                 = playerObject.GetComponent<Player>();
        currentComponent                = playerComponent;
        playerInven                     = playerComponent.GetInventory();
        currentInven                    = playerInven;
        allyObjects                     = GameManager.Instance.GetAllyObjects();
        allyInvens                      = new Inventory[allyObjects.Length];
        allies                          = new Ally[allyObjects.Length];

        for (int i = 0; i < allyObjects.Length; i++)
        {
            allies[i] = allyObjects[i].GetComponent<Ally>();
            allyInvens[i] = allies[i].GetInventory();
        }
        IndicateButtons();
    }
    /// <summary>
    /// Initializes various components and intakes various parts of information to not depend on if a new encounter started
    /// </summary>
    public void WakeUp()
    {
        if (currentComponent.GetInventory().GetPrimaryActiveWeapon() != null)
            IsTwoHanded = currentComponent.GetInventory().GetPrimaryActiveWeapon().WeaponIsTwoHanded;
        else
            IsTwoHanded = false;

        goldCount.text = $"{playerInven.GetGold()}";
        ShowEntityInformation(currentComponent);
        currScreenInstance = itemScreen;
        Globals.OpenInventory();
        if (GameManager.Instance.GetEncounterType() == GameManager.Encounters.Shop)
        {
            TownUI shopUi = FindObjectOfType<TownUI>().GetComponent<TownUI>();
            TownUI.CheckInventoryStatus(shopUi);
        }
        else if (GameManager.Instance.GetEncounterType() == GameManager.Encounters.Enemy)
        {
            EnemyUI enemyUi = FindObjectOfType<EnemyUI>().GetComponent<EnemyUI>();
            enemyUi.DeactivatePostBattleButtons();
        }

        InitializeItemScreenPoint();

        // All necessary information has been loaded
        initialization = Task.CompletedTask;
    }
    private void InitializeItemScreenPoint()
    {
        if (abilityScreen.activeSelf)
            abilityScreen.SetActive(false);
        else if (partyScreen.activeSelf)
            partyScreen.SetActive(false);
        else if (spellScreen.activeSelf)
            spellScreen.SetActive(false);

        screenRefs = -1;
        ActivateItemScreen();
    }
    /// <summary>
    /// Shows the current party member buttons
    /// </summary>
    private async void IndicateButtons()
    {
        // This is to prevent prior function occurance when the information necessary has not been loaded
        while (initialization == null)
            await Task.Yield();

        bool companionSwitch = true;
        int counter = -1;
        foreach (GameObject g in entityButtons)
        {
            // The first index is taken since the zero index is the button image
            // catch function activates when the allies[counter] indicates a null value
            try
            {
                g.GetComponent<Button>().interactable = true;
                g.GetComponent<Image>().enabled = true;
                g.GetComponentsInChildren<Image>()[1].enabled = true;
                if (companionSwitch)
                {
                    g.GetComponentsInChildren<Image>()[1].sprite = playerComponent.GetSprite();
                    companionSwitch = false;
                }
                else
                    g.GetComponentsInChildren<Image>()[1].sprite = allies[counter].GetSprite();
            }
            catch
            {
                g.GetComponent<Button>().interactable = false;
                g.GetComponent<Image>().enabled = false;
                g.GetComponentsInChildren<Image>()[1].enabled = false;
            }
            
            // Done after both the try and catch to prevent another entity being shown mid check
            counter++;
        }
    }
    public void ActivateEntityInformation(int inventoryValue)
    {
        // If same button was selected as the currently active inventory, simply exit method
        if (previousInventorySelected == inventoryValue)
            return;

        if (inventoryValue is -10)          // Left Button
        {
            // Goes to last available ally entity 
            if (previousInventorySelected is -1)
                inventoryValue = allies.Length - 1;
            else
                inventoryValue = previousInventorySelected - 1;
        }
        else if (inventoryValue is 10)      // Right Button
        {
            // Goes to player component, since it is always the first listed on the left side
            if (previousInventorySelected == allies.Length - 1)
                inventoryValue = -1;
            else
                inventoryValue = previousInventorySelected + 1;
        }

        ClearActiveObjects();

        if (inventoryValue is -1)
        {
            currentInven = playerInven;
            currentComponent = playerComponent;
            ShowEntityInformation(currentComponent);
        }
        else
        {
            currentInven = allyInvens[inventoryValue];
            currentComponent = allies[inventoryValue];
            ShowEntityInformation(currentComponent);
        }

        ClearScreens();

        UpdateCurrentScreen();

        previousInventorySelected = inventoryValue;
    }
    private void UpdateCurrentScreen()
    {
        switch (screenRefs)
        {
            case 0:
                screenRefs = -1;
                ActivateItemScreen();
                break;
            case 1:
                screenRefs = -1;
                ActivateSpellScreen();
                break;
            case 2:
                screenRefs = -1;
                ActivateAbilityScreen();
                break;
            case 3:
                screenRefs = -1;
                ActivatePartyScreen();
                break;
        }
    }
    private void ClearActiveObjects()
    {
        Transform activeTransform = helmetLocation.parent.transform;

        // Gets all of the inventory holder location by taking the parent and cycling through its children
        // for any item materials
        foreach (Transform child in activeTransform)
        {
            try
            {
                Destroy(child.GetChild(0).gameObject);
            }
            catch { }
        }
    }
    /// <summary>
    /// Shows the current entity information
    /// TODO ---> Add in the sprite assets in some way
    /// </summary>
    /// <param name="entity">The entity that holds the information being displayed</param>
    private void ShowEntityInformation(Entity entity)
    {
        entityName.text = $"{entity.GetName()}";
        entityLevel.text = $"{entity.GetLevel()}";
        IndicateHpAndMpText(entity);
        armorValue.text = $"{entity.GatherStats().GetStat(EntityStats.Stat.Armor, entity.RetrieveArmor())}";

        ActivateShowcaseSprite(entity, entity.GetSizeIndic());
        activeObjectContainers = new Dictionary<int, GameObject>()
        {
            { 0, null },
            { 1, null },
            { 2, null },
            { 3, null },
            { 4, null },
            { 5, null },
            { 6, null },
            { 7, null },
            { 8, null }
        };

        if (entity.HasEntityLeveledUp())
            skillAvailEffect.SetActive(true);
        else
            skillAvailEffect.SetActive(false);

        InjectActiveWeaponInfo();
        InjectActiveApparelInfo();
    }
    /// <summary>
    /// Showcases the allies sprite
    /// </summary>
    /// <param name="entity">The entity whose sprite needs to be shown</param>
    /// <param name="sizeIndic">Indication of the entity's size</param>
    private void ActivateShowcaseSprite(Entity entity, int sizeIndic)
    {
        // Re-positions any leftover showcase item
        ResetCurrentShowcaseSpritePosition();

        // 0 is the Small/closest to edge of bottom, 1 is in the middle, 2 is towards the top about 2/3's of the way
        Transform transformToUse = entitySpritePositions[sizeIndic];
        GameObject newEntityShowcase = entity.gameObject;
        EntityAnimation newEntityAnim = newEntityShowcase.GetComponent<EntityAnimation>();
        newEntityShowcase.transform.SetParent(transformToUse);
        newEntityShowcase.transform.localPosition = Vector3.zero;

        newEntityAnim.AcquireSpriteRenderer().sortingLayerName = "UI Effects";
        newEntityAnim.AcquireSpriteRenderer().sortingOrder = -1;

        entity.ReactivateVisually();
    }
    /// <summary>
    /// Resets the showcase sprite back to their position for battle encounters
    /// </summary>
    private void ResetCurrentShowcaseSpritePosition()
    {
        if (entitySpritePositions.Any(transform => transform.childCount > 0))
        {
            foreach (Transform position in entitySpritePositions)
            {
                try
                {
                    GameObject objectInPos = position.GetChild(0).gameObject;
                    objectInPos.transform.SetParent(objectInPos.GetComponent<Entity>().spawnedPosition);
                    objectInPos.transform.localPosition = Vector3.zero;
                    objectInPos.GetComponentInChildren<SpriteRenderer>().sortingLayerName = "Entities";
                    int sortingOrderID = DecipherTransformPosition(position);
                    objectInPos.GetComponentInChildren<SpriteRenderer>().sortingOrder = 10;
                    objectInPos.GetComponent<Entity>().DeactivateVisually();
                }
                catch { }
            }
        }
    }
    private int DecipherTransformPosition(Transform position)
    {
        switch (position.name)
        {
            case "Player_Position":
                return 0;
            case "Member_Position (0)":
                return 1;
            case "Member_Position (1)":
                return 2;
            case "Member_Position (2)":
                return 3;
            default:
                return -1;
        }
    }
    /// <summary>
    /// Showcases the HP and MP values based on the global settings switch
    /// </summary>
    /// <param name="entity">The entity whose values are being shown</param>
    private void IndicateHpAndMpText(Entity entity)
    {
        if (Globals.CurMaxPositionSwitch) // Enabled should be CUR / MAX
        {
            hpValue.text = $"{entity.RetrieveHealth()} / {entity.RetrieveMaxHealth()}";
            mpValue.text = $"{entity.RetrieveMana()} / {entity.RetrieveMaxMana()}";
        }
        else                              // Disabled should be MAX / CUR
        {
            hpValue.text = $"{entity.RetrieveMaxHealth()} / {entity.RetrieveHealth()}";
            mpValue.text = $"{entity.RetrieveMaxMana()} / {entity.RetrieveMana()}";
        }
    }
    /// <summary>
    /// Public call to switch the HP and MP text on the inventory status screen
    /// </summary>
    public void SwitchCurMaxText()
        => IndicateHpAndMpText(currentComponent);
    /// <summary>
    /// The weapon active fields are filled with the necessary information from the entities inventory
    /// </summary>
    /// <param name="entity">The entity information that is being shown</param>
    /// <exception cref="NullReferenceException">When the secondary weapon is marked as null a null reference exception is thrown</exception>
    private void InjectActiveWeaponInfo()
    {
        if (currentInven.GetPrimaryActiveWeapon() == null)
            return;

        if (currentInven.GetPrimaryActiveWeapon().WeaponIsTwoHanded)
        {
            GameObject weapon = Instantiate(itemUIPrefab, weaponOneLocation);
            weapon.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
            weapon.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
            weapon.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
            InjectAspectInfo(weapon, currentInven.GetPrimaryActiveWeapon());
            activeObjectContainers[(int)ActiveLocations.PrimeWeapon] = weapon;

            GameObject weaponTwo = Instantiate(itemUIPrefab, weaponTwoLocation);
            weaponTwo.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
            InjectAspectInfo(weaponTwo, currentInven.GetSecondaryActiveWeapon());
            activeObjectContainers[(int)ActiveLocations.SecondWeapon] = weaponTwo;
            weaponTwo.GetComponentInChildren<Image>().color = ImmovableColor;
            weaponTwo.GetComponent<DraggableItem>().enabled = false;
            weaponTwo.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
            weaponTwo.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
        }
        else
        {
            GameObject weapon = Instantiate(itemUIPrefab, weaponOneLocation);
            weapon.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
            weapon.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
            weapon.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
            InjectAspectInfo(weapon, currentInven.GetPrimaryActiveWeapon());
            activeObjectContainers[(int)ActiveLocations.PrimeWeapon] = weapon;

            GameObject weaponTwo = Instantiate(itemUIPrefab, weaponTwoLocation);
            try
            {
                InjectAspectInfo(weaponTwo, currentInven.GetSecondaryActiveWeapon());
                weaponTwo.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                activeObjectContainers[(int)ActiveLocations.SecondWeapon] = weaponTwo;
                weaponTwo.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                weaponTwo.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
            }
            catch
            {
                Destroy(weaponTwo);
            }
        }
    }
    /// <summary>
    /// The active apparel fields are alligned and filled with the necessary information available
    /// </summary>
    /// <exception cref="DataMisalignedException">When the key does not align to a value</exception>
    private void InjectActiveApparelInfo()
    {
        foreach (KeyValuePair<ApparelSO.Location, Apparel> pair in currentInven.GetActiveApparelLocations())
        {
            if (pair.Value == null)
                continue;

            switch (pair.Key)
            {
                case ApparelSO.Location.Head:
                    GameObject helmet = Instantiate(itemUIPrefab, helmetLocation);
                    helmet.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    helmet.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    helmet.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(helmet, pair.Value);
                    activeObjectContainers[(int)pair.Key] = helmet;
                    break;
                case ApparelSO.Location.Chest:
                    GameObject chestPiece = Instantiate(itemUIPrefab, chestLocation);
                    chestPiece.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    chestPiece.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    chestPiece.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(chestPiece, pair.Value);
                    activeObjectContainers[(int)pair.Key] = chestPiece;
                    break;
                case ApparelSO.Location.Leggings:
                    GameObject boots = Instantiate(itemUIPrefab, bootsLocation);
                    boots.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    boots.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    boots.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(boots, pair.Value);
                    activeObjectContainers[(int)pair.Key] = boots;
                    break;
                case ApparelSO.Location.Neck:
                    GameObject necklace = Instantiate(itemUIPrefab, necklaceLocation);
                    necklace.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    necklace.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    necklace.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(necklace, pair.Value);
                    activeObjectContainers[(int)pair.Key] = necklace;
                    break;
                case ApparelSO.Location.RingLocOne:
                    GameObject ringOne = Instantiate(itemUIPrefab, ringOneLocation);
                    ringOne.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    ringOne.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    ringOne.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(ringOne, pair.Value);
                    activeObjectContainers[(int)pair.Key] = ringOne;
                    break;
                case ApparelSO.Location.RingLocTwo:
                    GameObject ringTwo = Instantiate(itemUIPrefab, ringTwoLocation);
                    ringTwo.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    ringTwo.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    ringTwo.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(ringTwo, pair.Value);
                    activeObjectContainers[(int)pair.Key] = ringTwo;
                    break;
                case ApparelSO.Location.Relic:
                    GameObject relic = Instantiate(itemUIPrefab, relicLocation);
                    relic.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                    relic.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                    relic.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
                    InjectAspectInfo(relic, pair.Value);
                    activeObjectContainers[(int)pair.Key] = relic;
                    break;
                default:
                    throw new DataMisalignedException("Showing active apparel has led to unexpceted errors in InjectActiveApparelInfo inside InventoryManipulator...");
            }
        }
    }
    /// <summary>
    /// Injects the necessary aspect information into the components attached to the instantiated object
    /// </summary>
    /// <param name="aspect">The weapon game object that was spawned</param>
    /// <param name="invenToUse">The inventory that is to be used</param>
    private void InjectAspectInfo(GameObject aspect, Item itemToShow, int amount = 1)
    {
        ItemGUI gui = aspect.GetComponent<ItemGUI>();
        gui.InjectItemInformation(itemToShow, amount);

        AspectHelperManager ahm = aspect.GetComponent<AspectHelperManager>();
        ahm.InjectAspect(gui.GetAspect());
        ahm.InjectTransform(this.transform.GetChild(1).transform);
    }
    /// <summary>
    /// Closes the inventory
    /// </summary>
    public void Sleep()
    {
        // Save the current conditions of the inventory, such as equipment
        Globals.CloseInventory();
        if (GameManager.Instance.GetEncounterType() == GameManager.Encounters.Shop)
        {
            TownUI shopUi = FindObjectOfType<TownUI>().GetComponent<TownUI>();
            TownUI.CheckInventoryStatus(shopUi);
        }
        else if (GameManager.Instance.GetEncounterType() == GameManager.Encounters.Enemy)
        {
            EnemyUI enemyUi = FindObjectOfType<EnemyUI>().GetComponent<EnemyUI>();
            enemyUi.ReactivatePostBattleButtons();
        }

        skillAvailEffect.SetActive(false);

        ResetCurrentShowcaseSpritePosition();

        ClearActiveObjects();
        ClearScreens();
    }
    /// <summary>
    /// Clears the information from different fields and destroys necessary game objects
    /// </summary>
    private void ClearScreens()
    {
        foreach (Transform t in itemSpawnField)
            Destroy(t.gameObject);
        foreach (Transform t in spellSpawnField)
            Destroy(t.gameObject);
    }
    /// <summary>
    /// The starting screen that shows the items in the current inventory
    /// </summary>
    public void ActivateItemScreen()
    {
        if (currScreenInstance == itemScreen && !initializing && screenRefs is 0)
            return;

        currScreenInstance.SetActive(false);
        itemScreen.SetActive(true);
        ListItems();
        currScreenInstance = itemScreen;
        screenRefs = 0;
        
        if (initializing)
            initializing = false;
    }
    /// <summary>
    /// Lists all of the items in the current inventory after destroying any previous game object instantiations
    /// </summary>
    private void ListItems()
    {
        foreach (Transform t in itemSpawnField)
            Destroy(t.gameObject);

        grids                      = new List<GameObject>();
        inactiveItemCollection     = new Dictionary<Item, int>();

        Dictionary<Item, int> items                 = new Dictionary<Item, int>();
        foreach (KeyValuePair<Item, int> pair in currentInven.Items)
            items.Add(pair.Key, pair.Value);
        Dictionary<Consumable, int> consumables     = new Dictionary<Consumable, int>();
        foreach (KeyValuePair<Consumable, int> pair in currentInven.Consumables)
            consumables.Add(pair.Key, pair.Value);
        Dictionary<Weapon, int> weapons             = new Dictionary<Weapon, int>();
        foreach (KeyValuePair<Weapon, int> pair in currentInven.Weapons)
            weapons.Add(pair.Key, pair.Value);
        Dictionary<Apparel, int> apparel            = new Dictionary<Apparel, int>();
        foreach (KeyValuePair<Apparel, int> pair in currentInven.Apparel)
            apparel.Add(pair.Key, pair.Value);
        Dictionary<Relic, int> relics               = new Dictionary<Relic, int>();
        foreach (KeyValuePair<Relic, int> relic in currentInven.Relics)
            relics.Add(relic.Key, relic.Value);

        for (int i = 0; i < currentInven.GetInvenLimit(); i++)
        {
            GameObject grid = Instantiate(gridObjectPrefab, itemSpawnField);
            grids.Add(grid);
        }
        
        // Counter is used to increment the index object position in the grids list
        int counter = 0;

        foreach (KeyValuePair<Weapon, int> weapon in weapons)
        {
            int amount = weapon.Value;
            if (weapon.Key == currentInven.GetPrimaryActiveWeapon() || weapon.Key == currentInven.GetSecondaryActiveWeapon())
            {
                if (amount > 1)
                {
                    // Take one off immediately
                    --amount;

                    // Check if another of the same type isnt present in the other field if the weapon is one handed
                    bool check = !weapon.Key.WeaponIsTwoHanded && weapon.Key == currentInven.GetPrimaryActiveWeapon() && weapon.Key == currentInven.GetSecondaryActiveWeapon();
                    if (check)
                    {
                        --amount;

                        // Do not make a general inven gui if the amount is now 0
                        if (amount is 0)
                            continue;
                    }
                }
                else
                    continue;
            }

            GameObject goRef = Instantiate(itemUIPrefab, grids[counter++].transform);
            ItemGUI guiRef = goRef.GetComponent<ItemGUI>();
            guiRef.InjectItemInformation(weapon.Key, amount);
            guiRef.IndicateNoNameLargeSpriteWithAmount();
            AspectHelperManager ahm = goRef.GetComponent<AspectHelperManager>();
            ahm.InjectAspect(weapon.Key);
            ahm.InjectTransform(helperInstanceRef);

            inactiveItemCollection.Add(weapon.Key, amount);
        }
        foreach (KeyValuePair<Apparel, int> app in apparel)
        {
            int amount = app.Value;
            if (currentInven.GetActiveApparelLocations().ContainsValue(app.Key))
            {
                if (app.Value > 1)
                {
                    --amount;

                    // Check if another of the same type isnt present in the other field if the apparel is a ring
                    bool check = (app.Key.ApparelLocation is ApparelSO.Location.RingLocOne || app.Key.ApparelLocation is ApparelSO.Location.RingLocTwo) &&
                                  currentInven.GetActiveApparelLocations()[ApparelSO.Location.RingLocOne] == currentInven.GetActiveApparelLocations()[ApparelSO.Location.RingLocTwo];
                    if (check)
                    {
                        --amount;

                        // Do not make a general inven gui if the amount is now 0
                        if (amount is 0)
                            continue;
                    }
                }
                else
                    continue;
            }

            GameObject goRef = Instantiate(itemUIPrefab, grids[counter++].transform);
            ItemGUI guiRef = goRef.GetComponent<ItemGUI>();
            guiRef.InjectItemInformation(app.Key, amount);
            guiRef.IndicateNoNameLargeSpriteWithAmount();
            AspectHelperManager ahm = goRef.GetComponent<AspectHelperManager>();
            ahm.InjectAspect(app.Key);
            ahm.InjectTransform(helperInstanceRef);

            inactiveItemCollection.Add(app.Key, amount);
        }
        foreach (KeyValuePair<Relic, int> relic in relics)
        {
            int amount = relic.Value;
            if (currentInven.GetActiveRelic() == relic.Key)
            {
                if (amount > 1)
                    --amount;
                else
                    continue;
            }

            GameObject goRef = Instantiate(itemUIPrefab, grids[counter++].transform);
            ItemGUI guiRef = goRef.GetComponent<ItemGUI>();
            guiRef.InjectItemInformation(relic.Key, amount);
            guiRef.IndicateNoNameLargeSpriteWithAmount();
            AspectHelperManager ahm = goRef.GetComponent<AspectHelperManager>();
            ahm.InjectAspect(relic.Key);
            ahm.InjectTransform(helperInstanceRef);

            inactiveItemCollection.Add(relic.Key, amount);
        }
        foreach (KeyValuePair<Item, int> item in items)
        {
            GameObject goRef = Instantiate(itemUIPrefab, grids[counter++].transform);
            ItemGUI guiRef = goRef.GetComponent<ItemGUI>();
            guiRef.InjectItemInformation(item.Key, item.Value);
            guiRef.IndicateNoNameLargeSpriteWithAmount();
            AspectHelperManager ahm = goRef.GetComponent<AspectHelperManager>();
            ahm.InjectAspect(item.Key);
            ahm.InjectTransform(helperInstanceRef);

            inactiveItemCollection.Add(item.Key, item.Value);
        }
        foreach (KeyValuePair<Consumable, int> cons in consumables)
        {
            GameObject goRef = Instantiate(itemUIPrefab, grids[counter++].transform);
            ItemGUI guiRef = goRef.GetComponent<ItemGUI>();
            guiRef.InjectItemInformation(cons.Key, cons.Value);
            guiRef.IndicateNoNameLargeSpriteWithAmount();
            AspectHelperManager ahm = goRef.GetComponent<AspectHelperManager>();
            ahm.InjectAspect(cons.Key);
            ahm.InjectTransform(helperInstanceRef);

            inactiveItemCollection.Add(cons.Key, cons.Value);
        }
    }
    /// <summary>
    /// Shows the list of spells available to the current entity being shown
    /// </summary>
    public void ActivateSpellScreen()
    {
        if (currScreenInstance == spellScreen && screenRefs is 1)
            return;

        currScreenInstance.SetActive(false);
        spellScreen.SetActive(true);
        ListSpells();
        currScreenInstance = spellScreen;
        screenRefs = 1;
    }
    /// <summary>
    /// Shows the spells in the current entity's posession
    /// </summary>
    private void ListSpells()
    {
        foreach (Transform child in spellSpawnField)
            Destroy(child.gameObject);
        
        List<Spell> spells = new List<Spell>(currentInven.Spells);
        spells.AddRange(currentInven.limitedSpells);

        spells.ForEach(spell =>
        {
            GameObject spellRef = Instantiate(spellUIPrefab, spellSpawnField);
            spellRef.GetComponent<SpellGUI>().InjectSpellInformation(spell);
        });
    }
    /// <summary>
    /// Switches the current active screen as well as start listing all of the current inventories/entities abilities
    /// </summary>
    public void ActivateAbilityScreen()
    {
        if (currScreenInstance == abilityScreen && screenRefs is 2)
            return;

        currScreenInstance.SetActive(false);
        abilityScreen.SetActive(true);
        ListAbilities();
        currScreenInstance = abilityScreen;
        screenRefs = 2;
    }
    /// <summary>
    /// Lists all of the abilities within the entities possession into the ability screen
    /// </summary>
    private void ListAbilities()
    {
        foreach (Transform child in abilitySpawnField)
            Destroy(child.gameObject);

        List<Ability> abilities = new List<Ability>(currentInven.Abilities);
        abilities.AddRange(currentInven.limitedAbilities);

        abilities.ForEach(ability =>
        {
            GameObject abilityRef = Instantiate(abilityUIPrefab, abilitySpawnField);
            abilityRef.GetComponent<AbilityGUI>().InjectAbilityInformation(ability);
        });
    }
    public void ActivatePartyScreen()
    {
        if (currScreenInstance == partyScreen && screenRefs is 3)
            return;

        currScreenInstance.SetActive(false);
        partyScreen.SetActive(true);
        currScreenInstance = partyScreen;
        screenRefs = 3;
    }
    /// <summary>
    /// Switches the location and information shown with the new inactive item logic
    /// that takes information from the active item
    /// </summary>
    /// <param name="oldActiveItem">The active item that is being made inactive</param>
    public bool SwitchActiveToInventory(GameObject oldActiveItem, Transform chosenGrid, bool switching = false, DropBox.DropLocations locationSwitch = DropBox.DropLocations.GeneralItemInventory)
    {
        if (inactiveItemCollection.ContainsKey(oldActiveItem.GetComponent<ItemGUI>().GetAspect()))
        {
            Item item = oldActiveItem.GetComponent<ItemGUI>().GetAspect();
            inactiveItemCollection[item]++;

            foreach (GameObject grid in grids)
            {
                try
                {
                    GameObject inactiveItemInGrid = grid.transform.GetChild(0).gameObject;
                    Item itemInGridPoint = inactiveItemInGrid.GetComponent<ItemGUI>().GetAspect();
                    bool typeCheck = (itemInGridPoint is Weapon && item is Weapon) || (itemInGridPoint is Apparel && item is Apparel) || (itemInGridPoint is Item && item is Item);
                    if (typeCheck && itemInGridPoint.ItemId == item.ItemId)
                    {
                        inactiveItemInGrid.GetComponent<ItemGUI>().InjectItemInformation(item, inactiveItemCollection[item]);
                        break;
                    }
                }
                catch { }
            }

            DeactivateItem(oldActiveItem, locationSwitch);
            DestroyImmediate(oldActiveItem);
            CheckNude();
            return true;
        }

        ItemGUI gui = oldActiveItem.GetComponent<ItemGUI>();

        // TODO ---> Make an easier marker for items that can't be switched out once equipped
        if (gui.GetItemName().Equals("Natural Armor"))
            throw new InvalidOperationException();

        gui.IndicateNoNameLargeSpriteWithAmount();
        oldActiveItem.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ItemScreenInventory;
        bool indic = CheckAndSwitchLocation(oldActiveItem, gui.GetAspect(), chosenGrid, DropBox.DropLocations.GeneralItemInventory);
        if (!indic)
            return false;

        oldActiveItem.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
        inactiveItemCollection.Add(gui.GetAspect(), 1);

        if (switching)
            oldActiveItem.transform.SetParent(chosenGrid.transform, false);

        CheckNude();
        UpdateInvenInformation(currentComponent);
        return true;
    }
    /// <summary>
    /// A funny effect for if the player goes commando
    /// </summary>
    public void CheckNude()
    {
        Dictionary<int, Ability> abilityList = AbilityBrain.GetAbilityList();
        bool isNude = currentComponent.GetInventory().Abilities.Contains(abilityList[141]);

        Ability nudeAbility = new Ability(abilityList[141]);

        if (helmetLocation.childCount is 0 && bootsLocation.childCount is 0 && chestLocation.childCount is 0 && !isNude)
        {
            currentComponent.GetInventory().Add(nudeAbility);

            int newCHA = currentComponent.GetBaseStat(EntityStats.Stat.Charisma) - 2;
            currentComponent.GatherStats().SetStat("CHA", newCHA);
        }
        else if (isNude && (helmetLocation.childCount is not 0 || bootsLocation.childCount is not 0 || chestLocation.childCount is not 0))
        {
            currentComponent.GetInventory().Remove(nudeAbility);

            int newCHA = currentComponent.GetBaseStat(EntityStats.Stat.Charisma) + 2;
            currentComponent.GatherStats().SetStat("CHA", newCHA);
        }
    }
    /// <summary>
    /// Switches an inventory item to an active location
    /// </summary>
    /// <param name="itemBeingActivated">The old inventory status'ed item</param>
    /// <param name="dropBoxTransform">The transform that the new object is meant to spawn in</param>
    /// <param name="location">The location that is being considered</param>
    public bool SwitchInventoryToActive(GameObject itemBeingActivated, DropBox.DropLocations location)
    {
        RequirementHandler.SetEntityInformaiton(currentComponent);
        (_, bool trigger) = RequirementHandler.DetermineSpawnedAspectEligibility(itemBeingActivated.GetComponent<ItemGUI>().GetAspect());
        
        // Guard clause for if the item is actually unable to be used by the player currently
        if (!trigger)
            return false;

        Item itemCheck = itemBeingActivated.GetComponent<ItemGUI>().GetAspect();
        try
        {
            if (inactiveItemCollection[itemCheck] >= 1)
            {
                if (CheckForSameItem(itemCheck, location))
                    return false;

                int newAmount = inactiveItemCollection[itemCheck] - 1;
                inactiveItemCollection[itemCheck]--;

                if (inactiveItemCollection[itemCheck] is not 0)
                {
                    GameObject replication = Instantiate(itemBeingActivated, grids.Where(grid => grid.transform.childCount is 0).FirstOrDefault().transform);
                    InjectAspectInfo(replication, itemCheck, newAmount);
                    replication.GetComponentInChildren<Image>().raycastTarget = true;
                }
            }
        }
        catch { }

        // Need to switch to the active Item Container so the sprite looks less conjoined
        itemBeingActivated.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
        itemBeingActivated.GetComponent<DraggableItem>().Type = DraggableItem.DraggableItemType.ActiveItemSpot;
        bool indic = false;

        DraggableItem dragItem = itemBeingActivated.GetComponent<DraggableItem>();
        switch (location)
        {
            case DropBox.DropLocations.ActiveItemNecklace:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), necklaceLocation, DropBox.DropLocations.ActiveItemNecklace);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemRingOne:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), ringOneLocation, DropBox.DropLocations.ActiveItemRingOne);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemRingTwo:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), ringTwoLocation, DropBox.DropLocations.ActiveItemRingTwo);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemHelmet:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), helmetLocation, DropBox.DropLocations.ActiveItemHelmet);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemChest:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), chestLocation, DropBox.DropLocations.ActiveItemChest);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemBoots:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), bootsLocation, DropBox.DropLocations.ActiveItemBoots);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemWeapon:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), weaponOneLocation, DropBox.DropLocations.ActiveItemWeapon);
                if (indic)
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                break;
            case DropBox.DropLocations.ActiveItemSecWeapon:
                Item item = itemBeingActivated.GetComponent<ItemGUI>().GetAspect();
                if ((item as Weapon).WeaponIsTwoHanded)
                {
                    TransmitNewTransform(itemBeingActivated, weaponOneLocation.transform);
                    indic = CheckAndSwitchLocation(itemBeingActivated, item, weaponOneLocation.transform, DropBox.DropLocations.ActiveItemWeapon);
                    break;
                }

                indic = CheckAndSwitchLocation(itemBeingActivated, item, weaponTwoLocation, DropBox.DropLocations.ActiveItemSecWeapon);
                if (indic)
                {
                    itemBeingActivated.transform.SetParent(weaponTwoLocation);
                    if ((itemBeingActivated.GetComponent<ItemGUI>().GetAspect() as Weapon).WeaponIsTwoHanded)
                    {
                        itemBeingActivated.GetComponent<Image>().color = ImmovableColor;
                        itemBeingActivated.GetComponent<DraggableItem>().enabled = false;
                    }
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                }
                break;
            case DropBox.DropLocations.ActiveItemRelic:
                indic = CheckAndSwitchLocation(itemBeingActivated, itemBeingActivated.GetComponent<ItemGUI>().GetAspect(), relicLocation, DropBox.DropLocations.ActiveItemRelic);
                if (indic)
                {
                    itemBeingActivated.transform.SetParent(relicLocation);
                    dragItem.Type = DraggableItem.DraggableItemType.ActiveItemSpot;
                } 
                break;
        }

        if (!indic)
            throw new InvalidOperationException($"An error occurred when trying to set an item to an active " +
                $"slot.\n Old: {itemBeingActivated.name}\n New: {itemBeingActivated.name}");

        itemBeingActivated.GetComponent<AspectHelperManager>().SwitchOffsetSign(true);
        if (inactiveItemCollection.ContainsKey(itemCheck))
        {
            if (inactiveItemCollection[itemCheck] is 0)
                inactiveItemCollection.Remove(itemCheck);
        }

        return true;
    }
    /// <summary>
    /// Checks if the item that is being transferred is the same one as in the Drop Box Location 
    /// </summary>
    /// <param name="itemCheck">The item attempted to be transferred</param>
    /// <param name="location">The location to check item</param>
    /// <returns>False if not the same, or null, True if they are the same</returns>
    private bool CheckForSameItem(Item itemCheck, DropBox.DropLocations location)
    {
        bool output = false;

        try
        {
            Item itemInActive = activeObjectContainers[(int)location].GetComponent<ItemGUI>().GetAspect();

            if (itemCheck == itemInActive)
                output = true;
        }
        catch { }

        return output;
    }
    /// <summary>
    /// Switches out the active item if a child is detected in the transform location being considered
    /// </summary>
    /// <param name="itemInformation">The item to be passed as the new active</param>
    /// <param name="parentTransform">The parent transform to be considered</param>
    /// <param name="location">The matching location to the parent transform for further specific logic</param>
    /// <returns>True if the process completed successfully, false if an invalid value was provided</returns>
    /// <exception cref="NotSupportedException">If a parent has a child count of more than 1 than an error is thrown since that should not be possible</exception>
    private bool CheckAndSwitchLocation(GameObject transferringItem, Item itemInformation, Transform parentTransform, DropBox.DropLocations location)
    {
        if (parentTransform.childCount is 0 || location is DropBox.DropLocations.GeneralItemInventory)
        {
            switch (location)
            {
                case DropBox.DropLocations.GeneralItemInventory:
                    if (parentTransform.childCount > 0)
                    {
                        foreach (GameObject grid in grids)
                        {
                            if (grid.transform.childCount is 0)
                            {
                                TransmitNewTransform(transferringItem, grid.transform);
                                DeactivateItem(transferringItem, location);
                                break;
                            }
                        }
                    }
                    else
                        DeactivateItem(transferringItem, location);
                    break;
                case DropBox.DropLocations.ActiveItemNecklace:
                    InjectNewActiveItem((int)ActiveLocations.Necklace, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemRingOne:
                    InjectNewActiveItem((int)ActiveLocations.RingOne, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemRingTwo:
                    InjectNewActiveItem((int)ActiveLocations.RingTwo, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemHelmet:
                    InjectNewActiveItem((int)ActiveLocations.Helmet, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemChest:
                    InjectNewActiveItem((int)ActiveLocations.Chest, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemBoots:
                    InjectNewActiveItem((int)ActiveLocations.Boots, transferringItem);
                    break;
                case DropBox.DropLocations.ActiveItemWeapon:
                    bool primeCheck = InjectNewActiveItem((int)ActiveLocations.PrimeWeapon, transferringItem);
                    // If the check results in false, this indicates that the weapon is two handed and 
                    // needs the extra slot of information
                    if (!primeCheck)
                    {
                        // Handles a one handed weapon being present in the secondary slot
                        if (weaponTwoLocation.childCount > 0)
                        {
                            // If two handed, already being rid of, if one handed needs to be switched back to inventory
                            bool twoHandCheck = (weaponTwoLocation.GetChild(0).GetComponent<ItemGUI>().GetAspect() as Weapon).WeaponIsTwoHanded;

                            if (!twoHandCheck)
                            {
                                Transform transformToUse = null;
                                foreach (GameObject grid in grids)
                                {
                                    if (grid.transform.childCount is 0)
                                    {
                                        transformToUse = grid.transform;
                                        break;
                                    }
                                }

                                if (transformToUse == null)
                                    return false;

                                SwitchActiveToInventory(weaponTwoLocation.GetChild(0).gameObject, transformToUse, true);
                            }
                        }

                        GameObject checkObject;
                        try
                        {
                            checkObject = weaponTwoLocation.GetChild(0).gameObject;
                            Item itemCheck = checkObject.GetComponent<ItemGUI>().GetAspect();

                            if (itemCheck as Weapon == itemInformation as Weapon)
                                break;
                        }
                        catch { }

                        GameObject secWeaponInfo = Instantiate(itemUIPrefab, weaponTwoLocation);
                        secWeaponInfo.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                        InjectAspectInfo(secWeaponInfo, itemInformation as Weapon);
                        secWeaponInfo.GetComponent<DraggableItem>().enabled = false;
                        secWeaponInfo.GetComponentInChildren<Image>().color = ImmovableColor;
                        InjectNewActiveItem((int)ActiveLocations.SecondWeapon, transferringItem, true);
                    }
                    break;
                case DropBox.DropLocations.ActiveItemSecWeapon:
                    bool secCheck = InjectNewActiveItem((int)ActiveLocations.SecondWeapon, transferringItem);
                    
                    // If the secondary set switched to the main
                    if (secCheck && (itemInformation as Weapon).WeaponIsTwoHanded)
                    {
                        DeactivateItem(transferringItem, location);
                        SwitchInventoryToActive(transferringItem, DropBox.DropLocations.ActiveItemWeapon);
                        CheckNude();
                        InjectNewActiveItem((int)ActiveLocations.PrimeWeapon, transferringItem);
                    }
                    break;
                case DropBox.DropLocations.ActiveItemRelic:
                    InjectNewActiveItem((int)ActiveLocations.Relic, transferringItem);
                    break;
                default:
                    return false;
            }
        }
        else if (parentTransform.childCount is 1)
        {
            GameObject replacedItem = parentTransform.GetChild(0).gameObject;
            Transform chosenTransform = grids.Where(grid => grid.transform.childCount is 0).FirstOrDefault().transform;

            if (location is DropBox.DropLocations.ActiveItemRingOne || location is DropBox.DropLocations.ActiveItemRingTwo)
            {
                // If one of the locations of rings is empty, simply just put the newly active ring there
                bool checkOne = ringOneLocation.childCount is 0;
                bool checkTwo = ringTwoLocation.childCount is 0;

                if (checkOne && !checkTwo)
                {
                    CheckAndSwitchLocation(transferringItem, itemInformation, ringOneLocation, DropBox.DropLocations.ActiveItemRingOne);
                    return true;
                }
                else if (!checkOne && checkTwo)
                {
                    CheckAndSwitchLocation(transferringItem, itemInformation, ringTwoLocation, DropBox.DropLocations.ActiveItemRingTwo);
                    return true;
                }
            }

            // This if block handles the edge instance where a one handed or two handed is switched with the 
            // immovable second part of a two handed weapon
            if (location is DropBox.DropLocations.ActiveItemSecWeapon && weaponOneLocation.childCount > 0)
            {
                GameObject childObject = weaponOneLocation.GetChild(0).gameObject;
                ItemGUI itemGui = childObject.GetComponent<ItemGUI>();
                bool transferIsTwoHanded = (itemGui.GetAspect() as Weapon).WeaponIsTwoHanded;
                if (transferIsTwoHanded)
                {
                    bool switchPrimaryIndicator = SwitchActiveToInventory(childObject, chosenTransform, true);
                    
                    if (!switchPrimaryIndicator)
                        return false;

                    bool injectedItemState = InjectNewActiveItem((int)ActiveLocations.PrimeWeapon, transferringItem);
                    transferringItem.GetComponent<DraggableItem>().SetParentDrag(weaponOneLocation.transform);

                    // If the newly instanced primary is two handed sets up an immovable two handed version
                    if ((itemInformation as Weapon).WeaponIsTwoHanded)
                    {
                        GameObject secWeaponInfo = Instantiate(itemUIPrefab, weaponTwoLocation);
                        secWeaponInfo.GetComponent<ItemGUI>().IndicateLargeSpriteNoOtherElements();
                        InjectAspectInfo(secWeaponInfo, itemInformation as Weapon);
                        secWeaponInfo.GetComponent<DraggableItem>().enabled = false;
                        secWeaponInfo.GetComponentInChildren<Image>().color = ImmovableColor;
                        InjectNewActiveItem((int)ActiveLocations.SecondWeapon, transferringItem);
                    }

                    return injectedItemState;
                }
            }

            if (!replacedItem.GetComponent<ItemGUI>().GetItemName().Equals("Fist"))
            {
                bool indicator = SwitchActiveToInventory(replacedItem, chosenTransform, true, location);
                if (!indicator)
                    return false;
            }
            else
                DestroyImmediate(replacedItem);

            bool output = CheckAndSwitchLocation(transferringItem, itemInformation, parentTransform, location);
            return output;
        }

        return true;
    }
    private bool InjectNewActiveItem(int keyValue, GameObject newItem, bool wasPrimarySwitch = false)
    {
        if (activeObjectContainers.ContainsKey(keyValue))
            activeObjectContainers[keyValue] = newItem;
        else
            activeObjectContainers.Add(keyValue, newItem);

        Item itemCheck = newItem.GetComponent<ItemGUI>().GetAspect();
        switch ((ActiveLocations)keyValue)
        {
            case ActiveLocations.Helmet:
                currentInven.SetActiveApparelAtLocation(itemCheck as Apparel, ApparelSO.Location.Head);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.Chest:
                currentInven.SetActiveApparelAtLocation(itemCheck as Apparel, ApparelSO.Location.Chest);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.Boots:
                currentInven.SetActiveApparelAtLocation(itemCheck as Apparel, ApparelSO.Location.Leggings);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.Necklace:
                currentInven.SetActiveApparelAtLocation(itemCheck as Apparel, ApparelSO.Location.Neck);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.RingOne:
                currentInven.SetRing(itemCheck as Apparel, ApparelSO.Location.RingLocOne);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.RingTwo:
                currentInven.SetRing(itemCheck as Apparel, ApparelSO.Location.RingLocTwo);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            case ActiveLocations.PrimeWeapon:
                if ((itemCheck as Weapon).WeaponIsTwoHanded)
                    IsTwoHanded = true;
                else
                    IsTwoHanded = false;

                return currentInven.SetPrimaryActiveWeapon(itemCheck as Weapon);
            case ActiveLocations.SecondWeapon:
                if ((itemCheck as Weapon).WeaponIsTwoHanded)
                    IsTwoHanded = true;
                else
                    IsTwoHanded = false;

                if (!wasPrimarySwitch)
                    currentInven.SetSecondaryActiveWeapon(itemCheck as Weapon);

                break;
            case ActiveLocations.Relic:
                currentInven.SetActiveRelic(itemCheck as Relic);
                UpdateInvenInformation(currentInven.AttachedEntity);
                break;
            default:
                Debug.LogError($"An unknown object was set to a key value out of range. Please check logic. Key Value ({keyValue})!");
                return false;
        }

        return true;
    }
    /// <summary>
    /// Deactivates an item when the item in question is taken from the active slot
    /// </summary>
    /// <param name="itemRemoved">The item to deactivate</param>
    /// <exception cref="NullReferenceException">If the item is null than an exception is thrown</exception>
    private void DeactivateItem(GameObject itemRemoved, DropBox.DropLocations locationSwitch)
    {
        if (itemRemoved.GetComponent<ItemGUI>() == null)
            throw new NullReferenceException($"Item not detected in object {itemRemoved.name}");

        ItemGUI gui = itemRemoved.GetComponent<ItemGUI>();
        Item item = gui.GetAspect();

        if (item is Weapon weapon)
        {
            if (activeObjectContainers[(int)ActiveLocations.PrimeWeapon] == itemRemoved)
            {
                currentInven.SetPrimaryActiveWeapon(null);
                activeObjectContainers[(int)ActiveLocations.PrimeWeapon] = null;

                if (weapon.WeaponIsTwoHanded)
                {
                    currentInven.SetSecondaryActiveWeapon(null);
                    activeObjectContainers[(int)ActiveLocations.SecondWeapon] = null; 
                    try
                    {
                        Destroy(weaponTwoLocation.GetChild(0).gameObject);
                    }
                    catch { }
                }
            }
            else
            {
                currentInven.SetSecondaryActiveWeapon(null);
                activeObjectContainers[(int)ActiveLocations.SecondWeapon] = null;
            }
        }
        else if (item is Apparel apparel)
        {
            if (apparel.ApparelLocation is ApparelSO.Location.RingLocOne || apparel.ApparelLocation is ApparelSO.Location.RingLocTwo)
            {
                if (apparel.ApparelLocation is ApparelSO.Location.RingLocOne && locationSwitch is DropBox.DropLocations.ActiveItemRingTwo)
                    currentInven.SetRing(null, ApparelSO.Location.RingLocTwo);
                else if (apparel.ApparelLocation is ApparelSO.Location.RingLocTwo && locationSwitch is DropBox.DropLocations.ActiveItemRingOne)
                    currentInven.SetRing(null, ApparelSO.Location.RingLocOne);
            }
            else
                currentInven.SetActiveApparelAtLocation(null, apparel.ApparelLocation);

            switch (apparel.ApparelLocation)
            {
                case ApparelSO.Location.Head:
                    activeObjectContainers[(int)ActiveLocations.Helmet] = null;
                    break;
                case ApparelSO.Location.Chest:
                    activeObjectContainers[(int)ActiveLocations.Chest] = null;
                    break;
                case ApparelSO.Location.Leggings:
                    activeObjectContainers[(int)ActiveLocations.Boots] = null;
                    break;
                case ApparelSO.Location.Neck:
                    activeObjectContainers[(int)ActiveLocations.Necklace] = null;
                    break;
                case ApparelSO.Location.RingLocOne:
                    if (locationSwitch is DropBox.DropLocations.ActiveItemRingTwo)
                    {
                        currentInven.SetRing(null, ApparelSO.Location.RingLocTwo);
                        activeObjectContainers[(int)ActiveLocations.RingTwo] = null;
                        break;
                    }

                    currentInven.SetRing(null, ApparelSO.Location.RingLocOne);
                    activeObjectContainers[(int)ActiveLocations.RingOne] = null;
                    break;
                case ApparelSO.Location.RingLocTwo:
                    if (locationSwitch is DropBox.DropLocations.ActiveItemRingOne)
                    {
                        currentInven.SetRing(null, ApparelSO.Location.RingLocOne);
                        activeObjectContainers[(int)ActiveLocations.RingOne] = null;
                        break;
                    }

                    currentInven.SetRing(null, ApparelSO.Location.RingLocTwo);
                    activeObjectContainers[(int)ActiveLocations.RingTwo] = null;
                    break;
            }
        }
        else if (item is Relic)
        {
            currentInven.SetActiveRelic(null);
            activeObjectContainers[(int)ActiveLocations.Relic] = null;
        }
    }
    /// <summary>
    /// Transfers a better transform for the placement of the draggable item
    /// </summary>
    /// <param name="newItem">The new item object</param>
    /// <param name="otherBox">The new transform</param>
    private void TransmitNewTransform(GameObject newItem, Transform otherBox)
        => newItem.GetComponent<DraggableItem>().SetParentDrag(otherBox);
    /// <summary>
    /// Sends signal to update the shown entity information, such as HP
    /// </summary>
    /// <param name="entity">The entity, whose information is being updated</param>
    private void UpdateInvenInformation(Entity entity)
    {
        entityName.text            = $"{entity.GetName()}";
        hpValue.text               = $"{entity.RetrieveHealth()} / {entity.RetrieveMaxHealth()}";
        mpValue.text               = $"{entity.RetrieveMana()} / {entity.RetrieveMaxMana()}";
        armorValue.text            = $"{entity.GatherStats().GetStat(EntityStats.Stat.Armor, entity.RetrieveArmor())}";

        if (entity.HasEntityLeveledUp())
            skillAvailEffect.SetActive(true);
        else
            skillAvailEffect.SetActive(false);
    }
    public void CallToUpdate()
    {
        currentComponent.StatusChanged();
        UpdateInvenInformation(currentComponent);
        UpdateCurrentScreen();
    }
    /// <summary>
    /// Retrieves the current entity component, primarily for the status screen handler
    /// </summary>
    /// <returns>The current entity whose stats and items are being shown</returns>
    public Entity GetCurrentEntity()
        => currentComponent;

    public void AdjustItems()
    {
        WeaponSO.Type weaponType = currentComponent.GetInventory().GetPrimaryActiveWeapon().WeaponType;
        Dictionary<WeaponSO.Type, bool> offHandedIndic = currentComponent.GetInventory().GetTwoHandedInOffHandData();
        
        if (offHandedIndic[weaponType] && IsTwoHanded && weaponTwoLocation.childCount > 0)
        {
            activeObjectContainers[7] = null;
            Destroy(weaponTwoLocation.GetChild(0).gameObject);
            currentComponent.GetInventory().SetSecondaryActiveWeapon(null);
        }
    }
}