using System.Collections.Generic; using NodeCanvas.Tasks.Actions; using Reset.Items; using UnityEngine; namespace Reset.Units{ public class PlayerInventory : UnitComponent, IInventory { public Weapon rangedWeapon; public Weapon meleeWeapon; public Ability spellAbility1; public Ability spellAbility2; public Ability toolAbility1; public Ability toolAbility2; public List storedItems { get; set; } private IEquipable currentWeapon; private GameObject currentWeaponItem; public void OnDrawWeapon(){ // Remove a current weapon if (currentWeapon != null) { Destroy(currentWeaponItem); currentWeaponItem = null; } // Add weapon to status and hand currentWeapon = meleeWeapon; currentWeaponItem = meleeWeapon.PlaceInHand(); // Move item to hand currentWeaponItem.transform.SetParent((Unit.Animation as PlayerAnimation).rightHand); currentWeaponItem.transform.localPosition = meleeWeapon.handPositionOffset; currentWeaponItem.transform.rotation = (Unit.Animation as PlayerAnimation).rightHand.rotation * Quaternion.Euler(meleeWeapon.handRotationOffset); Debug.Log(currentWeapon); // // Unit.Graph.SendEvent("Draw Weapon"); } public void OnHolsterWeapon(){ Destroy(currentWeaponItem); currentWeaponItem = null; currentWeapon = null; Debug.Log(currentWeapon); // // Unit.Graph.SendEvent("Holster Weapon"); } public void EquipToCharacter(Item item){ if (item is not IEquipable) { Debug.LogError("This item is not equippable.", item); return; } if (item is Weapon thisWeapon) { if (meleeWeapon != null) { storedItems.Add(meleeWeapon); } meleeWeapon = thisWeapon; } } // Update is called once per frame void Update(){ } } }