Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed thursters power override, fixed so unstable components actually… #33

Merged
merged 2 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static PLThruster CreateThruster(int Subtype, int level)
InThruster.Desc = ThrusterType.Description;
InThruster.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InThruster, ThrusterType.IconTexture);
InThruster.GetType().GetField("m_MaxOutput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InThruster, ThrusterType.MaxOutput);
InThruster.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InThruster, ThrusterType.MaxPowerUsage_Watts);
InThruster.GetType().GetField("m_BaseMaxPower", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InThruster, ThrusterType.MaxPowerUsage_Watts);
InThruster.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InThruster, (ObscuredInt)ThrusterType.MarketPrice);
InThruster.CargoVisualPrefabID = ThrusterType.CargoVisualID;
InThruster.CanBeDroppedOnShipDeath = ThrusterType.CanBeDroppedOnShipDeath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static PLInertiaThruster CreateInertiaThruster(int Subtype, int level)
InInertiaThruster.Desc = InertiaThrusterType.Description;
InInertiaThruster.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InInertiaThruster, InertiaThrusterType.IconTexture);
InInertiaThruster.GetType().GetField("m_MaxOutput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InInertiaThruster, InertiaThrusterType.MaxOutput);
InInertiaThruster.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InInertiaThruster, InertiaThrusterType.MaxPowerUsage_Watts);
InInertiaThruster.GetType().GetField("m_BaseMaxPower", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InInertiaThruster, InertiaThrusterType.MaxPowerUsage_Watts);
InInertiaThruster.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InInertiaThruster, (ObscuredInt)InertiaThrusterType.MarketPrice);
InInertiaThruster.CargoVisualPrefabID = InertiaThrusterType.CargoVisualID;
InInertiaThruster.CanBeDroppedOnShipDeath = InertiaThrusterType.CanBeDroppedOnShipDeath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static PLManeuverThruster CreateManeuverThruster(int Subtype, int level)
InManeuverThruster.Desc = ManeuverThrusterType.Description;
InManeuverThruster.GetType().GetField("m_IconTexture", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.IconTexture);
InManeuverThruster.GetType().GetField("m_MaxOutput", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.MaxOutput);
InManeuverThruster.GetType().GetField("m_MaxPowerUsage_Watts", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.MaxPowerUsage_Watts);
InManeuverThruster.GetType().GetField("m_BaseMaxPower", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, ManeuverThrusterType.MaxPowerUsage_Watts);
InManeuverThruster.GetType().GetField("m_MarketPrice", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(InManeuverThruster, (ObscuredInt)ManeuverThrusterType.MarketPrice);
InManeuverThruster.CargoVisualPrefabID = ManeuverThrusterType.CargoVisualID;
InManeuverThruster.CanBeDroppedOnShipDeath = ManeuverThrusterType.CanBeDroppedOnShipDeath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ private static IEnumerator LateAddToSendQueueReplacement(int shipID, int sendQue
[HarmonyPatch(typeof(PLWarpDriveProgram), "GetActiveTimerAlpha")]
class WarpDriveProgramGetActiveTimerAlphaPatch
{
static void Postfix(PLWarpDriveProgram __instance, ref float __result)
static void Postfix(PLWarpDriveProgram __instance, ref float __result, float __ShieldBooster_LastActivationTime)
{
int subtypeformodded = __instance.SubType - WarpDriveProgramModManager.Instance.VanillaWarpDriveProgramMaxType;
if (subtypeformodded > -1 && subtypeformodded < WarpDriveProgramModManager.Instance.WarpDriveProgramTypes.Count)
{
__result = Mathf.Clamp01((Time.time - (float)__instance.GetType().GetField("ShieldBooster_LastActivationTime", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance)) / WarpDriveProgramModManager.Instance.WarpDriveProgramTypes[subtypeformodded].ActiveTime);
__result = Mathf.Clamp01((Time.time - __ShieldBooster_LastActivationTime) / WarpDriveProgramModManager.Instance.WarpDriveProgramTypes[subtypeformodded].ActiveTime);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions PulsarModLoader/PulsarModLoader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<Compile Include="Content\Components\MissionShipComponent\MissionShipComponentModManager.cs" />
<Compile Include="Content\Components\NuclearDevice\NuclearDeviceMod.cs" />
<Compile Include="Content\Components\NuclearDevice\NuclearDeviceModManager.cs" />
<Compile Include="Content\Components\OnWarpUnstableNotificationPatch.cs" />
<Compile Include="Content\Components\PolytechModule\PolytechModuleMod.cs" />
<Compile Include="Content\Components\PolytechModule\PolytechModuleModManager.cs" />
<Compile Include="Content\Components\Reactors\ReactorMod.cs" />
Expand Down