Log() public method

public Log ( string text ) : void
text string
return void
Beispiel #1
0
        public string LoginString(string url)
        {
            FileLog.Log($"LoginString Requset {url}");
            var newurl = url + "&fun=new&version=v2";
            var client = new AsyncHttpClient().UserAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
                         .Header("Accept-Encoding", "gzip,deflate,br")
                         .Header("Accept-Language", "zh-CN,zh;q=0.9")
                         .Header("Accept", "application/json, text/plain, */*")
                         .Header("Connection", "keep-alive")
                         .Header("Host", "wx2.qq.com").Cookies(cookieContainer)
                         .AutomaticDecompression(DecompressionMethods.Deflate | DecompressionMethods.GZip)
                         .Referer("https://wx2.qq.com/").Url(newurl);
            var response = client.Get().Result;
            var str      = response.GetString();

            FileLog.Log($"GetString Response {str}");
            return(str);
        }
Beispiel #2
0
 public static async void LogDebug(object line)
 {
     try
     {
         if (!Settings.Debug)
         {
             return;
         }
         using (var writer = new StreamWriter(LogFilePath, true))
         {
             await writer.WriteLineAsync($"{GetFormattedStartupTime()}  {line}");
         }
     }
     catch (Exception ex)
     {
         FileLog.Log(ex.ToString());
     }
 }
Beispiel #3
0
        private void client_Disconnected(object sender, EventArgs e)
        {
            Log <Peer> .Logger.FatalFormat("{0} Disconnected to {1}", this.LocalEndPoint, this.RemoteEndPoint);

            FileLog.Log("Peer.log", string.Format("{0} Disconnected to {1}", this.LocalEndPoint, this.RemoteEndPoint));
            this.connected = false;
            while (this.pipes.Count > 0)
            {
                foreach (Pipe pipe in new LinkedList <Pipe>(this.pipes.Values))
                {
                    pipe.Close();
                }
            }
            if (this.Disconnected != null)
            {
                this.Disconnected(this);
            }
        }
Beispiel #4
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                FileLog.Log("Running patch " + MethodBase.GetCurrentMethod().DeclaringType);
                Lib.seekAndPatchCubeSelect(codes);
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
        internal static MethodBase TargetMethod()
        {
            var compilation = AccessTools.TypeByName("Oxide.Plugins.Compilation, Oxide.CSharp");

            if (compilation == null)
            {
                FileLog.Log("[OxideNoLimit] Can't find Compilation type. Not patched.");
                return(null);
            }
            var target = AccessTools.Method(compilation, "PreparseScript", new[] { typeof(CompilablePlugin) });

            if (target == null)
            {
                FileLog.Log("[OxideNoLimit] Can't find PreparseScript method. Not patched.");
                return(null);
            }
            return(target);
        }
Beispiel #6
0
 public static void LoadDelegates()
 {
     try
     {
         if (!AccessExtensionPatcher.GetDelegateFromAssembly("CustomUnits", "CustomUnits.SimGameState_AddMech", "GetFirstFreeMechBay", ref GetFirstFreeMechBay, null, null, SimpleMechAssembly_Main.Log.Log))
         {
             if (SimpleMechAssembly_Main.Settings.FakeVehilceTag != null)
             {
                 SimpleMechAssembly_Main.Log.LogWarning("warning: SMA FakeVehilceTag is set, but CustomUnits is missing. unsetting it now.");
                 SimpleMechAssembly_Main.Settings.FakeVehilceTag = null;
             }
         }
     }
     catch (Exception e)
     {
         FileLog.Log(e.ToString());
     }
 }
