コード例 #1
0
ファイル: KK_FBIOpenUp.Unity.cs プロジェクト: jallex1515/KK
 /// <summary>
 /// 切換紅色書包圖標顯示
 /// </summary>
 private static void ChangeRedBagBtn(GameObject redBagBtn)
 {
     if (KK_FBIOpenUp._isenabled)
     {
         redBagBtn.GetComponent <Image>().color = new Color(1f, 1f, 1f, 1f);
         Logger.LogInfo("Enable Plugin");
     }
     else
     {
         redBagBtn.GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.3f);
         Logger.LogInfo("Disable Plugin");
     }
 }
コード例 #2
0
        public override void Load()
        {
            try {
                Logger = Log;
                GameOptionsData.RecommendedImpostors = GameOptionsData.MaxImpostors = Enumerable.Repeat <int>(255, 255).ToArray <int>();
                Logger.LogMessage("Patching harmony...");
                Logger.LogInfo("Succesfully loaded CorsacHats");

                Attribute[] attrs = Attribute.GetCustomAttributes(typeof(MyHats.HatManagerHatsPatch));

                foreach (Attribute attr in attrs)
                {
                    Logger.LogMessage($"Looking {attr.GetType()}");
                }
                if (attrs.Length == 0)
                {
                    Logger.LogError("HarmonyPatchers not found.");
                }
                _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
                Logger.LogMessage($"Is patched? {Harmony.HasAnyPatches(_harmony.Id)}");
            }
            catch (Exception e) {
                Log.LogError(e);
                throw e;
            }
        }
コード例 #3
0
        internal void Awake()
        {
            this.FPSBoost();

            try
            {
                if (FindObjectsOfType <ModEntryPoint>().Length > 1)
                {
                    Logger.LogWarning(string.Format("Another instance of {0} was instantiated. Will destroy this: {1}",
                                                    typeof(ModEntryPoint),
                                                    gameObject.GetInstanceID()
                                                    ));
                    DestroyImmediate(this);
                }
                else
                {
                    new Harmony(MOD_GUID).PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
                    Logger.LogInfo("Successfully patched via Harmony.");
                }
            }
            catch (Exception arg)
            {
                Logger.LogError(string.Format("Failed to patch via Harmony. Error: {0}", arg));
            }
        }
コード例 #4
0
        private ModEntryPoint()
        {
            instant3DMark = base.Config.Bind("General", "Instant3DMark", true, "Instant 3DMark");
            autoFPSBoost  = base.Config.Bind("General", "AutoFPSBoost", true, "Auto FPS Boost");

            Logger = base.Logger;
            Logger.LogInfo("ModEntryPoint loaded");
        }
コード例 #5
0
        public void init(BaseUnityPlugin mod, bool defaultBindServerAuthority = false)
        {
            _mod = mod;
            //logger
            Logger = new BepInEx.Logging.ManualLogSource(RPC_SYNC_GUID);
            BepInEx.Logging.Logger.Sources.Add(Logger);

            _configEntries         = new Dictionary <string, ConfigBaseEntry>();
            _DefaultBindAuthority  = defaultBindServerAuthority;
            _ServerIsAuthoritative = _mod.Config.Bind("ServerAuthoritativeConfig", "ServerIsAuthoritative", true, "<Server Only> Forces Clients to use Server defined configs.");
            Harmony.CreateAndPatchAll(typeof(Config));
            Logger.LogInfo("Initialized Server Authoritative Config Manager.");
        }
