Esempio n. 1
0
 /// <summary>
 ///   Deinitialize this context, i.e. removing from all registered events.
 /// </summary>
 public virtual void Deinit()
 {
     // Clear event handlers.
     if (this.EventManager != null)
     {
         foreach (var gameEvent in this.events)
         {
             this.EventManager.RemoveListener(gameEvent.Key, gameEvent.Value);
         }
         this.EventManager = null;
         this.EntityManager = null;
     }
 }
Esempio n. 2
0
        /// <summary>
        ///   Sets up the connection to the client logic.
        /// </summary>
        /// <param name="eventManager">Event manager to communicate with the client logic.</param>
        /// <param name="entityManager">Entity manager to access data from client logic.</param>
        public virtual void Init(EventManager eventManager, EntityManager entityManager)
        {
            // Setup event callbacks.
            this.EventManager = eventManager;
            this.EntityManager = entityManager;

            if (this.EventManager != null)
            {
                this.SetEventListeners();
            }

            if (this.EventManager != null)
            {
                foreach (var gameEvent in this.events)
                {
                    this.EventManager.RegisterListener(gameEvent.Key, gameEvent.Value);
                }
            }
        }
 public ProcessManager(EntityManager entityManager, EventManager eventManager)
 {
     this.entityManager = entityManager;
     this.eventManager = eventManager;
 }
Esempio n. 4
0
 /// <summary>
 ///   Initializes this process.
 /// </summary>
 public virtual void InitProcess(EntityManager entityManager, EventManager eventManager)
 {
     this.EntityManager = entityManager;
     this.EventManager = eventManager;
 }
Esempio n. 5
0
 /// <summary>
 ///   Registers for the specified event at any future FreudBot games that might start.
 /// </summary>
 /// <param name="eventType">Type of the event to register for.</param>
 /// <param name="callback">Method to call when the event is raised.</param>
 protected void RegisterListener(object eventType, EventManager.EventDelegate callback)
 {
     this.events.Add(eventType, callback);
 }
            public override void InitProcess(EntityManager entityManager, EventManager eventManager)
            {
                base.InitProcess(entityManager, eventManager);

                this.Initialized = true;
            }
Esempio n. 7
0
 /// <summary>
 ///   Registers the passed callback for events with the specified key.
 /// </summary>
 /// <param name="eventKey">Key of the events to register to callback for.</param>
 /// <param name="callback">Callback to register.</param>
 protected void SetEventListener(object eventKey, EventManager.EventDelegate callback)
 {
     this.events.Add(eventKey, callback);
 }
 /// <summary>
 ///   Sets the passed callback for events with the specified key.
 ///   The callback will automatically be added on enable, and removed on disable.
 /// </summary>
 /// <param name="eventKey">Key of events to set the callback for.</param>
 /// <param name="callback">Callback to automatically add on enable, and remove on disable.</param>
 protected virtual void SetListener(object eventKey, EventManager.EventDelegate callback)
 {
     this.listeners.Add(eventKey, callback);
 }
        protected virtual void OnGameChanged(Game newGame, Game oldGame)
        {
            // Remove listeners from old event manager.
            this.RemoveListeners();

            // Get new event manager.
            this.EventManager = newGame.EventManager;

            // Add listeners to new event manager.
            this.AddListeners();
        }