-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-WarpDriveProgram GetActiveTimer patch now has harmony load the value…
… rather than using reflection -Removed virtual method OnWarp code, added notification as a patch
- Loading branch information
Showing
4 changed files
with
38 additions
and
21 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
34 changes: 34 additions & 0 deletions
34
PulsarModLoader/Content/Components/OnWarpUnstableNotificationPatch.cs
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,34 @@ | ||
using HarmonyLib; | ||
using System.Collections.Generic; | ||
using System.Reflection.Emit; | ||
using static PulsarModLoader.Patches.HarmonyHelpers; | ||
|
||
namespace PulsarModLoader.Content.Components | ||
{ | ||
[HarmonyPatch()] | ||
class OnWarpUnstableNotificationPatch | ||
{ | ||
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) | ||
{ | ||
List<CodeInstruction> targetSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(OpCodes.Ldloc_0), | ||
new CodeInstruction(OpCodes.Ldc_I4_1), | ||
new CodeInstruction(OpCodes.Sub), | ||
new CodeInstruction(OpCodes.Call), | ||
}; | ||
|
||
List<CodeInstruction> injectedSequence = new List<CodeInstruction>() | ||
{ | ||
new CodeInstruction(OpCodes.Ldarg_0), | ||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(OnWarpUnstableNotificationPatch), "PatchMethod")) | ||
}; | ||
|
||
return PatchBySequence(instructions, targetSequence, injectedSequence, checkMode: CheckMode.NEVER); | ||
} | ||
static void PatchMethod(PLShipComponent InComp) | ||
{ | ||
PulsarModLoader.Utilities.Messaging.Notification(InComp.GetItemName(true) + " has degraded to Level " + (InComp.Level + 1)); | ||
} | ||
} | ||
} |
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