Beispiel #7
0
        public static bool Prefix(AcidDamageEffect __instance, DamageAccumulation accum, IDamageReceiver recv, Vector3 damageOrigin, Vector3 impactForce, CastHit impactHit)
        {
            try
            {
                if (!Mod.Settings.Acid)
                {
                    return(true);
                }
                var currentArmor = recv.GetArmor().Value;
                var hasArmor     = currentArmor > 0;
                var totalDamage  = accum.Amount * accum.SourceMultiplier;
                var armorDamage  = 0f;
                if (hasArmor)
                {
                    armorDamage = Math.Min(totalDamage, currentArmor);
                }


                var healthDamage = totalDamage - armorDamage;
                //FileLog.Log($"({accum.Amount} * {accum.SourceMultiplier}) hit on {recv.GetDisplayName()}\ncurrentArmor {currentArmor}\ntotalDamage {totalDamage}\narmorDamage {armorDamage}\nhealthDamage {healthDamage}");
                var data = new DamageAccumulation.TargetData
                {
                    Target        = recv,
                    AmountApplied = totalDamage,
                    DamageResult  = new DamageResult
                    {
                        Source        = __instance.Source,
                        ArmorDamage   = armorDamage,
                        HealthDamage  = healthDamage,
                        ImpactForce   = impactForce,
                        ImpactHit     = impactHit,
                        DamageOrigin  = damageOrigin,
                        DamageTypeDef = __instance.AcidDamageEffectDef.DamageTypeDef
                    }
                };
                accum.AddGeneratedTarget(data);
            }
            catch (Exception e)
            {
                FileLog.Log(e.ToString());
            }

            return(false);
        }
Beispiel #8
0
        public static void ModifyArea(scriptEncounterArea __instance)
        {
            try
            {
                List <string> monsterlist = new List <string>();
                monsterlist.AddRange(VoidConstants.MODENCOUNTERS.GetValueSafe(__instance.title));

                for (int i = 0; i < __instance.monsters.Count() - 1; i++)
                {
                    monsterlist.Add(__instance.monsters[i]);
                }
                GameObject global = GameObject.FindGameObjectWithTag("Global");

                if (Harmony.DEBUG)
                {
                    FileLog.Log("Anzahl Sprites: " + global.GetComponent <scriptMonsters>().dSprites.Length);
                    foreach (Sprite ds in global.GetComponent <scriptMonsters>().dSprites)
                    {
                        FileLog.Log("Sprite Name: " + ds.name);
                    }
                }



                GameObject player = GameObject.FindGameObjectWithTag("Player");
                player.GetComponent <scriptOWPlayer>().SetEncounterData(
                    __instance.canEncounter,   // Boolean to determine if monsters can spawn
                    monsterlist.ToArray(),     // List of monsters that are supposed to spawn
                    __instance.levelMin,       // Minimum level of wild monsters
                    __instance.levelMax,       // Maximum level of wild monsters
                    __instance.encounterDelay, // Not sure. Either the delay between the monster spawning and beginning to act or the timer inbetween spawns
                    __instance.uMonID,         // ID of the wild crossbreed
                    __instance.uMonVar,        // Crossbreed Variant
                    __instance.uMonPal);       // Color Palette of the variant
            }
            catch (Exception e)
            {
                FileLog.Log("Titel: " + __instance.title);
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.InnerException.Message);
                FileLog.Log(e.InnerException.StackTrace);
            }
        }
Beispiel #9
0
        internal static MethodBase TargetMethod()
        {
            MethodBase target             = null;
            var        targetDelegateType = AccessTools.FirstInner(typeof(CompiledAssembly), typ =>
            {
                if (!typ.IsClass || !typ.IsDefined(typeof(CompilerGeneratedAttribute), false) || AccessTools.Field(typ, "patchModuleType") == null)
                {
                    return(false);
                }
                return((target = GetSandboxMethod(typ)) != null);
            });

            if (targetDelegateType != null)
            {
                return(target);
            }
            FileLog.Log("[OxideNoLimit] Can't find target in CompiledAssembly. Not patched.");
            return(null);
        }
Beispiel #10
0
        internal static void LogDebug(object input)
        {
            /*if (modSettings.CombatLog)
             * {
             *  try
             *  {
             *      using (var writer = new StreamWriter(LogFilePath, true))
             *      {
             *          writer.WriteLine($" {input ?? "null"}");
             *      }
             *  }
             *  catch (Exception ) { }
             * }*/

            if (modSettings.Debug)
            {
                FileLog.Log($"[PanicSystem] {input ?? "null"}");
            }
        }
