Files
ArachnaeSwarm/Source/ArachnaeSwarm/ARA_TrainingWork/JobClean/JobGiver_Cleaner.cs
2025-09-05 13:53:55 +08:00

53 lines
1.8 KiB
C#

using Verse;
using Verse.AI;
using RimWorld;
namespace ArachnaeSwarm
{
public class JobGiver_Cleaner : ThinkNode_JobGiver
{
private WorkGiver_ArachnaeClean _workGiver;
public override void ResolveReferences()
{
base.ResolveReferences();
// We instantiate our custom WorkGiver here.
// It doesn't need a Def because it's not a standard game WorkGiver.
_workGiver = new WorkGiver_ArachnaeClean();
}
protected override Job TryGiveJob(Pawn pawn)
{
if (_workGiver == null)
{
Log.ErrorOnce("JobGiver_Cleaner's WorkGiver is null. ResolveReferences was not called.", 91354);
return null;
}
// The WorkGiver will handle both filth and snow.
// We just need to find the closest potential job.
// The logic is simplified here; the real work is in the WorkGiver.
// Find the closest filth to clean
Thing closestFilth = _workGiver.FindClosestFilth(pawn);
if (closestFilth != null)
{
Job filthJob = _workGiver.JobOnThing(pawn, closestFilth);
if (filthJob != null) return filthJob;
}
// If no filth, check if there's any snow to clear at all before searching
if (pawn.Map.areaManager.SnowOrSandClear.TrueCount > 0)
{
IntVec3 closestSnowCell = _workGiver.FindClosestSnow(pawn);
if (closestSnowCell.IsValid)
{
Job snowJob = _workGiver.JobOnCell(pawn, closestSnowCell);
if (snowJob != null) return snowJob;
}
}
return null;
}
}
}