public void Unregister(InventoryEventListener listenerToRemove) { if (gameEventListeners.Contains(listenerToRemove)) { gameEventListeners.Remove(listenerToRemove); } }
public void Register(InventoryEventListener listenerToAdd) { if (!gameEventListeners.Contains(listenerToAdd)) { gameEventListeners.Add(listenerToAdd); } }
public static void AddComponentAtRunTime(GameObject _entity, InventoryEvent _eventToReact, UnityAction <InventoryEventData> _onInvoke) { InventoryEventListener newListener = _entity.AddComponent <InventoryEventListener>(); newListener.eventToReact = _eventToReact; _eventToReact.Register(newListener); newListener.onReceiveEvent = new attachedUnityEvent(); newListener.onReceiveEvent.AddListener(_onInvoke); }
private IEnumerator WaitForPossibleSecondInventory() { yield return(StartCoroutine(InventoryEventListener.WaitForPossibleEvent(1))); if (receivedInventories[1] == null) { EnablePanels(receivedInventories[0].owner); } else { InventoryOwner nonPlayerOwner = GetNonPlayerOwner(); EnablePanels(nonPlayerOwner); } inventoryOpen = true; }
private IEnumerator DropCoroutine() { yield return(StartCoroutine(InventoryEventListener.WaitForPossibleEvent(5))); if (!dropOnItemSlot) // drop item on floor { dataInputAtStart.container.DropItemOnFloor(dataInputAtStart.itemSlot); string infoMessage = MakeDropOnFloorMessage(dataInputAtStart.itemSlot.Quantity, dataInputAtStart.itemSlot.Item.name); SendStringMessage(infoMessage); ResetPanel(); } else if (dataInputAtStart.itemSlot == dataInputAtEnd.itemSlot) // depart = destination { ResetPanel(); } else { Item itemAtStart = dataInputAtStart.itemSlot.Item; Item itemAtEnd = dataInputAtEnd.itemSlot.Item; if (itemAtEnd == null || itemAtEnd != itemAtStart) // swap itemSlot { dataInputAtStart.container.SwapItemSlot(dataInputAtStart.container, dataInputAtStart.itemSlot, dataInputAtEnd.container, dataInputAtEnd.itemSlot); ResetPanel(); } else if (itemAtEnd == itemAtStart) // stack itemSlot; { if (dataInputAtStart.container == dataInputAtEnd.container || dataInputAtStart.itemSlot.Quantity == 1) { MoveItem(dataInputAtStart.itemSlot.Quantity); } else { AskForQuantity(); } } } }