Skip to content

Commit

Permalink
cleanup + fixed Save our ship 2 incompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Apr 5, 2020
1 parent 0337f90 commit e45f414
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*.vs
Source/Giddy-up-Caravan/.vs/*
Source/Giddy-up-Caravan/obj/*
v1.1/Source/Giddy-up-Core/obj/*
v1.1/Source/Giddy-up-Caravan/obj/*
Binary file modified v1.1/Assemblies/GiddyUpCaravan.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Text;
using Verse;
using Verse.AI;
using Verse.AI.Group;

namespace GiddyUpCaravan.Harmony
{
Expand All @@ -16,10 +17,11 @@ static class Lordtoil_PrepareCaravan_Leave_UpdateAllDuties
{
static void Prefix(LordToil_PrepareCaravan_Leave __instance)
{
AddMissingPawnsToLord(__instance);
foreach (Pawn pawn in __instance.lord.ownedPawns)
{
ExtendedPawnData pawnData = GiddyUpCore.Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);
if(pawnData.caravanMount != null && __instance.lord.ownedPawns.Contains(pawnData.caravanMount))
if (pawnData.caravanMount != null)
{
Pawn animal = pawnData.caravanMount;
Job jobRider = new Job(GUC_JobDefOf.Mount, animal);
Expand All @@ -33,5 +35,25 @@ static void Prefix(LordToil_PrepareCaravan_Leave __instance)
}
}
}

//For compatibility with other mods (Save our ship 2), add any missing mounts to the lord.
private static void AddMissingPawnsToLord(LordToil_PrepareCaravan_Leave __instance)
{
List<Pawn> shouldAddOwnedPawns = new List<Pawn>();
foreach (Pawn pawn in __instance.lord.ownedPawns)
{
ExtendedPawnData pawnData = GiddyUpCore.Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);
bool caravanContainsMount = __instance.lord.ownedPawns.Contains(pawnData.caravanMount);
if (pawnData.caravanMount != null && !caravanContainsMount)
{
shouldAddOwnedPawns.Add(pawnData.caravanMount);
}
}
foreach (Pawn pawn in shouldAddOwnedPawns)
{
__instance.lord.ownedPawns.Add(pawn);
pawn.mindState.duty = new PawnDuty(DutyDefOf.TravelOrWait, Traverse.Create(__instance).Field("exitSpot").GetValue<IntVec3>());
}
}
}
}
Binary file not shown.
Empty file.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Empty file.
Empty file.
Empty file.

0 comments on commit e45f414

Please sign in to comment.