public Action <IRoom> this[RoomEventType eventType]
    {
        get
        {
            if (isActiveAndEnabled)
            {
                if (_actions == null)
                {
                    _actions = new EnumActionDictionary <RoomEventType, IRoom>();
                    foreach (var listener in _roomEventsListeners.GetCachedComponets <IRoomEventListener>())
                    {
                        foreach (var roomEvent in StructsExtentions.GetEnumValues <RoomEventType>())
                        {
                            if (listener[roomEvent] != null)
                            {
                                _actions[roomEvent] += listener[roomEvent];
                            }
                        }
                    }
                }

                return(_actions[eventType]);
            }
            return(null);
        }
    }
Exemple #2
0
 private void CreateDictionary()
 {
     if (!_onActionsCreated)
     {
         _dictionary = new EnumActionDictionary <RoomEventType, IRoom>();
         FillDictionary(RoomEventType.OnOpen, _onOpenCommands);
         FillDictionary(RoomEventType.OnClosed, _onCloseCommands);
         _onActionsCreated = true;
     }
 }
    public RoomEventListenerCollector(bool listenAllRooms, IEnumerable <IRoomEventListener> listeners)
    {
        ShouldListenAllRooms = listenAllRooms;

        _actions = new EnumActionDictionary <RoomEventType, IRoom>();

        foreach (var listener in listeners)
        {
            foreach (var key in StructsExtentions.GetEnumValues <RoomEventType>())
            {
                if (listener[key] != null)
                {
                    _actions[key] += listener[key];
                }
            }
        }
    }