Beispiel #11
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Call, "CubeHelper", "IsReinforced", false, new Type[] { typeof(ushort) });
                FileLog.Log("Running patch, which found instruction " + InstructionHandlers.toString(codes, loc));
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.Cryopathy.CryopathyMod", "shouldAvoidBlock", false, typeof(ushort));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
        public override void Init()
        {
            base.Init();
            OLogger.CreateLog(new Rect(400, 400, 400, 400), "Default", true, true);
            //OLogger.Log("OnInit()");
            //FileLog.Log("OnInit()");
            outwardItemOverrides = new List <OutwardItemOverrides>();
            xmlConfigHelper      = new XMLConfigHelper();

            // Load our configuration files
            try
            {
                xmlConfigHelper.Init();
                //OLogger.Log("xmlConfig Init called");
                //FileLog.Log("xmlConfig Init called");
                // Deserialize our XML to C# classes and objects directly, the parameter is the XMLRootAttribute, aka Document Root.
                outwardItemOverrides = xmlConfigHelper.GetConfigData();

                // Reads the order date.
                if (outwardItemOverrides.Count > 0)
                {
                    OLogger.Log("Sucessfully read the configuration file contents.");
                    FileLog.Log("Sucessfully read the configuration file contents.");
                }
                else
                {
                    OLogger.Log("Failed to read the configuration file contents.");
                    FileLog.Log("Failed to read the configuration file contents.");
                }
            }
            catch (Exception e)
            {
                // Prob a bad idea, but kept for now
                OLogger.Log("Exception called :( ");
                FileLog.Log("Exception called :( ");
                OLogger.Log(e.Message);
                FileLog.Log(e.Message);
                OLogger.Log(e.ToString());
                FileLog.Log(e.ToString());
                throw e;
            }
        }
Beispiel #13
0
        public static void DumpData(SimGameState s)
        {
            string last = "";

            try
            {
                string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                using (StreamWriter w = new StreamWriter(dir + "\\BTDump.txt", false))
                {
                    w.WriteLine("BTDumper: " + s.CompanyName + " " + s.CurrentDate.ToString("dd-MM-yyyy"));
                    w.WriteLine();
                    using (StreamWriter mcsv = new StreamWriter(dir + "\\BTDumpMechs.csv", false))
                    {
                        DumpMechs(s, w, mcsv, out last);
                    }
                    w.WriteLine();
                    using (StreamWriter wcsv = new StreamWriter(dir + "\\BTDumpWeapons.csv", false))
                    {
                        DumpWeapons(s, w, wcsv, out last);
                    }
                    w.WriteLine();
                    using (StreamWriter acsv = new StreamWriter(dir + "\\BTDumpAmmo.csv", false))
                    {
                        DumpAmmo(s, w, acsv, out last);
                    }
                    w.WriteLine();
                    using (StreamWriter ucsv = new StreamWriter(dir + "\\BTDumpUpgrades.csv", false))
                    {
                        DumpUpgrades(s, w, ucsv, out last);
                    }
                    using (StreamWriter vcsv = new StreamWriter(dir + "\\BTDumpVehicles.csv", false))
                    {
                        DumpVehicles(s, null, vcsv, out last);
                    }
                }
            }
            catch (Exception e)
            {
                FileLog.Log(last);
                FileLog.Log(e.ToString());
            }
        }
 public static void Prefix(SimGameDifficulty __instance, bool force, SimGameState ___simState, SimGameDifficulty.DifficultySetting setting, int index,
                           Dictionary <string, int> ___difficultyIndices,
                           ref List <SimGameDifficulty.DifficultyConstantValue> __state)
 {
     __state = null;
     if (setting == null)
     {
         return;
     }
     if (!force && ___difficultyIndices[setting.ID] == index)
     {
         return;
     }
     if (index >= setting.Options.Count)
     {
         return;
     }
     if (!setting.Enabled)
     {
         return;
     }
     try
     {
         SimGameDifficulty.DifficultyOption opt = setting.Options[index];
         if (opt.DifficultyConstants != null)
         {
             __state = opt.DifficultyConstants;
             foreach (SimGameDifficulty.DifficultyConstantValue v in opt.DifficultyConstants)
             {
                 if (v.ConstantType.Equals("AdditionalSettings"))
                 {
                     DifficultyOptionsMain.ApplySettings(___simState, setting.ID, v.ConstantName, v.ConstantValue);
                 }
             }
             opt.DifficultyConstants = opt.DifficultyConstants.Where((x) => !x.ConstantType.Equals("AdditionalSettings")).ToList();
         }
     }
     catch (Exception e)
     {
         FileLog.Log(e.ToString());
     }
 }
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            var harmony = new Harmony("top.hirtol.patch.partyenhancements");

            harmony.PatchAll();

            try
            {
                Directories.Initialize();
                Logging.Initialise();
                PartyScreenConfig.Initialize();
            }
            catch (Exception e)
            {
                FileLog.Log($"PSE Config Load Exception: {e}");
            }

            //UIResourceManager.UIResourceDepot.StartWatchingChangesInDepot();
        }
