// Updates ItemEntity in Player's hand public void DrawItemEntity(ItemStack its) { if (this.character == null) { return; } // If had nothing and switched to nothing if (its == null && PlayerEvents.itemInHand == null) { return; } // If had something and switched to nothing if (its == null) { DestroyItemEntity(); return; } // If had nothing and switched to something if (PlayerEvents.itemInHand == null) { PlayerEvents.itemInHand = new ItemEntityHand(its.GetID(), its.GetIconID(), this.iconRenderer); this.handItem = PlayerEvents.itemInHand.go; this.handItem.name = "HandItem"; this.handItem.transform.parent = this.character.transform; SetItemEntityPosition(); return; } // If had item and switched to same if (its.GetIconID() == PlayerEvents.itemInHand.iconID) { return; } // Else if switched from something to something else PlayerEvents.itemInHand.ChangeItem(its.GetItem()); }
public void DestroyItemEntity() { PlayerEvents.itemInHand.Destroy(); PlayerEvents.itemInHand = null; }