Skip to content

Commit

Permalink
adds better mechanitor placement
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Oct 24, 2022
1 parent 9fed401 commit 1583c47
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Binary file modified 1.4/Assemblies/AchtungMod.dll
Binary file not shown.
26 changes: 25 additions & 1 deletion Source/Colonist.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using RimWorld;
using UnityEngine;
using UnityEngine.UIElements;
using Verse;
using Verse.AI;
using static RimWorld.MechClusterSketch;
using static UnityEngine.GraphicsBuffer;

namespace AchtungMod
{
Expand Down Expand Up @@ -37,7 +40,28 @@ public IntVec3 UpdateOrderPos(Vector3 pos)
}
}

var bestCell = RCellFinder.BestOrderedGotoDestNear(cell, pawn);
var bestCell = IntVec3.Invalid;
if (ModsConfig.BiotechActive && pawn.IsColonyMech && MechanitorUtility.InMechanitorCommandRange(pawn, cell) == false)
{
var overseer = pawn.GetOverseer();
var map = overseer.MapHeld;
if (map == pawn.MapHeld)
{
var mechanitor = overseer.mechanitor;
foreach (var newPos in GenRadial.RadialCellsAround(cell, 20f, false))
if (mechanitor.CanCommandTo(newPos))
if (map.pawnDestinationReservationManager.CanReserve(newPos, pawn, true)
&& newPos.Standable(map)
&& pawn.CanReach(newPos, PathEndMode.OnCell, Danger.Deadly, false, false, TraverseMode.ByPawn)
)
{
bestCell = newPos;
break;
}
}
}
else
bestCell = RCellFinder.BestOrderedGotoDestNear(cell, pawn);
if (bestCell.InBounds(pawn.Map))
{
designation = bestCell;
Expand Down

0 comments on commit 1583c47

Please sign in to comment.