public RuntimeConsumableItem ConsumableToRunTime(Consumable consumable)
        {
            GameObject go = new GameObject();

            go.transform.parent = referencesParent.transform;
            go.name             = consumable.item_id;
            RuntimeConsumableItem runTimeConsumable = go.AddComponent <RuntimeConsumableItem>();

            runTimeConsumable.Instance = new Consumable();
            StaticFunctions.DeepCopyConsumable(runTimeConsumable.Instance, consumable);

            //IF you have a prefab 3D model for consumable item, instantiate thr gameobject
            if (runTimeConsumable.Instance.consumablePrefab != null)
            {
                GameObject model  = Instantiate(runTimeConsumable.Instance.consumablePrefab) as GameObject;
                Transform  parent = states.animator.GetBoneTransform(HumanBodyBones.RightHand);
                model.transform.parent           = parent;
                model.transform.localPosition    = runTimeConsumable.Instance.model_pos;
                model.transform.localEulerAngles = runTimeConsumable.Instance.model_eulerRot;

                //If the scale is 0, set it to 1 as default
                Vector3 targetScale = runTimeConsumable.Instance.model_scale;
                if (targetScale == Vector3.zero)
                {
                    targetScale = Vector3.one;
                }
                model.transform.localScale = targetScale;

                runTimeConsumable.consumableModel = model;
                runTimeConsumable.consumableModel.SetActive(false);
            }

            return(runTimeConsumable);
        }
        public void EquipConsumable(RuntimeConsumableItem consumable)
        {
            currentConsumable = consumable;

            Item i = ResourcesManager.Instance.GetItem(consumable.Instance.item_id, Itemtype.Consumable);

            quickSlotManager.UpdateSlot(QSlotType.item, i.itemIcon);
        }
        public void LoadInventory(bool updateActions = false)
        {
            SessionManager sessionManger = SessionManager.Instance;

            unarmedRunTimeWeapon           = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(unarmedId), false);
            unarmedRunTimeWeapon.isUnarmed = true;

            //3 --> number of equipment slots in inventory
            for (int i = 0; i < 3; i++)
            {
                runtime_Right_Weapons.Add(unarmedRunTimeWeapon);
                runtime_Left_Weapons.Add(unarmedRunTimeWeapon);
            }

            //There are 10 slots for consumables in inventory
            for (int i = 0; i < 10; i++)
            {
                runtime_Consumables.Add(emptyItem);
            }

            for (int i = 0; i < rightHandWeapons.Count; i++)
            {
                if (rightHandWeapons[i] == -1)
                {
                    runtime_Right_Weapons[i] = unarmedRunTimeWeapon;
                }
                else
                {
                    ItemInventoryInstance invInstance = sessionManger.GetWeaponItem(rightHandWeapons[i]);
                    RuntimeWeapon         weapon      = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(invInstance.itemId));
                    runtime_Right_Weapons[i] = weapon;
                }
            }

            for (int i = 0; i < leftHandWeapons.Count; i++)
            {
                if (leftHandWeapons[i] == -1)
                {
                    runtime_Left_Weapons[i] = unarmedRunTimeWeapon;
                }
                else
                {
                    ItemInventoryInstance invInstance = sessionManger.GetWeaponItem(leftHandWeapons[i]);
                    RuntimeWeapon         weapon      = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(invInstance.itemId), true);
                    runtime_Left_Weapons[i] = weapon;
                }
            }

            for (int i = 0; i < spellItems.Count; i++)
            {
                SpellToRuntimeSpell(ResourcesManager.Instance.GetSpell(spellItems[i]));
            }

            emptyItem         = ConsumableToRunTime(ResourcesManager.Instance.GetConsumable("empty"));
            emptyItem.isEmpty = true;
            //Consumables
            for (int i = 0; i < consumableItems.Count; i++)
            {
                if (consumableItems[i] == -1)
                {
                    runtime_Consumables[i] = emptyItem;
                }
                else
                {
                    ItemInventoryInstance invInstance       = sessionManger.GetConsumableItem(consumableItems[i]);
                    RuntimeConsumableItem runtimeConsumable = ConsumableToRunTime(ResourcesManager.Instance.GetConsumable(invInstance.itemId));
                    runtime_Consumables[i] = runtimeConsumable;
                }
            }

            InitAllDamageColliders(states);
            CloseAllDamageColliders();

            MakeIndexesList();
            EquipInventory();

            if (updateActions)
            {
                states.actionManager.UpdateActionsOneHanded();
            }
        }