Skip to content

Commit 7da5fa3

Browse files
Sakura-TASakura-TA
andauthored
fix: include all player factions in shuttle quest colonist count (#882)
Co-authored-by: Sakura-TA <Sakura_TA@163.com>
1 parent 2ac77a6 commit 7da5fa3

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

Source/Client/Factions/MultifactionPatches.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> inst
761761
yield return ci;
762762
}
763763
}
764-
static bool IsFreeColonistAnyPlayerFaction(Pawn pawn)
764+
public static bool IsFreeColonistAnyPlayerFaction(Pawn pawn)
765765
{
766766
if (Multiplayer.Client == null || !Multiplayer.GameComp.multifaction)
767767
return pawn.IsFreeColonist;
@@ -818,3 +818,23 @@ static void Finalizer(Gravship gravship, Map map,bool __state)
818818
map.PopFaction();
819819
}
820820
}
821+
822+
[HarmonyPatch(typeof(QuestPart_LendColonistsToFaction), "Enable")]
823+
static class QuestPart_LendColonistsToFaction_Enable_Patch
824+
{
825+
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> insts)
826+
{
827+
var isFreeColonist = AccessTools.PropertyGetter(typeof(Pawn), nameof(Pawn.IsFreeColonist));
828+
var replacement = AccessTools.Method(typeof(CompShuttle_ContainedColonistCount_Patch),
829+
nameof(CompShuttle_ContainedColonistCount_Patch.IsFreeColonistAnyPlayerFaction));
830+
foreach (var ci in insts)
831+
{
832+
if (ci.Calls(isFreeColonist))
833+
{
834+
ci.opcode = OpCodes.Call;
835+
ci.operand = replacement;
836+
}
837+
yield return ci;
838+
}
839+
}
840+
}

0 commit comments

Comments
 (0)