/// <summary> /// Called when [active item changed]. /// </summary> /// <param name="item">The item.</param> private void OnActiveItemChanged(T item) { ActiveItemChanged?.Invoke(this, new AutoQueueEventArgs <T> { Item = item }); }
public void Equip(IItem item) { // We don't want multiple items equipped at the same time UnequipActiveItem(); // Place this item underneath our right hand HandleItemEquipped(item); // Invoke the Event if the Event is not null ActiveItemChanged?.Invoke(ActiveItem); ItemEquipped?.Invoke(item); }
public void Equip(Item item) { // Likely puts item in right spot, fires a bunch of call backs, etc. Debug.Log($"Equipped Item {item.gameObject.name}"); item.transform.SetParent(_rightHand); // Note: Performance impact here is fine since we've only done it once. // If doing repeatedly, cache the value and go from there. item.transform.localPosition = Vector3.zero; item.transform.localRotation = Quaternion.identity; ActiveItem = item; // If ActiveItem is not null (the ? part) then invoke the event and pass in what the active item is // The ? is similar to "if (ActiveItem != null)" ActiveItemChanged?.Invoke(ActiveItem); }
/// <summary> /// Equip given item. /// </summary> /// <param name="item">Item to equip</param> public void Equip(Item item) { // MN:TO_DO:Delete this Debug.Log($"Equipped item [{item.gameObject.name}]"); Transform trans = item.transform; trans.SetParent(_rightHand); trans.localPosition = Vector3.zero; trans.localRotation = Quaternion.identity; ActiveItem = item; ActiveItemChanged?.Invoke(ActiveItem); }
public void Equip(IItem item) { if (ActiveItem != null) { ActiveItem.transform.SetParent(_itemRoot); ActiveItem.gameObject.SetActive(false); ItemUnEquipped?.Invoke(ActiveItem); } Debug.Log($"Equipped Item: {item.gameObject.name}"); item.transform.SetParent(rightHand); item.transform.localPosition = Vector3.zero; item.transform.localRotation = Quaternion.identity; ActiveItem = item; ActiveItem.gameObject.SetActive(true); ActiveItemChanged?.Invoke(ActiveItem); ItemEquipped?.Invoke(item); }
private void OnActiveItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ActiveItemChanged?.Invoke(ActiveItem); UpdateTracker(); }