Skip to content

Commit

Permalink
fix: Emergency fix for Vehicle Upgrade Modules! (#426)
Browse files Browse the repository at this point in the history
* Emergency fix for Vehicle Upgrade Modules!

* Optimization changes.

* Formatting fixes

* Condense 'gadget' declaration

---------

Co-authored-by: LeeTwentyThree <[email protected]>
  • Loading branch information
jonahnm and LeeTwentyThree committed Jul 1, 2023
1 parent 3fe6996 commit 93d82c2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Nautilus/Patchers/VehicleUpgradesPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static void OnModuleChangeDelegate(Vehicle __instance, int slotID, TechT
private static void OnModuleChangeCrushDepth(Vehicle __instance, int slotID, TechType techType, bool added)
{
Dictionary<TechType, float> CrushDepthUpgrades = new();
if(__instance is Exosuit)
if (__instance is Exosuit)
ExosuitUpgradeModules.DoIf(
(KeyValuePair<TechType, ICustomPrefab> mapElem) => mapElem.Value.TryGetGadget(out UpgradeModuleGadget moduleGadget) && moduleGadget.CrushDepth > 0f,
(KeyValuePair<TechType, ICustomPrefab> mapElem) => CrushDepthUpgrades.Add(mapElem.Key, mapElem.Value.GetGadget<UpgradeModuleGadget>().CrushDepth)
Expand All @@ -88,7 +88,7 @@ private static void OnModuleChangeCrushDepth(Vehicle __instance, int slotID, Tec
if (crushDepthToCheck > newCrushDepth)
{
newCrushDepth = crushDepthToCheck;
if(__instance is Exosuit)
if (__instance is Exosuit)
{
if (ExosuitUpgradeModules[techTypeInSlot].TryGetGadget(out UpgradeModuleGadget moduleGadget))
absolute = moduleGadget.AbsoluteDepth;
Expand Down Expand Up @@ -239,7 +239,7 @@ private static void OnUpgradeModuleExoHull(Exosuit __instance, int slotID, TechT
if (Exosuit.crushDepths.TryGetValue(techTypeInSlot, out depthToCheck) && depthToCheck > newCrushDepth)
{
newCrushDepth = depthToCheck;
if (ExosuitUpgradeModules[techTypeInSlot].TryGetGadget(out UpgradeModuleGadget mdlGadget))
if (ExosuitUpgradeModules.TryGetValue(techTypeInSlot, out var gadget) && gadget.TryGetGadget(out UpgradeModuleGadget mdlGadget))
absolute = mdlGadget.AbsoluteDepth;
}
}
Expand Down Expand Up @@ -331,7 +331,7 @@ private static void SeamothOnUpgradeModuleHull(SeaMoth __instance, int slotID, T
if (crushDepthToCheck > newCrushDepth)
{
newCrushDepth = crushDepthToCheck;
if(SeamothUpgradeModules[techTypeInSlot].TryGetGadget(out UpgradeModuleGadget moduleGadget))
if (SeamothUpgradeModules.TryGetValue(techTypeInSlot, out var gadget) && gadget.TryGetGadget(out UpgradeModuleGadget moduleGadget))
absolute = moduleGadget.AbsoluteDepth;
}
}
Expand Down Expand Up @@ -363,7 +363,7 @@ public static void SeamothDelegateUse(SeaMoth __instance, ref float cooldown, in
moduleGadget.delegateOnUsed?.Invoke(__instance, slotID, quickSlotCharge, chargeScalar);

if (moduleGadget.Cooldown > 0f)
cooldown = (float)moduleGadget.Cooldown;
cooldown = (float) moduleGadget.Cooldown;
}

[HarmonyTranspiler]
Expand All @@ -386,7 +386,7 @@ private static IEnumerable<CodeInstruction> OnUpgradeModuleUse(IEnumerable<CodeI
Transpilers.EmitDelegate(SeamothDelegateUse)
);

return matcher.InstructionEnumeration();
return matcher.InstructionEnumeration();
}


Expand Down Expand Up @@ -468,7 +468,7 @@ private static void OnUpgradeChangeDelegate(SeaTruckUpgrades __instance, int slo
if (SeaTruckUpgrades.crushDepths.TryGetValue(techTypeInSlot, out depthToCheck) && depthToCheck > newCrushDepth)
{
newCrushDepth = depthToCheck;
if (SeatruckUpgradeModules[techTypeInSlot].TryGetGadget(out UpgradeModuleGadget mdlGadget))
if (SeatruckUpgradeModules.TryGetValue(techTypeInSlot, out var gadget) && gadget.TryGetGadget(out UpgradeModuleGadget mdlGadget))
absolute = mdlGadget.AbsoluteDepth;
}
}
Expand Down

0 comments on commit 93d82c2

Please sign in to comment.