Skip to content

Commit

Permalink
performance fixes + version up
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed May 1, 2020
1 parent 3f5d317 commit 4319848
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<li>UnlimitedHugs.HugsLib</li>
<li>roolo.giddyupcore</li>
</loadAfter>
<packageId>roolo.giddyupcaravan</packageId>
<packageId>roolo.giddyupcaravan</packageId>
<description>Let your colonists ride to far lands on elephants, muffalos, llamas or any other animal, modded or not!

&lt;color=orange&gt;&lt;b&gt;Dependencies &lt;/b&gt;&lt;/color&gt;
Expand Down
2 changes: 1 addition & 1 deletion About/Version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<VersionData>
<overrideVersion>2.0.2</overrideVersion>
<overrideVersion>2.0.3</overrideVersion>
</VersionData>
Binary file added v1.1/Assemblies/0MultiplayerAPI.dll
Binary file not shown.
Binary file modified v1.1/Assemblies/GiddyUpCaravan.dll
Binary file not shown.
3 changes: 2 additions & 1 deletion v1.1/Source/Giddy-up-Caravan/GiddyUpCaravan.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -36,6 +36,7 @@
<ItemGroup>
<Reference Include="0Harmony, Version=2.0.0.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Lib.Harmony.2.0.0.6\lib\net472\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="0MultiplayerAPI">
<HintPath>packages\0MultiplayerAPI.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ private static void AddMissingPawnsToLord(LordToil_PrepareCaravan_Leave __instan
shouldAddOwnedPawns.Add(pawnData.caravanMount);
}
}
var exitSpot = Traverse.Create(__instance).Field("exitSpot").GetValue<IntVec3>();
foreach (Pawn pawn in shouldAddOwnedPawns)
{
__instance.lord.ownedPawns.Add(pawn);
pawn.mindState.duty = new PawnDuty(DutyDefOf.TravelOrWait, Traverse.Create(__instance).Field("exitSpot").GetValue<IntVec3>());
pawn.mindState.duty = new PawnDuty(DutyDefOf.TravelOrWait, exitSpot);
}
}
}
Expand Down
23 changes: 11 additions & 12 deletions v1.1/Source/Giddy-up-Caravan/Harmony/Pawn_JobTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ namespace GiddyUpCaravan.Harmony
static class Pawn_JobTracker_DetermineNextJob
{

static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result, ref Pawn ___pawn)
{
Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue<Pawn>();
if (pawn.RaceProps.Animal && pawn.Faction != Faction.OfPlayer && pawn.Faction != null)
if (___pawn.RaceProps.Animal && ___pawn.Faction != Faction.OfPlayer && ___pawn.Faction != null)
{

if (pawn.GetLord() != null && (pawn.GetLord().CurLordToil is LordToil_DefendPoint || pawn.GetLord().CurLordToil.GetType().Name == "LordToil_DefendTraderCaravan"))
if (___pawn.GetLord() != null && (___pawn.GetLord().CurLordToil is LordToil_DefendPoint || ___pawn.GetLord().CurLordToil.GetType().Name == "LordToil_DefendTraderCaravan"))
{

if (__result.SourceNode is JobGiver_Wander)
Expand All @@ -41,11 +40,11 @@ static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
}


if (pawn.IsColonistPlayerControlled || pawn.RaceProps.Animal || pawn.Faction.HostileTo(Faction.OfPlayer))
if (___pawn.IsColonistPlayerControlled || ___pawn.RaceProps.Animal || ___pawn.Faction.HostileTo(Faction.OfPlayer))
{
return;
}
if (pawn.IsPrisoner)
if (___pawn.IsPrisoner)
{
return;
}
Expand All @@ -63,8 +62,8 @@ static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
}

//Log.Message("wrong duty");
ExtendedPawnData PawnData = store.GetExtendedDataFor(pawn);
Lord lord = pawn.GetLord();
ExtendedPawnData PawnData = store.GetExtendedDataFor(___pawn);
Lord lord = ___pawn.GetLord();
if (lord == null)
{
return;
Expand All @@ -75,25 +74,25 @@ static void Postfix(Pawn_JobTracker __instance, ref ThinkResult __result)
return;
}

QueuedJob qJob = pawn.jobs.jobQueue.FirstOrFallback(null);
QueuedJob qJob = ___pawn.jobs.jobQueue.FirstOrFallback(null);
if(qJob != null && (qJob.job.def == GUC_JobDefOf.Dismount || qJob.job.def == GUC_JobDefOf.Mount))
{
return;
}

if (lord.CurLordToil is LordToil_ExitMapAndEscortCarriers || lord.CurLordToil is LordToil_Travel || lord.CurLordToil is LordToil_ExitMap || lord.CurLordToil is LordToil_ExitMapTraderFighting)
{
if (PawnData.owning != null && PawnData.owning.Faction == pawn.Faction && PawnData.mount == null && !PawnData.owning.Downed && PawnData.owning.Spawned && !pawn.IsBurning() && !pawn.Downed)
if (PawnData.owning != null && PawnData.owning.Faction == ___pawn.Faction && PawnData.mount == null && !PawnData.owning.Downed && PawnData.owning.Spawned && !___pawn.IsBurning() && !___pawn.Downed)
{
mountAnimal(__instance, pawn, PawnData, ref __result);
mountAnimal(__instance, ___pawn, PawnData, ref __result);

}
}
else if(lord.CurLordToil.GetType().Name == "LordToil_DefendTraderCaravan" || lord.CurLordToil is LordToil_DefendPoint) //first option is internal class, hence this way of accessing.
{
if (PawnData.mount != null)
{
parkAnimal(__instance, pawn, PawnData);
parkAnimal(__instance, ___pawn, PawnData);
}
}
}
Expand Down

0 comments on commit 4319848

Please sign in to comment.