Beispiel #16
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Callvirt, "MobManager", "SpawnMob", true, new Type[] { typeof(MobType), typeof(Segment), typeof(long), typeof(long), typeof(long), typeof(Vector3), typeof(Vector3) });
                FileLog.Log("Running patch, which found instruction " + InstructionHandlers.toString(codes, loc));
                codes[loc].opcode  = OpCodes.Call;
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.Cryopathy.CryopathyMod", "onMobAttemptSpawn", false, typeof(MobManager), typeof(MobType), typeof(Segment), typeof(long), typeof(long), typeof(long), typeof(Vector3), typeof(Vector3));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
 protected override void InsertItem(int index, SettlementNameplateVM item)
 {
     try
     {
         bool flag = item != null;
         if (flag)
         {
             Traverse                   traverse = Traverse.Create(item);
             GameEntity                 value    = traverse.Field <GameEntity>("_entity").Value;
             Camera                     value2   = traverse.Field <Camera>("_mapCamera").Value;
             Action <Vec2, float>       value3   = traverse.Field <Action <Vec2, float> >("_fastMoveCameraToPosition").Value;
             SettlementIconsNameplateVM item2    = new SettlementIconsNameplateVM(item.Settlement, value, value2, value3);
             base.InsertItem(index, item2);
         }
     }
     catch (Exception ex)
     {
         FileLog.Log(ex.ToString());
     }
 }
Beispiel #18
0
        static void Main(string[] args)
        {
            try
            {
                if (args == null || args.Length <= 0)
                {
                    ILog log = new FileLog();
                    log.Log("The agrument is null");
                }
                else
                {
                    string fileName = string.Empty;

                    IGetFileName getFileName = new FileName();
                    fileName = getFileName.GetFileName(args[0]);

                    List <Name> nameList = new List <Name>();
                    IReadLine   readline = new Readline();
                    nameList = readline.ReadLine(fileName);

                    List <Name> sortedNameList = new List <Name>();
                    ISortName   sortName       = new SortName();
                    sortedNameList = sortName.Sort(nameList);

                    IPrintName printName = new PrintName();
                    printName.PrintNameToScreen(sortedNameList);

                    IWriteNameToFile writeNameToFile = new WriteNameToFile();
                    writeNameToFile.WriteName(sortedNameList);

                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(ex.Message);
                ILog log = new FileLog();
                log.Log("The file could not be read:" + ex);
            }
        }
Beispiel #19
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                FileLog.Log("Running patch " + MethodBase.GetCurrentMethod().DeclaringType);
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Call, "CubeHelper", "IsCubeGlass", true, new Type[] { typeof(int) });
                FileLog.Log("Found match at pos " + InstructionHandlers.toString(codes, loc));
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.FortressTweaks.FortressTweaksMod", "isCubeGlassForRoom", false, new Type[] { typeof(ushort), typeof(RoomController) });
                codes.Insert(loc, new CodeInstruction(OpCodes.Ldarg_0));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
Beispiel #20
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Callvirt, "Segment", "GetCube", true, new Type[] { typeof(long), typeof(long), typeof(long) });
                FileLog.Log("Running patch, which found instruction " + InstructionHandlers.toString(codes, loc));
                codes[loc].opcode  = OpCodes.Call;
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.Cryopathy.CryopathyMod", "getCubeForCryoCheckAt", false, typeof(Segment), typeof(long), typeof(long), typeof(long), typeof(ushort));
                codes.Insert(loc, new CodeInstruction(OpCodes.Ldloc_1));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
