private void RemoveItemFromEquipment() { if (spriteHandler != null) { spriteHandler.Empty(); } if (!InHands && GameObjectReference != null) { // did we take off clothing? var unequippedClothing = GameObjectReference.GetComponent <ClothingV2>(); if (unequippedClothing == null) { //Not clothing, maybe PDA return; } // Unhide the players's slots defined in the clothing's HiddenSlots, as we're removing it. thisPlayerScript.Equipment.obscuredSlots &= ~unequippedClothing.HiddenSlots; if (unequippedClothing) { OnClothingEquipped?.Invoke(unequippedClothing, false); } } GameObjectReference = null; }
public virtual void SetReference(GameObject item) { UpdateReferenceOffset(); if (item == null) { if (spriteHandler != null) { spriteHandler.Empty(); } if (!InHands && GameObjectReference != null) { // did we take off clothing? var unequippedClothing = GameObjectReference.GetComponent <ClothingV2>(); if (unequippedClothing != null) { // Unhide the players's slots defined in the clothing's HiddenSlots, as we're removing it. thisPlayerScript.Equipment.obscuredSlots &= ~unequippedClothing.HiddenSlots; if (unequippedClothing) { OnClothingEquipped?.Invoke(unequippedClothing, false); } } } GameObjectReference = null; // Remove the item from equipment } if (item != null) { GameObjectReference = item; // Add item to equipment if (InHands) { var ItemAttributesV2 = item.GetComponent <ItemAttributesV2>(); var InHandsSprites = ItemAttributesV2?.ItemSprites; SetInHand(InHandsSprites); } else { var equippedClothing = item.GetComponent <ClothingV2>(); equippedClothing?.LinkClothingItem(this); // Set the slots defined in hidesSlots as hidden. //thisPlayerScript.Equipment.obscuredSlots |= equippedClothing.HiddenSlots; // Some items like trash bags / mining satchels can be equipped but are not clothing and do not show on character sprite // But for the others, we call the OnClothingEquipped event. if (equippedClothing) { // call the event of equiped clothing OnClothingEquipped?.Invoke(equippedClothing, true); } } } UpdateReferenceOffset(); }
private void AddItemToEquipment(GameObject item) { GameObjectReference = item; if (InHands) { var itemAttributesV2 = item.GetComponent <ItemAttributesV2>(); var inHandsSprites = itemAttributesV2.ItemSprites; if (inHandsSprites != null) { SetInHand(inHandsSprites); } } else { var equippedClothing = item.GetComponent <ClothingV2>(); if (equippedClothing == null) { //Not clothing, maybe PDA return; } equippedClothing.LinkClothingItem(this); // Set the slots defined in hidesSlots as hidden. thisPlayerScript.Equipment.obscuredSlots |= equippedClothing.HiddenSlots; // Some items like trash bags / mining satchels can be equipped but are not clothing and do not show on character sprite // But for the others, we call the OnClothingEquipped event. // call the event of equiped clothing OnClothingEquipped?.Invoke(equippedClothing, true); } }