Esempio n. 1
0
 private void DetachEvents(PluginEvents eventHandlers)
 {
     if (eventHandlers.GameLoading != null)
     {
         GameLoading -= eventHandlers.GameLoading;
     }
     if (eventHandlers.GameLoaded != null)
     {
         GameLoaded -= eventHandlers.GameLoaded;
     }
     if (eventHandlers.GameSaving != null)
     {
         GameSaving -= eventHandlers.GameSaving;
     }
     if (eventHandlers.GameSaved != null)
     {
         GameSaved -= eventHandlers.GameSaved;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Plugins call this to register for plugin events.  Typically it will
        /// be called in the plugin's InitializePlugin method.  If a particular
        /// event is not needed it can be left null in the PluginEvents structure.
        /// </summary>
        public void RegisterPlugin(IPlugin plugin, PluginEvents eventHandlers)
        {
            // Store a list of the event handlers so they can be detached later
            pluginEventTable.Add(plugin, eventHandlers);

            if (eventHandlers.GameLoading != null)
            {
                GameLoading += eventHandlers.GameLoading;
            }
            if (eventHandlers.GameLoaded != null)
            {
                GameLoaded += eventHandlers.GameLoaded;
            }
            if (eventHandlers.GameSaving != null)
            {
                GameSaving += eventHandlers.GameSaving;
            }
            if (eventHandlers.GameSaved != null)
            {
                GameSaved += eventHandlers.GameSaved;
            }
        }