Beispiel #21
0
        public static void Postfix(GeoMission mission)
        {
            try
            {
                if (!Mod.Settings.Regeneration)
                {
                    return;
                }
                //FileLog.Log(mission.Squad.Soldiers.Count().ToString());
                foreach (var phoenixFactionSoldier in mission.Squad.Soldiers)
                {
                    // FileLog.Log($"{phoenixFactionSoldier.DisplayName}");
                    // FileLog.Log(phoenixFactionSoldier.GetBodyParts().ToArray()[0].name);
                    // Human_Torso_BodyPartDef

                    // phoenixFactionSoldier.GetTacticalAbilities().Do(x => FileLog.Log(x.name));
                    // Heavy_ClassProficiency_AbilityDef
                    // Brawler_AbilityDef
                    // WarCry_AbilityDef

                    // phoenixFactionSoldier.ArmourItems.FirstOrDefault(x => x.CommonItemData.GetDisplayName() == "Regeneration Torso")?.ItemDef.Abilities.Do(x => FileLog.Log(x.name));
                    // Regeneration_Torso_Passive_AbilityDef
                    // phoenixFactionSoldier.ArmourItems.FirstOrDefault(x => x.CommonItemData.GetDisplayName() == "Regeneration Torso")?.ItemDef.Abilities.Do(x => FileLog.Log(x.Guid));
                    // d7f6a180-f767-ed74-18f9-22a90ba2828c
                    // phoenixFactionSoldier.ArmourItems.FirstOrDefault(x => x.CommonItemData.GetDisplayName() == "Regeneration Torso")?.ItemDef.Abilities.Do(x => FileLog.Log(x.ResourcePath));
                    // Defs/Tactical/Actors/_Common/Abilities/Regeneration_Torso_Passive_AbilityDef

                    if (phoenixFactionSoldier.ArmourItems.Any(x =>
                                                              x.CommonItemData.ItemDef.Abilities.Any(y => y.Guid == "d7f6a180-f767-ed74-18f9-22a90ba2828c")))
                    {
                        //FileLog.Log($"Healing {phoenixFactionSoldier.DisplayName}.");
                        phoenixFactionSoldier.Heal(float.MaxValue);
                    }
                }
            }
            catch (Exception e)
            {
                FileLog.Log(e.ToString());
            }
        }
Beispiel #22
0
        static void Postfix(scriptMasterLoader __instance, ref string ___assetPath, ref int ___phase)
        {
            try
            {
                if (___phase == 1)
                {
                    FileLog.LogBuffered("Current Phase: " + ___phase.ToString());
                    FileLog.LogBuffered("assetpath: " + ___assetPath);
                    String modpath = ___assetPath;
                    FileLog.LogBuffered("modpath: " + modpath);
                    modpath += "Mods/";
                    FileLog.LogBuffered("modpath2: " + modpath);


                    if (Harmony.DEBUG)
                    {
                        FileLog.FlushBuffer();
                    }
                    FileLog.Reset();
                    AssetLoader loader = AssetLoader.Instance;
                    loader.loadAssets(modpath);
                    FileLog.Log("Assets loaded");
                }
                else if (___phase == 13)
                {
                    GameObject global = GameObject.FindGameObjectWithTag("Global");

                    FileLog.Log("Number of monster sprites: " + global.GetComponent <scriptMonsters>().dSprites.Length);
                    FileLog.Log("Number of follower sprites: " + global.GetComponent <scriptMonsters>().followMon.Length);
                    FileLog.Log("Number of egg sprites: " + global.GetComponent <scriptMonsters>().dEggSprites.Length);
                }
            }
            catch (Exception e)
            {
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.InnerException.Message);
                FileLog.Log(e.InnerException.StackTrace);
            }
        }