コード例 #6
0
        public static Exception SettingDoFinalizer(ADV.EventCG.Data ___data, string[] ___args, Exception __exception, Setting __instance)
        {
            if (HS2ChicksDigMapModdersPlugin.EnableDebugLogging.Value)
            {
                Log.LogInfo($"Setting.Do {string.Join(",", ___args)}");
                Log.LogInfo($"Data {___data}");
                if (__exception != null)
                {
                    Log.LogInfo($"Exception Thrown: {__exception.Message} {__exception.StackTrace} ");
                }
            }

            if (___data == null)
            {
                GameObject dataGo   = new GameObject("MapData", new Type[] { typeof(ADV.EventCG.Data) });
                GameObject camPosGo = new GameObject("camPos", new Type[] { typeof(ADV.EventCG.CameraData) });
                camPosGo.transform.parent = dataGo.transform;
                ___data = dataGo.GetComponent <ADV.EventCG.Data>();
                bool hasNo = int.TryParse(___args[2], out int no);
                if (hasNo)
                {
                    Transform transform  = ___data.transform;
                    Transform transform2 = __instance.scenario.commandController.GetChara(no).backup.transform;
                    transform.position += transform2.position;
                    transform.rotation *= transform2.rotation;
                }

                ___data.camRoot = __instance.scenario.advScene.advCamera.transform;
                ___data.SetChaRoot(__instance.scenario.commandController.Character, __instance.scenario.commandController.Characters);
                ___data.Next(0, __instance.scenario.commandController.Characters);

                if (HS2ChicksDigMapModdersPlugin.EnableDebugLogging.Value)
                {
                    Log.LogInfo($"Created Data {___data}");
                }
            }
            return(null);
        }
コード例 #7
0
 public void IncreaseBaseStats()
 {
     foreach (string bodyName in new string[] { "CommandoBody", "ToolbotBody", "HuntressBody", "EngiBody", "MageBody", "MercBody", "TreebotBody", "LoaderBody", "CrocoBody", "CaptainBody" })
     {
         GameObject obj = Resources.Load <GameObject>($"Prefabs/CharacterBodies/{bodyName}");
         if (obj)
         {
             CharacterBody body = obj.GetComponent <CharacterBody>();
             if (body)
             {
                 body.baseMoveSpeed = 10f; // Default is 7
             }
             else
             {
                 pluginLogger.LogInfo("The prefab loaded has no character body");
             }
         }
         else
         {
             pluginLogger.LogInfo("That is not a valid prefab");
         }
     }
 }
コード例 #8
0
ファイル: TextPlugin.cs プロジェクト: jallex1515/KK
        /// <summary>
        /// 建立動態字體字典,如果總數超過500則用到時再生成,否則一次建立完畢
        /// </summary>
        /// <returns>字典內已生成的字體總數</returns>
        internal static int CreateDynamicFonts()
        {
            DynamicFonts.Clear();
            List <string> fontlist = Font.GetOSInstalledFontNames().ToList();

            for (int i = 0; i < fontlist.Count; i++)
            {
                if (i > 0 && fontlist[i].Replace("Bold", "").Replace("Italic", "").TrimEnd().Equals(fontlist[i - 1]))
                {
                    fontlist.RemoveAt(i);
                    i--;
                    continue;
                }
            }
            FontList = fontlist.ToArray();
            if (fontlist.Count >= 500)
            {
                DynamicFonts.Add("Arial", Resources.GetBuiltinResource <Font>("Arial.ttf"));
                Logger.LogInfo($"Detact {fontlist.Count} fonts in your system.");
                Logger.LogInfo($"Based on Unity's limitations, this number is more than that can be generated.");
                Logger.LogInfo($"I am sorry to tell you that I have to disable your fonts preview.");
            }
            else
            {
                DisablePreview = false;
                if (fontlist.Remove("Arial"))
                {
                    DynamicFonts.Add("Arial", Resources.GetBuiltinResource <Font>("Arial.ttf"));
                }
                foreach (var fontName in fontlist)
                {
                    DynamicFonts.Add(fontName, Font.CreateDynamicFontFromOSFont(new string[] { fontName, "Arial" }, 30));
                }
                Logger.LogInfo($"Generate {DynamicFonts.Count} System Fonts");
            }
            return(DynamicFonts.Count);
        }
コード例 #9
0
 private static void RegisterSyncConfigRPC()
 {
     Logger.LogInfo($"Authoritative Config Registered -> {Config.RPC_SYNC_GUID}");
     ZRoutedRpc.instance.Register(Config.RPC_SYNC_GUID, new Action <long, ZPackage>(Config.RPC_SyncServerConfig));
     //clear server values
     foreach (ConfigBaseEntry entry in Config.Instance._configEntries.Values)
     {
         entry.ClearServerValue();
     }
 }
