修医生抢喂食工作
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -90,7 +90,7 @@
|
|||||||
"RelativeDocumentMoniker": "CompApparelInterceptor.cs",
|
"RelativeDocumentMoniker": "CompApparelInterceptor.cs",
|
||||||
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompApparelInterceptor.cs",
|
"ToolTip": "C:\\Steam\\steamapps\\common\\RimWorld\\Mods\\3516260226\\Source\\WulaFallenEmpire\\CompApparelInterceptor.cs",
|
||||||
"RelativeToolTip": "CompApparelInterceptor.cs",
|
"RelativeToolTip": "CompApparelInterceptor.cs",
|
||||||
"ViewState": "AQIAAAAAAAAAAAAAAAAAAFMBAAAMAAAA",
|
"ViewState": "AQIAAAAAAAAAAAAAAAAAAFQBAAAMAAAA",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2025-07-23T10:03:31.989Z",
|
"WhenOpened": "2025-07-23T10:03:31.989Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace WulaFallenEmpire
|
|||||||
[StaticConstructorOnStartup]
|
[StaticConstructorOnStartup]
|
||||||
public class CompApparelInterceptor : ThingComp
|
public class CompApparelInterceptor : ThingComp
|
||||||
{
|
{
|
||||||
// 状态变量
|
// 状态变量
|
||||||
private int lastInterceptTicks = -999999;
|
private int lastInterceptTicks = -999999;
|
||||||
private int startedChargingTick = -1;
|
private int startedChargingTick = -1;
|
||||||
private bool shutDown;
|
private bool shutDown;
|
||||||
@@ -62,17 +62,17 @@ namespace WulaFallenEmpire
|
|||||||
private int ticksToReset;
|
private int ticksToReset;
|
||||||
private int activatedTick = -999999;
|
private int activatedTick = -999999;
|
||||||
|
|
||||||
// 视觉效果变量
|
// 视觉效果变量
|
||||||
private float lastInterceptAngle;
|
private float lastInterceptAngle;
|
||||||
private bool drawInterceptCone;
|
private bool drawInterceptCone;
|
||||||
|
|
||||||
// 静态资源
|
// 静态资源
|
||||||
private static readonly Material ForceFieldMat = MaterialPool.MatFrom("Other/ForceField", ShaderDatabase.MoteGlow);
|
private static readonly Material ForceFieldMat = MaterialPool.MatFrom("Other/ForceField", ShaderDatabase.MoteGlow);
|
||||||
private static readonly Material ForceFieldConeMat = MaterialPool.MatFrom("Other/ForceFieldCone", ShaderDatabase.MoteGlow);
|
private static readonly Material ForceFieldConeMat = MaterialPool.MatFrom("Other/ForceFieldCone", ShaderDatabase.MoteGlow);
|
||||||
private static readonly MaterialPropertyBlock MatPropertyBlock = new MaterialPropertyBlock();
|
private static readonly MaterialPropertyBlock MatPropertyBlock = new MaterialPropertyBlock();
|
||||||
private static readonly Color InactiveColor = new Color(0.2f, 0.2f, 0.2f);
|
private static readonly Color InactiveColor = new Color(0.2f, 0.2f, 0.2f);
|
||||||
|
|
||||||
// 属性
|
// 属性
|
||||||
public CompProperties_ApparelInterceptor Props => (CompProperties_ApparelInterceptor)props;
|
public CompProperties_ApparelInterceptor Props => (CompProperties_ApparelInterceptor)props;
|
||||||
private Pawn PawnOwner => (parent as Apparel)?.Wearer;
|
private Pawn PawnOwner => (parent as Apparel)?.Wearer;
|
||||||
|
|
||||||
@@ -320,6 +320,7 @@ namespace WulaFallenEmpire
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StaticConstructorOnStartup]
|
||||||
public class Gizmo_EnergyShieldStatus : Gizmo
|
public class Gizmo_EnergyShieldStatus : Gizmo
|
||||||
{
|
{
|
||||||
public CompApparelInterceptor shield;
|
public CompApparelInterceptor shield;
|
||||||
@@ -355,4 +356,4 @@ namespace WulaFallenEmpire
|
|||||||
return new GizmoResult(GizmoState.Clear);
|
return new GizmoResult(GizmoState.Clear);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace WulaFallenEmpire
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pawn.CanReserve(patient, 1, -1, null, forced))
|
if (!pawn.CanReserveAndReach(patient, PathEndMode.Touch, Danger.Deadly, 1, -1, null, forced))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pawn.CanReserve(prisoner, 1, -1, null, forced))
|
if (!pawn.CanReserveAndReach(prisoner, PathEndMode.Touch, Danger.Deadly, 1, -1, null, forced))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,41 +5,55 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace WulaFallenEmpire
|
namespace WulaFallenEmpire
|
||||||
{
|
{
|
||||||
public class WorkGiver_Warden_FeedWula : WorkGiver_Warden
|
public class WorkGiver_Warden_FeedWula : WorkGiver_Scanner
|
||||||
{
|
{
|
||||||
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
|
public override ThingRequest PotentialWorkThingRequest => ThingRequest.ForGroup(ThingRequestGroup.Pawn);
|
||||||
|
|
||||||
|
public override PathEndMode PathEndMode => PathEndMode.ClosestTouch;
|
||||||
|
|
||||||
|
public override Danger MaxPathDanger(Pawn pawn) => Danger.Deadly;
|
||||||
|
|
||||||
|
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
|
||||||
{
|
{
|
||||||
if (!(t is Pawn prisoner) || !ShouldFeed(pawn, prisoner))
|
if (!(t is Pawn prisoner) || pawn == prisoner)
|
||||||
{
|
return false;
|
||||||
return null;
|
|
||||||
}
|
if (!ShouldFeed(pawn, prisoner))
|
||||||
|
return false;
|
||||||
|
|
||||||
Need_WulaEnergy energyNeed = prisoner.needs.TryGetNeed<Need_WulaEnergy>();
|
Need_WulaEnergy energyNeed = prisoner.needs.TryGetNeed<Need_WulaEnergy>();
|
||||||
var extension = def.GetModExtension<WorkGiverDefExtension_FeedWula>();
|
var extension = def.GetModExtension<WorkGiverDefExtension_FeedWula>();
|
||||||
if (energyNeed == null || energyNeed.CurLevelPercentage >= extension.feedThreshold)
|
if (energyNeed == null || energyNeed.CurLevelPercentage >= extension.feedThreshold)
|
||||||
{
|
return false;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prisoner.health.hediffSet.HasHediff(DefDatabase<HediffDef>.GetNamed("WULA_ChargingHediff")))
|
if (prisoner.health.hediffSet.HasHediff(DefDatabase<HediffDef>.GetNamed("WULA_ChargingHediff")))
|
||||||
{
|
return false;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The prisoner must be in bed to be fed by a warden. If the job is not forced, they must also be unable to move.
|
|
||||||
if (!prisoner.InBed() || (!forced && prisoner.health.capacities.CapableOf(PawnCapacityDefOf.Moving)))
|
if (!prisoner.InBed() || (!forced && prisoner.health.capacities.CapableOf(PawnCapacityDefOf.Moving)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!pawn.CanReserveAndReach(prisoner, PathEndMode.Touch, Danger.Deadly, 1, -1, null, forced))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!TryFindBestEnergySourceFor(pawn, prisoner, out _, out _))
|
||||||
{
|
{
|
||||||
return null;
|
JobFailReason.Is("NoWulaEnergyToFeed".Translate(prisoner.LabelShort, prisoner));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TryFindBestEnergySourceFor(pawn, prisoner, out Thing energySource, out _))
|
return true;
|
||||||
{
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Job job = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("WULA_FeedWulaPatient"), energySource, prisoner);
|
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
|
||||||
job.count = 1;
|
{
|
||||||
return job;
|
Pawn prisoner = (Pawn)t;
|
||||||
|
if (TryFindBestEnergySourceFor(pawn, prisoner, out Thing energySource, out _))
|
||||||
|
{
|
||||||
|
Job job = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("WULA_FeedWulaPatient"), energySource, prisoner);
|
||||||
|
job.count = 1;
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldFeed(Pawn warden, Pawn prisoner)
|
private bool ShouldFeed(Pawn warden, Pawn prisoner)
|
||||||
|
|||||||
Reference in New Issue
Block a user