/// <summary> /// Open this treasure chest, auto. closes the previous one. /// From an external call use the triggerer. Use() instead. /// </summary> protected virtual void OpenTreasureChest() { if (this != lastChest && lastChest != null) { lastChest.CloseTreasureChest(); } lastChest = this; // Set items lootWindow.SetItems(items, true); window.OnHide += window_OnHide; lootWindow.OnRemovedItem += lootWindow_OnRemovedItem; if (open == false) { window.Show(); open = true; } }
public virtual void Use(bool fireEvents = true) { if (isActive) { return; } if (handleWindowDirectly && fireEvents) { if (toggleWhenTriggered) { window.Toggle(); } else if (window.isVisible == false) { window.Show(); } } if (useAnimation != null) { animator.Play(useAnimation.name); } if (useAudioClip != null) { InventoryUIUtility.AudioPlayOneShot(useAudioClip); } isActive = true; if (OnTriggerUse != null && fireEvents) { OnTriggerUse(); } }