コード例 #10
0
        public override void Load()
        {
            log.LogInfo("loaded Love Couple Mod");
            Name = Config.Bind("Custom", "Name", "Custom");
            Ip   = Config.Bind("Custom", "Ipv4 or Hostname", "127.0.0.1");
            Port = Config.Bind("Custom", "Port", (ushort)22023);

            var defaultRegions = ServerManager.DefaultRegions.ToList();
            var ip             = Ip.Value;

            if (Uri.CheckHostName(Ip.Value).ToString() == "Dns")
            {
                log.LogMessage("Resolving " + ip + " ...");
                try
                {
                    foreach (IPAddress address in Dns.GetHostAddresses(Ip.Value))
                    {
                        if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            ip = address.ToString(); break;
                        }
                    }
                }
                catch
                {
                    log.LogMessage("Hostname could not be resolved" + ip);
                }

                log.LogMessage("IP is " + ip);
            }


            var port = Port.Value;


            defaultRegions.Insert(defaultRegions.Count, new StaticRegionInfo(
                                      Name.Value, (StringNames)CustomStringNames.CustomServerName, ip, new[]
            {
                new ServerInfo($"{Name.Value}-Master-1", ip, port)
            }).Duplicate()
                                  );

            ServerManager.DefaultRegions = defaultRegions.ToArray();

            this.harmony.PatchAll();
        }
コード例 #11
0
 void Awake()
 {
     isEnabled           = Config.Bind("General.Toggles", "EnableFilter", true, "Whether or not to filter the chat.");
     wrapWords           = Config.Bind("General.Toggles", "WrapWords", true, "Whether or not to wrap around words.");
     replaceKey          = Config.Bind("General", "ReplaceKey", "*", "Symbol to censor words with.");
     addCustomWords      = Config.Bind("Filtering.Toggles", "AddCustomWords", false, "Add your own custom words.");
     customWordsFilename = Config.Bind("Filtering", "CustomWordsFilename", "customAdd.filter", "Filename where custom words to add are.");
     removeWords         = Config.Bind("Filtering.Toggles", "RemoveWords", false, "Remove certain words from filters.");
     removeWordsFilename = Config.Bind("Filtering", "RemoveWordsFilename", "customRemove.filter", "Filename where words to remove from filter are.");
     harmony             = new Harmony(ID);
     harmony.PatchAll();
     chatFilterLogger = Logger;
     FamilyFriendlyfier.Initialise();
     if (addCustomWords.Value)
     {
         string[] wordsToAdd = FamilyFriendlyfier.GetWordsFromFile(customWordsFilename.Value);
         if (wordsToAdd != null)
         {
             FamilyFriendlyfier.filter.AddProfanity(wordsToAdd);
         }
     }
     if (removeWords.Value)
     {
         string[] wordsToRemove = FamilyFriendlyfier.GetWordsFromFile(removeWordsFilename.Value);
         if (wordsToRemove != null)
         {
             foreach (string word in wordsToRemove)
             {
                 if (FamilyFriendlyfier.filter.IsProfanity(word))
                 {
                     FamilyFriendlyfier.filter.RemoveProfanity(word);
                 }
             }
         }
     }
     chatFilterLogger.LogInfo("This server is using VPlusChatFilter.");
 }
