-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated PrawnSelfDefenseModule Added a bunch of patches for the PrawnSelfDefenseModule Ready for release. WAITING FOR A SMLHELPER UPDATE !!!
- Loading branch information
Showing
7 changed files
with
141 additions
and
38 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
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,19 @@ | ||
using System; | ||
using System.CodeDom; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VELD.AlterraWeaponry.patches; | ||
|
||
[HarmonyPatch(typeof(GameSettings))] | ||
public class GameSettings_SaveAsync_Patch | ||
{ | ||
[HarmonyPostfix] | ||
[HarmonyPatch(nameof(GameSettings.SaveAsync))] | ||
public static void SaveAsync(GameSettings.OnSaveDelegate onSave) | ||
{ | ||
LanguagesHandler.LanguagePatch(); | ||
} | ||
} |
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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VELD.AlterraWeaponry.patches; | ||
|
||
[HarmonyPatch(typeof(Vehicle))] | ||
public class Vehicle_ChargeModule_Patch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(Vehicle.ChargeModule))] | ||
public static bool ChargeModule(Vehicle __instance, TechType techType, int slotID) | ||
{ | ||
float num = __instance.quickSlotCharge[slotID]; | ||
float maxCharge = TechData.GetMaxCharge(techType); | ||
|
||
// TEMP CODE WAITING FOR SMLHELPER UPDATE | ||
if(techType == PrawnSelfDefenseModule.techType) | ||
maxCharge = PrawnSelfDefenseModule.maxCharge; | ||
|
||
float num2; | ||
TechData.GetEnergyCost(techType, out num2); | ||
|
||
// TEMP CODE WAITING FOR SMLHELPER UPDATE | ||
if (techType == PrawnSelfDefenseModule.techType) | ||
num2 = PrawnSelfDefenseModule.energyCost; | ||
|
||
float num3 = num2 * Time.deltaTime; | ||
float num4 = maxCharge - num; | ||
bool flag = num3 >= num4; | ||
float b = flag ? Mathf.Max(0f, num4) : num3; | ||
int num6; | ||
float num5 = Mathf.Min(__instance.energyInterface.TotalCanProvide(out num6), b); | ||
__instance.ConsumeEnergy(num5); | ||
__instance.quickSlotCharge[slotID] = __instance.quickSlotCharge[slotID] + num5; | ||
if (__instance.quickSlotCharge[slotID] > 0f && (flag || num5 == 0f)) | ||
{ | ||
__instance.OnUpgradeModuleUse(techType, slotID); | ||
__instance.quickSlotCharge[slotID] = 0f; | ||
} | ||
return false; | ||
} | ||
} |
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,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace VELD.AlterraWeaponry.patches; | ||
|
||
|
||
[HarmonyPatch(typeof(Vehicle))] | ||
internal class Vehicle_GetSlotCharge_Patch | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(Vehicle.GetSlotCharge))] | ||
public static bool GetSlotCharge(Vehicle __instance, int slotID, ref float __result) | ||
{ | ||
if (slotID < 0 || slotID >= __instance.slotIDs.Length) | ||
{ | ||
__result = 1f; | ||
return false; | ||
} | ||
TechType techType; | ||
QuickSlotType quickSlotType = __instance.GetQuickSlotType(slotID, out techType); | ||
if (quickSlotType == QuickSlotType.Chargeable || quickSlotType == QuickSlotType.SelectableChargeable) | ||
{ | ||
float maxCharge = TechData.GetMaxCharge(techType); | ||
|
||
// TEMPORARY PATCH, WAITING FOR AN SMLHELPER UPDATE | ||
bool flag = techType == PrawnSelfDefenseModule.techType; | ||
if (flag) | ||
maxCharge = PrawnSelfDefenseModule.maxCharge; | ||
|
||
if (maxCharge > 0f) | ||
{ | ||
__result = __instance.quickSlotCharge[slotID] / maxCharge; | ||
Main.logger.LogInfo($"Slot charge: {__result}"); | ||
return false; | ||
} | ||
} | ||
__result = 1f; | ||
return false; | ||
} | ||
} |
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