Skip to content

Commit

Permalink
commented out problematic patch
Browse files Browse the repository at this point in the history
stuck with spawn issues
  • Loading branch information
Sn1p3rr3c0n committed Aug 1, 2023
1 parent 3bf86cf commit d5f10f8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Patch_ClosestThingReachable
{
public static void Postfix(Thing __result, ThingRequest thingReq)
{
Log.Message($"ClosestThingReachable returns {__result} for {thingReq} -- region: {thingReq.CanBeFoundInRegion}");
// Log.Message($"ClosestThingReachable returns {__result} for {thingReq} -- region: {thingReq.CanBeFoundInRegion}");
}


Expand Down Expand Up @@ -187,7 +187,7 @@ public static IEnumerable<Thing> ThingsWithColdStorage(IEnumerable<Thing> baseLi
foreach(var b in storage)
{
things.AddRange((b as Building_ColdStorage).StoredItems);
Log.Message($"added items form {b}");
// Log.Message($"added items form {b}");
}

return things;
Expand Down Expand Up @@ -255,7 +255,7 @@ Be aware of distance calc
"//Note that could also enhance the Logic for DSU Access and vs stuff on the floor"
*/
[HarmonyPatch(typeof(RegionProcessorClosestThingReachable), "RegionProcessor")]
/* [HarmonyPatch(typeof(RegionProcessorClosestThingReachable), "RegionProcessor")]
public class Patch_RegionProcessorClosestThingReachable_RegionProcessor
{
Expand Down Expand Up @@ -462,9 +462,11 @@ static IntVec3 GetPosition(Thing thing)
/*
Katia started 10 jobs in one tick. newJob=HaulToContainer (Job_61312) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429 jobGiver=RimWorld.JobGiver_Work jobList=(Wait_Combat (Job_60887) A=(169, 0, 159))
(BuildRoof (Job_61106) A=(172, 0, 156) B=(172, 0, 156)) (HaulToContainer (Job_61296) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430
C=Thing_Blueprint_Wall68429) (HaulToContainer (Job_61298) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
Katia started 10 jobs in one tick. newJob=HaulToContainer (Job_61312) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429 jobGiver=RimWorld.JobGiver_Work jobList=
(Wait_Combat (Job_60887) A=(169, 0, 159))
(BuildRoof (Job_61106) A=(172, 0, 156) B=(172, 0, 156))
(HaulToContainer (Job_61296) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
(HaulToContainer (Job_61298) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
(HaulToContainer (Job_61300) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
(HaulToContainer (Job_61302) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
(HaulToContainer (Job_61304) A=Thing_Steel66075 B=Thing_Blueprint_Wall68430 C=Thing_Blueprint_Wall68429)
Expand All @@ -476,4 +478,6 @@ static IntVec3 GetPosition(Thing thing)
Maybe a job interruption is the issue
*/


}
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC
, ThinkTreeDef thinkTree = null, JobTag? tag = null, bool fromQueue = false, bool canReturnCurJobToPool = false)
{

// Log.Message($"{newJob} - {jobGiver} - {___pawn}");
ShouldGetItem = false;
// Log.Message($"{newJob} - {jobGiver} - {___pawn}");
// TODO Enable that again
// ShouldGetItem = false;
if (newJob.def == PRFDefOf.PRF_GotoAdvanced) return true;
//No random moths eating my cloths
if (___pawn?.Faction == null || !___pawn.Faction.IsPlayer) return true;
Expand All @@ -88,7 +89,7 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC
{
if (target.Thing == null)
{
//Log.Error($"ProjectRimfactory - Patch_Pawn_JobTracker_StartJob - Null Thing as Target: {target} - pawn:{___pawn} - Job:{newJob}");
//Log.Error($"ProjectRimfactory - Patch_Pawn_JobTracker_StartJob - Null Thing as Target: {target} - pawn:{___pawn} - Job:{newJob}");
continue;
}

Expand All @@ -97,14 +98,15 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC
//Quick check if the Item could be in a DSU
//Might have false Positives They are then filterd by AdvancedIO_PatchHelper.CanMoveItem
//But should not have false Negatives
if (prfmapcomp.ShouldHideItemsAtPos(target.Cell))
if (prfmapcomp.ShouldHideItemsAtPos(target.Cell) || target.Thing.ParentHolder is Building_ColdStorage)
{
Log.Message($"Maybe cold storage {target} - {target.Thing}");
foreach (var port in Ports)
{
var PortIsCloser = port.Key < DistanceToTarget;
if (PortIsCloser || (ConditionalPatchHelper.Patch_Reachability_CanReach.Status && ___pawn.Map.reachability.CanReach(___pawn.Position, target.Thing, Verse.AI.PathEndMode.Touch, TraverseParms.For(___pawn)) && Patch_Reachability_CanReach.CanReachThing(target.Thing)))
{
if (AdvancedIO_PatchHelper.CanMoveItem(port.Value, target.Cell))
if (AdvancedIO_PatchHelper.CanMoveItem(port.Value, target.Cell) || port.Value.boundStorageUnit == target.Thing.ParentHolder)
{
// port.Value.AddItemToQueue(target.Thing);
// port.Value.updateQueue();
Expand All @@ -123,6 +125,10 @@ public static bool Prefix(Job newJob, ref Pawn ___pawn, JobCondition lastJobEndC
}
}
}
else
{
Log.Message($"Checking {target} - {target.Thing} - {target.Thing?.Position}");
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,28 @@ public void updateQueue()

public void PlaceThingNow(Thing thing)
{
if (thing != null)
{
thing.Position = this.Position;
}
Log.Message($"PlaceThingNow {thing}");
if (thing.stackCount <= 0) boundStorageUnit.HandleMoveItem(thing);

GenSpawn.Spawn(thing, WorkPosition, Map);
Log.Message($"Should have placed {thing}@{thing.Position} to {WorkPosition} - Spawned: {thing.Spawned}");

}

public override void Tick()
{
updateQueue();

/*
if (this.IsHashIntervalTick(10))
{
var thing = GetstoredItem();
if (thing != null && !this.Map.reservationManager.AllReservedThings().Contains(thing))
{
RefreshInput();
RefreshInput();
}
}
*/

}

Expand Down

0 comments on commit d5f10f8

Please sign in to comment.