mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 04:53:30 +08:00
WIP
This commit is contained in:
@@ -10,7 +10,7 @@ public static class AuxilaryfunctionWrapper
|
|||||||
private const string AuxilaryfunctionGuid = "cn.blacksnipe.dsp.Auxilaryfunction";
|
private const string AuxilaryfunctionGuid = "cn.blacksnipe.dsp.Auxilaryfunction";
|
||||||
public static ConfigEntry<bool> ShowStationInfo;
|
public static ConfigEntry<bool> ShowStationInfo;
|
||||||
|
|
||||||
public static void Init(Harmony harmony)
|
public static void Start(Harmony harmony)
|
||||||
{
|
{
|
||||||
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return;
|
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return;
|
||||||
var assembly = pluginInfo.Instance.GetType().Assembly;
|
var assembly = pluginInfo.Instance.GetType().Assembly;
|
||||||
|
|||||||
@@ -10,45 +10,8 @@ public static class BulletTimeWrapper
|
|||||||
private const string BulletTimeGuid = "com.starfi5h.plugin.BulletTime";
|
private const string BulletTimeGuid = "com.starfi5h.plugin.BulletTime";
|
||||||
public static bool HasBulletTime;
|
public static bool HasBulletTime;
|
||||||
|
|
||||||
public static void Init(Harmony harmony)
|
public static void Start(Harmony _)
|
||||||
{
|
{
|
||||||
HasBulletTime = BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var pluginInfo);
|
HasBulletTime = BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var _);
|
||||||
if (!HasBulletTime) return;
|
|
||||||
|
|
||||||
I18N.Add("Increase game speed (max 10x)", "Increase game speed (max 10x)", "提升游戏速度(最高10倍)");
|
|
||||||
I18N.Apply();
|
|
||||||
|
|
||||||
var assembly = pluginInfo.Instance.GetType().Assembly;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var classType = assembly.GetType("BulletTime.IngameUI");
|
|
||||||
harmony.Patch(AccessTools.Method(classType, "Init"),
|
|
||||||
null, null, new HarmonyMethod(AccessTools.Method(typeof(BulletTimeWrapper), nameof(IngameUI_Init_Transpiler))));
|
|
||||||
harmony.Patch(AccessTools.Method(classType, "OnSpeedButtonClick"),
|
|
||||||
null, null, new HarmonyMethod(AccessTools.Method(typeof(BulletTimeWrapper), nameof(IngameUI_OnSpeedButtonClick_Transpiler))));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
UXAssist.Logger.LogWarning("Failed to patch BulletTime functions()");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private static IEnumerable<CodeInstruction> IngameUI_Init_Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
||||||
{
|
|
||||||
var matcher = new CodeMatcher(instructions);
|
|
||||||
matcher.MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldstr, "Increase game speed (max 4x)")
|
|
||||||
).Set(OpCodes.Ldstr, "Increase game speed (max 10x)");
|
|
||||||
return matcher.InstructionEnumeration();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IEnumerable<CodeInstruction> IngameUI_OnSpeedButtonClick_Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
||||||
{
|
|
||||||
var matcher = new CodeMatcher(instructions);
|
|
||||||
matcher.MatchForward(false,
|
|
||||||
new CodeMatch(OpCodes.Ldc_R8, 240.0)
|
|
||||||
).Set(OpCodes.Ldc_R8, 600.0);
|
|
||||||
return matcher.InstructionEnumeration();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -381,12 +381,6 @@ public static class TechPatch
|
|||||||
|
|
||||||
void DoUnlockFuncInternal()
|
void DoUnlockFuncInternal()
|
||||||
{
|
{
|
||||||
UnlockTechRecursive(__instance.techProto, maxLevel);
|
|
||||||
history.VarifyTechQueue();
|
|
||||||
if (history.currentTech != history.techQueue[0])
|
|
||||||
{
|
|
||||||
history.currentTech = history.techQueue[0];
|
|
||||||
}
|
|
||||||
var mainPlayer = GameMain.mainPlayer;
|
var mainPlayer = GameMain.mainPlayer;
|
||||||
for (var i = 0; i < 6; i++)
|
for (var i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
@@ -398,6 +392,12 @@ public static class TechPatch
|
|||||||
mainPlayer.mecha.AddProductionStat(itemId, itemCount, mainPlayer.nearestFactory);
|
mainPlayer.mecha.AddProductionStat(itemId, itemCount, mainPlayer.nearestFactory);
|
||||||
mainPlayer.mecha.AddConsumptionStat(itemId, itemCount, mainPlayer.nearestFactory);
|
mainPlayer.mecha.AddConsumptionStat(itemId, itemCount, mainPlayer.nearestFactory);
|
||||||
}
|
}
|
||||||
|
UnlockTechRecursive(__instance.techProto, maxLevel);
|
||||||
|
history.VarifyTechQueue();
|
||||||
|
if (history.currentTech != history.techQueue[0])
|
||||||
|
{
|
||||||
|
history.currentTech = history.techQueue[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
private static bool _initialized;
|
private static bool _initialized;
|
||||||
private static PressKeyBind _toggleKey;
|
private static PressKeyBind _toggleKey;
|
||||||
private static ConfigFile _dummyConfig;
|
private static ConfigFile _dummyConfig;
|
||||||
private Type[] _patches;
|
private Type[] _patches, _compats;
|
||||||
|
|
||||||
#region IModCanSave
|
#region IModCanSave
|
||||||
private const ushort ModSaveVersion = 1;
|
private const ushort ModSaveVersion = 1;
|
||||||
@@ -160,6 +160,8 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
|
|
||||||
_patches = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.Patches");
|
_patches = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.Patches");
|
||||||
_patches?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
|
_patches?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
|
||||||
|
_compats = Common.Util.GetTypesInNamespace(Assembly.GetExecutingAssembly(), "UXAssist.ModsCompat");
|
||||||
|
_compats?.Do(type => type.GetMethod("Init")?.Invoke(null, null));
|
||||||
|
|
||||||
I18N.Apply();
|
I18N.Apply();
|
||||||
I18N.OnInitialized += RecreateConfigWindow;
|
I18N.OnInitialized += RecreateConfigWindow;
|
||||||
@@ -171,9 +173,9 @@ public class UXAssist : BaseUnityPlugin, IModCanSave
|
|||||||
UIPatch.Enable(true);
|
UIPatch.Enable(true);
|
||||||
|
|
||||||
_patches?.Do(type => type.GetMethod("Start")?.Invoke(null, null));
|
_patches?.Do(type => type.GetMethod("Start")?.Invoke(null, null));
|
||||||
var patch = UIPatch.GetHarmony();
|
|
||||||
ModsCompat.AuxilaryfunctionWrapper.Init(patch);
|
object[] parameters = [UIPatch.GetHarmony()];
|
||||||
ModsCompat.BulletTimeWrapper.Init(patch);
|
_compats?.Do(type => type.GetMethod("Start")?.Invoke(null, parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
|
|||||||
Reference in New Issue
Block a user