Beispiel #23
0
        public void Update()
        {
            // Toggle GUI Menu
            if (Input.GetKeyDown(KeyCode.F5))
            {
                enabled_Menu = !enabled_Menu;
                //Lock or unlock the view to allow menu control.
                if (enabled_Menu)
                {
                    try { TheForest.Utils.LocalPlayer.FpCharacter.LockView(); }
                    catch (Exception) { }
                }
                else
                {
                    try { TheForest.Utils.LocalPlayer.FpCharacter.UnLockView(); }
                    catch (Exception) { }
                }
            }

            ///--KEYBIND HANDLING---//
            if (Input.GetKey(KeyCode.RightAlt))
            {
                if (Input.GetKeyDown(KeyCode.Keypad0) && !isKeyPressed)
                {
                    enabled_GodMode = !enabled_GodMode;
                    isKeyPressed    = true;
                    FileLog.Log("God Mode: " + enabled_GodMode.ToString());
                }
                else if (Input.GetKeyDown(KeyCode.Keypad1) && !isKeyPressed)
                {
                    enabled_MovementHack = !enabled_MovementHack;
                    isKeyPressed         = true;
                    FileLog.Log("Movement Hacks: " + enabled_MovementHack.ToString());
                }
                else
                {
                    isKeyPressed = false;
                }
            }
        }
Beispiel #24
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                FileLog.Log("Running patch " + MethodBase.GetCurrentMethod().DeclaringType);
                int loc = InstructionHandlers.getInstruction(codes, 0, 0, OpCodes.Callvirt, "Segment", "SearchEntity", true, new Type[] { typeof(long), typeof(long), typeof(long) });
                FileLog.Log("Found match at pos " + InstructionHandlers.toString(codes, loc));
                codes.RemoveAt(loc + 1);               //isinst
                codes[loc].operand = InstructionHandlers.convertMethodOperand("ReikaKalseki.FortressTweaks.FortressTweaksMod", "getStorageHandlerForEntityForBelt", false, new Type[] { typeof(Segment), typeof(long), typeof(long), typeof(long), typeof(ConveyorEntity) });
                codes.Insert(loc, new CodeInstruction(OpCodes.Ldarg_0));
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
                //FileLog.Log("Codes are "+InstructionHandlers.toString(codes));
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }
        void Init()
        {
            FileLog.Reset();
            FileLog.Log("Init Start");

            HarmonyInstance harmony = HarmonyInstance.Create("exp.hax.tabg.stuff");

            FileLog.Log("Harmony Instance created");

            //harmony.PatchAll(Assembly.GetExecutingAssembly());
            var postfix = typeof(HarmonyPatches.CatchNewPlayer).GetMethod("Postfix");

            harmony.Patch(typeof(Player).GetMethod("Start"), null, new HarmonyMethod(postfix));

            var prefix = typeof(HarmonyPatches.RemovePlayer).GetMethod("Prefix");

            harmony.Patch(typeof(Player).GetMethod("OnDestroy"), new HarmonyMethod(prefix), null);
            FileLog.Log("Harmony Patches applied");

            _init = true;
            FileLog.Log("Init Completed");
        }
Beispiel #26
0
 private static void ReadConfig()
 {
     try
     {
         var fileName = Path.Combine(modDirectory, "mod_settings.json");
         if (File.Exists(fileName))
         {
             Globals.Settings = JsonConvert.DeserializeObject <Settings>(File.ReadAllText(fileName));
             ClampSettingsValues(ref Globals.Settings);
             PrintValidatedSettings(Globals.Settings);
         }
         else
         {
             Log($"Configuration file expected at {fileName} but not found, using default settings", LogLevel.Error);
             Globals.Settings = new Settings();
         }
     }
     catch (Exception ex)
     {
         FileLog.Log(ex.ToString());
     }
 }
        internal static void Log(string text, LogLevel level, LogType type, string caller)
        {
            if (type.Contains(LogType.None) || type.Contains(LogType.Custom))
            {
                AddToFile(caller, $"{DateTime.Now.ToShortTimeString()} [{caller}] [{level:f}] {text}");
            }

            if (type.Contains(LogType.Harmony))
            {
                FileLog.Log($"{DateTime.Now.ToShortTimeString()} [{caller}] [{level:f}] {text}");
            }

            if (type.Contains(LogType.Console))
            {
                Console.WriteLine($"[{caller}] [{level:f}] {text}");
            }

            if (type.Contains(LogType.PlayerScreen))
            {
                ErrorMessage.AddDebug($"{DateTime.Now.ToShortTimeString()} [{caller}] [{level:f}] {text}");
            }
        }
        public override void OnEnable()
        {
            base.OnEnable();

            APILoad.api = this;

            GameObject obj = new GameObject();

            APILoader = obj.AddComponent <APILoad>();
            //FileLog.Log("OnEnable()");
            //OLogger.Log("OnEnable()");

            if (outwardItemOverrides.Count > 0)
            {
                APILoader.Initialise(outwardItemOverrides);
            }
            else
            {
                OLogger.Log("There was an error reading the configuration files, cant patch anything. Exiting");
                FileLog.Log("There was an error reading the configuration files, cant patch anything. Exiting");
            }
        }
