-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Awbugl
committed
Dec 25, 2022
1 parent
3ff7aa2
commit c440b3e
Showing
6 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LDB/@EntryIndexedValue">LDB</s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
using HarmonyLib; | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
namespace ProjectGenesis.Patches | ||
{ | ||
public static class InitnalTechPatches | ||
{ | ||
private static readonly List<int> InitnalTechs = new List<int>() | ||
{ | ||
1, | ||
1001, | ||
1901, | ||
1902, | ||
1903, | ||
1904, | ||
1905 | ||
}; | ||
|
||
[HarmonyPatch(typeof(GameData), "SetForNewGame")] | ||
[HarmonyPostfix] | ||
public static void SetForNewGame(GameData __instance) | ||
{ | ||
foreach (var tech in InitnalTechs) __instance.history.UnlockTech(tech); | ||
} | ||
|
||
[HarmonyPatch(typeof(UITechNode), "DoBuyoutTech")] | ||
[HarmonyPatch(typeof(UITechNode), "DoStartTech")] | ||
[HarmonyPatch(typeof(UITechNode), "OnPointerEnter")] | ||
[HarmonyPatch(typeof(UITechNode), "OnPointerExit")] | ||
[HarmonyPatch(typeof(UITechNode), "OnPointerDown")] | ||
[HarmonyPatch(typeof(UITechNode), "OnOtherIconClick")] | ||
[HarmonyTranspiler] | ||
public static IEnumerable<CodeInstruction> UITechNode_Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
var matcher = new CodeMatcher(instructions); | ||
matcher.MatchForward(true, new CodeMatch(OpCodes.Ldarg_0), | ||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UITechNode), nameof(UITechNode.techProto))), | ||
new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(Proto), nameof(Proto.ID))), new CodeMatch(OpCodes.Ldc_I4_1)); | ||
|
||
matcher.SetInstructionAndAdvance(Transpilers.EmitDelegate<Func<int, bool>>(id => InitnalTechs.Contains(id))); | ||
matcher.SetOpcodeAndAdvance(OpCodes.Brfalse_S); | ||
return matcher.InstructionEnumeration(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using BepInEx.Configuration; | ||
using HarmonyLib; | ||
using xiaoye97; | ||
|
||
namespace ProjectGenesis.Utils | ||
{ | ||
internal static class LDBToolCacheUtils | ||
{ | ||
internal static void Clear() | ||
{ | ||
ClearConfigFile("CustomID"); | ||
ClearConfigFile("CustomGridIndex"); | ||
ClearConfigFile("CustomStringZHCN"); | ||
ClearConfigFile("CustomStringENUS"); | ||
ClearConfigFile("CustomStringFRFR"); | ||
} | ||
|
||
private static void ClearConfigFile(string name) => AccessTools.StaticFieldRefAccess<ConfigFile>(typeof(LDBTool), name).Clear(); | ||
} | ||
} |