hediff能量

This commit is contained in:
2025-07-22 19:31:18 +08:00
parent 15494e8a8e
commit 0dcebba343
8 changed files with 36 additions and 12 deletions

View File

@@ -19,6 +19,11 @@ namespace WulaFallenEmpire
return null;
}
if (EnergyAvailableInRoomTo(prisoner))
{
return null;
}
if (!TryFindBestEnergySourceFor(pawn, prisoner, out Thing energySource, out _))
{
return null;
@@ -26,10 +31,27 @@ namespace WulaFallenEmpire
Job job = JobMaker.MakeJob(JobDefOf.DeliverFood, energySource, prisoner);
job.count = 1;
job.targetC = RCellFinder.SpotToChewStandingNear(prisoner, energySource);
return job;
}
private bool EnergyAvailableInRoomTo(Pawn prisoner)
{
if (prisoner.GetRoom() == null)
{
return false;
}
var allThings = prisoner.GetRoom().ContainedAndAdjacentThings;
foreach (Thing thing in allThings)
{
if (thing.def.GetModExtension<ThingDefExtension_EnergySource>() != null)
{
return true;
}
}
return false;
}
private bool TryFindBestEnergySourceFor(Pawn getter, Pawn eater, out Thing energySource, out ThingDef energyDef)
{
energySource = null;