Skip to content

Commit

Permalink
mounts no longer wait to be mounted when rider has mental break
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Mar 17, 2018
1 parent bdd7247 commit c03342a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Binary file modified Assemblies/GiddyUpCore.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Source/Giddy-up-Core/FactionRestrictionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public List<string> getAllowedNonWildAnimalsAsList()
}
public List<string> getAllowedWildAnimalsAsList()
{
Log.Message("requesting allowedWildAnimalsCSV" + allowedWildAnimalsCSV);
return allowedWildAnimalsCSV.Split(',').ToList();
}
}
Expand Down
31 changes: 22 additions & 9 deletions Source/Giddy-up-Core/Jobs/JobDriver_Mounted.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class JobDriver_Mounted : JobDriver
{
public Pawn Rider { get { return job.targetA.Thing as Pawn; } }
ExtendedPawnData riderData;
bool shouldEnd = false;
public bool interrupted = false;
bool isFinished = false;

protected override IEnumerable<Toil> MakeNewToils()
Expand All @@ -29,16 +29,18 @@ public override bool TryMakePreToilReservations()

private bool shouldCancelJob(ExtendedPawnData riderData)
{
if(riderData == null || riderData.mount == null)
if (interrupted)
{
//Log.Message("riderData is null or riderData.mount is null");
//Log.Message("cancel job, shouldEnd called");
return true;
}
if (shouldEnd)

if (riderData == null || riderData.mount == null)
{
//Log.Message("cancel job, shouldEnd called");
//Log.Message("riderData is null or riderData.mount is null");
return true;
}

Thing thing = pawn as Thing;
if (Rider.Downed || Rider.Dead || pawn.Downed || pawn.Dead || pawn.IsBurning() || Rider.IsBurning())
{
Expand Down Expand Up @@ -114,15 +116,23 @@ private Toil waitForRider()
{
//Log.Message("waiting for rider");

if (Rider == null || Rider.Dead || !Rider.Spawned || Rider.Downed || Rider.InMentalState)
{
interrupted = true;
ReadyForNextToil();
return;
}

riderData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(Rider);
if (riderData.mount != null && riderData.mount == pawn)
{
ReadyForNextToil();
}

if (Rider.CurJob.def != GUC_JobDefOf.Mount && Rider.CurJob.def != JobDefOf.Vomit && Rider.CurJob.def != JobDefOf.WaitMaintainPosture && Rider.CurJob.def != JobDefOf.SocialRelax && Rider.CurJob.def != JobDefOf.Wait && riderData.mount == null)
{
//Log.Message("cancel wait for rider, rider is not mounting, curJob: " + Rider.CurJob.def.defName);
shouldEnd = true;
interrupted = true;
ReadyForNextToil();
}

Expand Down Expand Up @@ -158,9 +168,10 @@ private Toil delegateMovement()

toil.AddFinishAction(delegate
{

FinishAction();
});

return toil;

}
Expand All @@ -171,9 +182,11 @@ private void FinishAction()
riderData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(Rider);
riderData.reset();
pawn.Drawer.tweener = new PawnTweener(pawn);
pawn.Position = Rider.Position;
if (!interrupted)
{
pawn.Position = Rider.Position;
}
pawn.pather.ResetToCurrentPosition();
Log.Message("before calling ExtraFinishAction");
}

private void tryAttackEnemy()
Expand Down

0 comments on commit c03342a

Please sign in to comment.