コード例 #12
0
        private static IEnumerable <string> TellBepinAbsolutelyNothingBecauseThePluginsFolderIsntManaged()
        {
            Logger.LogInfo($"Collecting information for new MMHook");
            string oldHash      = null;
            int    modsWithRefs = 0;

            foreach (string path in PluginPaths)
            {
                foreach (var pluginDll in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories))
                {
                    try
                    {
                        using (var ass = AssemblyDefinition.ReadAssembly(pluginDll))
                        {
                            if (ass.Name.Name == "MMHOOK_Assembly-CSharp")
                            {
                                oldHash = CollectHash(ass);

                                mmhLocation = pluginDll;
                                continue;
                            }
                            foreach (var refer in ass.MainModule.AssemblyReferences)
                            {
                                if (refer.Name == "MMHOOK_Assembly-CSharp")
                                {
                                    CollectMethodDefinitions(ass);
                                    modsWithRefs++;
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception e) { Logger.LogError($"Error on: {pluginDll}"); Logger.LogError(e); }
                }
            }

            if (mmhLocation == null)
            {
                Logger.LogMessage("No MMHOOK found. I can't make lighter what's already 0.");
                return(Array.Empty <string>());
            }

            if (modsWithRefs == 0)
            {
                Logger.LogMessage("No plugins to patch MMHook for.");
                mmhLocation = null;
                return(Array.Empty <string>());
            }


            Logger.LogMessage($"Found {modsWithRefs} mods with a MMHook dependency.");
            Logger.LogInfo($"Number of neededtypes for hooks : {neededTypes.Count}");
            neededTypes.Sort();
            hash = neededTypes.MakeContentHashCode();

            if (oldHash == hash.ToString())
            {
                Logger.LogMessage($"LighterhHook has already run for these mods. Using that old file again.");
                mmhLocation = null;
            }
            else
            {
                if (oldHash == null)
                {
                    Logger.LogDebug("Backing up vanilla MMHook");
                    File.Delete(mmhLocation + ".backup");
                    File.Move(mmhLocation, mmhLocation + ".backup");
                }
            }

            return(Array.Empty <string>());
        }
コード例 #13
0
ファイル: Tempest.cs プロジェクト: antjowie/Tempest
        public void Awake()
        {
            ModLogger = this.Logger;

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Tempest.tempest_assets"))
            {
                MainAssets = AssetBundle.LoadFromStream(stream);
            }

            //ModLogger.LogInfo("----------------------ASSETS--------------------");
            //foreach (var asset in MainAssets.GetAllAssetNames())
            //{
            //    ModLogger.LogMessage(asset);
            //}

            if (Helpers.InDebugMode())
            {
                ModLogger.LogWarning("Tempest has been compiled in debug mode!");
            }

            ModLogger.LogInfo("----------------------SYSTEMS--------------------");
            var SystemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseSystem)));

            foreach (var systemType in SystemTypes)
            {
                BaseSystem system = (BaseSystem)System.Activator.CreateInstance(systemType);

                if (!Helpers.InDebugMode() && system.StripFromRelease)
                {
                    ModLogger.LogWarning("System: " + systemType.Name + " stripped from release!");
                    continue;
                }

                system.Init(this);
                ModLogger.LogInfo("System: " + systemType.Name + " initialized!");
            }

            ModLogger.LogInfo("----------------------ITEMS--------------------");
            var ItemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseItem)));

            foreach (var itemType in ItemTypes)
            {
                BaseItem item = (BaseItem)System.Activator.CreateInstance(itemType);
                if (ValidateItem(item, Items))
                {
                    item.Init(Config);
                    CustomItems.Add(item.ItemDef.name, item.ItemDef);
                    ModLogger.LogInfo("Item: " + item.ItemName + " initialized!");
                }
                else
                {
                    ModLogger.LogWarning("Item: " + item.ItemName + " disabled!");
                }
            }

            ModLogger.LogInfo("----------------------EQUIPMENT--------------------");
            var EquipmetTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(BaseEquipment)));

            foreach (var EquipmetType in EquipmetTypes)
            {
                BaseEquipment equipment = (BaseEquipment)System.Activator.CreateInstance(EquipmetType);
                equipment.Init(Config);

                ModLogger.LogInfo("Equpment: " + equipment.EquipmentName + " initialized!");
            }

            ModLogger.LogInfo("----------------------TEMPEST DONE--------------------");
        }
コード例 #14
0
 void Awake()
 {
     log = Logger;
     log.LogInfo("Zoomies mod initiated");
     harmony.PatchAll();
 }
コード例 #15
0
ファイル: ModEntryPoint.cs プロジェクト: Heyter/MDT2
 private ModEntryPoint()
 {
     Logger = base.Logger;
     Logger.LogInfo("ModEntryPoint loaded");
 }