Beispiel #29
0
        public static void Init(string directory, string settingsJSON)
        {
            SimpleMechAssembly_Main.Log = Logger.GetLogger("BTSimpleMechAssembly");
            try
            {
                SimpleMechAssembly_Main.Settings = JsonConvert.DeserializeObject <SimpleMechAssembly_Settings>(settingsJSON);
            }
            catch (Exception e)
            {
                SimpleMechAssembly_Main.Log.LogException("error reading settings, using defaults", e);
                SimpleMechAssembly_Main.Settings = new SimpleMechAssembly_Settings();
            }
            if (SimpleMechAssembly_Main.Settings.LogLevelLog)
            {
                Logger.SetLoggerLevel("BTSimpleMechAssembly", LogLevel.Log);
            }
            var harmony = HarmonyInstance.Create("com.github.mcb5637.BTSimpleMechAssembly");

            harmony.PatchAll(Assembly.GetExecutingAssembly());
            AccessExtensionPatcher.PatchAll(harmony, Assembly.GetExecutingAssembly());
            if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageActive)
            {
                try
                {
                    harmony.Patch(typeof(Contract).GetMethod("GenerateSalvage", BindingFlags.NonPublic | BindingFlags.Instance),
                                  null,
                                  new HarmonyMethod(typeof(SimpleMechAssembly_StructurePointBasedSalvage).GetMethod("Postfix")),
                                  new HarmonyMethod(typeof(SimpleMechAssembly_StructurePointBasedSalvage).GetMethod("Transpiler")));
                    harmony.Patch(AccessTools.DeclaredMethod(typeof(Contract), "AddMechComponentToSalvage"), null, null,
                                  new HarmonyMethod(AccessTools.DeclaredMethod(typeof(SimpleMechAssembly_StructurePointBasedSalvage), "CheckSalvageTranspiler")));
                    harmony.Patch(AccessTools.DeclaredMethod(typeof(Contract), "CreateAndAddMechPart"), null, null,
                                  new HarmonyMethod(AccessTools.DeclaredMethod(typeof(SimpleMechAssembly_StructurePointBasedSalvage), "CheckMechSalvageTranspiler")));
                }
                catch (Exception e)
                {
                    FileLog.Log(e.ToString());
                }
            }
        }
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new List <CodeInstruction>(instructions);

            try {
                int start = 0;
                FileLog.Log("Running patch, which found anchor " + InstructionHandlers.toString(codes, start));
                List <CodeInstruction> inject = new List <CodeInstruction>();
                inject.Add(new CodeInstruction(OpCodes.Ldarg_0));
                inject.Add(InstructionHandlers.createMethodCall("ReikaKalseki.RoomEnvironmentals.RoomEnvironmentalsMod", "onRoomEnviroPPSCost", false, typeof(Room_Enviro)));
                FileLog.Log("Injecting " + inject.Count + " instructions: " + InstructionHandlers.toString(inject));
                codes.InsertRange(start, inject);
                FileLog.Log("Done patch " + MethodBase.GetCurrentMethod().DeclaringType);
            }
            catch (Exception e) {
                FileLog.Log("Caught exception when running patch " + MethodBase.GetCurrentMethod().DeclaringType + "!");
                FileLog.Log(e.Message);
                FileLog.Log(e.StackTrace);
                FileLog.Log(e.ToString());
            }
            return(codes.AsEnumerable());
        }