Exemplo n.º 1
0
        /// <summary>
        ///     Unregisters a mod handler.
        /// </summary>
        /// <returns><c>true</c>, if mod handler was unregistered, <c>false</c> otherwise.</returns>
        /// <param name="modName">Mod Name.</param>
        public bool UnregisterModHandler(string modName)
        {
            var unregistered = false;

            lock (EventLock)
            {
                if (RegisteredRawMods.ContainsKey(modName))
                {
                    RegisteredRawMods.Remove(modName);
                    unregistered = true;
                }
                if (RegisteredUpdateMods.ContainsKey(modName))
                {
                    RegisteredUpdateMods.Remove(modName);
                    UpdateQueue.Remove(modName);
                    unregistered = true;
                }
                if (RegisteredFixedUpdateMods.ContainsKey(modName))
                {
                    RegisteredFixedUpdateMods.Remove(modName);
                    FixedUpdateQueue.Remove(modName);
                    unregistered = true;
                }
            }
            return(unregistered);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Registers a mod handler function that will be called as soon as the Message is received.
 ///     This is called from the networking thread, so you should avoid interacting with KSP directly here as Unity is not
 ///     thread safe.
 /// </summary>
 /// <param name="modName">Mod Name.</param>
 /// <param name="handlerFunction">Handler function.</param>
 public bool RegisterRawModHandler(string modName, MessageCallback handlerFunction)
 {
     lock (EventLock)
     {
         if (RegisteredRawMods.ContainsKey(modName))
         {
             Debug.Log($"[LMP]: Failed to register raw mod handler for {modName}, mod already registered");
             return(false);
         }
         Debug.Log($"[LMP]: Registered raw mod handler for {modName}");
         RegisteredRawMods.Add(modName, handlerFunction);
     }
     return(true);
 }