From 80e539c0007b12f55897c2c410d94c791593854d Mon Sep 17 00:00:00 2001 From: Rhinous Date: Sat, 27 Apr 2024 02:46:30 +1000 Subject: [PATCH] Fix pawns not generating ammo for primary weapon --- .../Harmony/Harmony_PawnInventoryGenerator.cs | 25 ------------------- .../Harmony/Harmony_PawnWeaponGenerator.cs | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 25 deletions(-) delete mode 100644 Source/CombatExtended/Harmony/Harmony_PawnInventoryGenerator.cs create mode 100644 Source/CombatExtended/Harmony/Harmony_PawnWeaponGenerator.cs diff --git a/Source/CombatExtended/Harmony/Harmony_PawnInventoryGenerator.cs b/Source/CombatExtended/Harmony/Harmony_PawnInventoryGenerator.cs deleted file mode 100644 index ebdefd99c3..0000000000 --- a/Source/CombatExtended/Harmony/Harmony_PawnInventoryGenerator.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using RimWorld; -using Verse; -using UnityEngine; -using HarmonyLib; - -namespace CombatExtended.HarmonyCE -{ - [HarmonyPatch(typeof(PawnInventoryGenerator), "GenerateInventoryFor")] - static class Harmony_PawnInventoryGenerator_GenerateInventoryFor - { - public static void Postfix(Pawn p, PawnGenerationRequest request) - { - var loadoutProps = p.kindDef.GetModExtension(); - if (loadoutProps != null) - { - float biocodeChance = (request.BiocodeWeaponChance > 0f) ? request.BiocodeWeaponChance : p.kindDef.biocodeWeaponChance; //pass biocode weapon chance to generate loadout - loadoutProps.GenerateLoadoutFor(p, biocodeChance); - } - } - } -} diff --git a/Source/CombatExtended/Harmony/Harmony_PawnWeaponGenerator.cs b/Source/CombatExtended/Harmony/Harmony_PawnWeaponGenerator.cs new file mode 100644 index 0000000000..ca7f941c39 --- /dev/null +++ b/Source/CombatExtended/Harmony/Harmony_PawnWeaponGenerator.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using RimWorld; +using Verse; +using UnityEngine; +using HarmonyLib; + +namespace CombatExtended.HarmonyCE +{ + [HarmonyPatch(typeof(PawnWeaponGenerator), "TryGenerateWeaponFor")] + static class Harmony_PawnWeaponGenerator_TryGenerateWeaponFor + { + public static void Postfix(Pawn pawn, PawnGenerationRequest request) + { + var loadoutProps = pawn.kindDef.GetModExtension(); + if (loadoutProps != null) + { + float biocodeChance = (request.BiocodeWeaponChance > 0f) ? request.BiocodeWeaponChance : pawn.kindDef.biocodeWeaponChance; //pass biocode weapon chance to generate loadout + loadoutProps.GenerateLoadoutFor(pawn, biocodeChance); + } + } + } +}