Beispiel #1
0
        /// <summary>
        /// Initializes the PLib patch bootstrapper for shared code. <b>Must</b> be called in
        /// OnLoad for proper PLib functionality.
        ///
        /// Optionally logs the mod name and version when a mod initializes.
        /// </summary>
        public static void InitLibrary(bool logVersion = true)
        {
            var assembly = Assembly.GetCallingAssembly();

            if (assembly != null)
            {
                bool needInit;
                // Check if PLib was already initialized
                lock (assembly) {
                    needInit = !PLibInit;
                    if (needInit)
                    {
                        PLibInit = true;
                    }
                }
                if (needInit)
                {
                    // Only if not already initialized
                    PRegistry.Init();
                    if (logVersion)
                    {
                        Debug.LogFormat("[PLib] Mod {0} initialized, version {1}",
                                        assembly.GetName()?.Name, assembly.GetFileVersion() ?? "Unknown");
                    }
                }
            }
            else
            {
                // Probably impossible
                Debug.LogError("[PLib] Somehow called from null assembly!");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Logs the mod name and version when a mod initializes. Also initializes the PLib
        /// patch bootstrapper for shared code.
        ///
        /// <b>Must</b> be called in Mod_OnLoad for proper PLib functionality.
        /// </summary>
        public static void LogModInit()
        {
            var assembly = Assembly.GetCallingAssembly();

            if (assembly != null)
            {
                PRegistry.Init();
                Debug.LogFormat("[PLib] Mod {0} initialized, version {1}",
                                assembly.GetName()?.Name, assembly.GetFileVersion() ?? "Unknown");
            }
            else
            {
                // Probably impossible
                Debug.LogError("[PLib] Somehow called from null assembly!");
            }
        }