搬运倒地的乌拉进维护
This commit is contained in:
Binary file not shown.
@@ -8,7 +8,14 @@
|
||||
<dismissEffects>
|
||||
<li>
|
||||
<conditions>
|
||||
</conditions>
|
||||
<li Class="WulaFallenEmpire.Condition_FactionExists">
|
||||
<!--
|
||||
这会设置 Condition_FactionExists 类中的 'factionDef' 字段。
|
||||
游戏会检查 defName 为 "Mechanoid" 的派系当前是否存在于世界地图上。
|
||||
-->
|
||||
<factionDef>Mechanoid</factionDef>
|
||||
</li>
|
||||
</conditions>
|
||||
<effects>
|
||||
<li Class="WulaFallenEmpire.Effect_TriggerRaid">
|
||||
<letterLabel>来自乌拉帝国 大教堂的进攻</letterLabel>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<isBad>false</isBad>
|
||||
<initialSeverity>0</initialSeverity>
|
||||
<minSeverity>0</minSeverity>
|
||||
<maxSeverity>2</maxSeverity>
|
||||
<maxSeverity>1</maxSeverity>
|
||||
<!--<lethalSeverity>2</lethalSeverity>-->
|
||||
<comps>
|
||||
<li Class="WulaFallenEmpire.HediffCompProperties_MaintenanceNeed">
|
||||
@@ -59,16 +59,6 @@
|
||||
</li>
|
||||
</capMods>
|
||||
</li>
|
||||
<li>
|
||||
<label>崩坏</label>
|
||||
<minSeverity>2.0</minSeverity>
|
||||
<capMods>
|
||||
<li>
|
||||
<capacity>Consciousness</capacity>
|
||||
<setMax>0.1</setMax>
|
||||
</li>
|
||||
</capMods>
|
||||
</li>
|
||||
</stages>
|
||||
</HediffDef>
|
||||
</Defs>
|
||||
@@ -22,6 +22,7 @@
|
||||
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
|
||||
</JobDef>
|
||||
|
||||
|
||||
<JobDef>
|
||||
<defName>WULA_HaulToMaintenancePod</defName>
|
||||
<driverClass>WulaFallenEmpire.JobDriver_HaulToMaintenancePod</driverClass>
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<!--
|
||||
这是一个如何使用 Condition_FactionExists 的示例。
|
||||
它定义了一个自定义事件,该事件只有在满足特定条件时才会触发。
|
||||
-->
|
||||
<WulaFallenEmpire.EventDef>
|
||||
<defName>MyCustomEvent_RequiresMechanoids</defName>
|
||||
<label>需要机械族的事件</label>
|
||||
<description>一个只有在机械族存在时才会发生的特殊事件。</description>
|
||||
|
||||
<!-- 在这里放置其他的事件相关属性, 例如事件的触发概率、效果等 -->
|
||||
|
||||
<conditions>
|
||||
<!--
|
||||
这是条件列表。游戏会检查所有这些条件是否都满足。
|
||||
'Class' 属性指定了要使用的 C# 条件类。
|
||||
-->
|
||||
<li Class="WulaFallenEmpire.Condition_FactionExists">
|
||||
<!--
|
||||
这会设置 Condition_FactionExists 类中的 'factionDef' 字段。
|
||||
游戏会检查 defName 为 "Mechanoid" 的派系当前是否存在于世界地图上。
|
||||
-->
|
||||
<factionDef>Mechanoid</factionDef>
|
||||
</li>
|
||||
|
||||
<!-- 您可以在这里添加更多的条件, 例如:
|
||||
<li Class="AnotherCondition">
|
||||
<someValue>123</someValue>
|
||||
</li>
|
||||
-->
|
||||
|
||||
</conditions>
|
||||
|
||||
<!--
|
||||
如果所有条件都满足,事件的效果将在这里定义。
|
||||
<effects>
|
||||
...
|
||||
</effects>
|
||||
-->
|
||||
|
||||
</WulaFallenEmpire.EventDef>
|
||||
|
||||
</Defs>
|
||||
@@ -147,8 +147,7 @@ namespace WulaFallenEmpire
|
||||
ticksRemaining = RequiredDuration(pawn);
|
||||
|
||||
// Move pawn inside
|
||||
pawn.DeSpawn();
|
||||
innerContainer.TryAdd(pawn, true);
|
||||
innerContainer.TryAddOrTransfer(pawn);
|
||||
}
|
||||
|
||||
private void CycleFinished()
|
||||
@@ -199,7 +198,10 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (state == MaintenancePodState.Running)
|
||||
{
|
||||
sb.AppendLine("Contains".Translate() + ": " + Occupant.NameShortColored.Resolve());
|
||||
if (Occupant != null)
|
||||
{
|
||||
sb.AppendLine("Contains".Translate() + ": " + Occupant.NameShortColored.Resolve());
|
||||
}
|
||||
sb.AppendLine("TimeLeft".Translate() + ": " + ticksRemaining.ToStringTicksToPeriod());
|
||||
}
|
||||
|
||||
@@ -264,7 +266,7 @@ namespace WulaFallenEmpire
|
||||
private List<FloatMenuOption> GetPawnOptions()
|
||||
{
|
||||
List<FloatMenuOption> options = new List<FloatMenuOption>();
|
||||
foreach (Pawn p in parent.Map.mapPawns.FreeColonists.Where(pawn => pawn.def == ThingDefOf_WULA.Wula))
|
||||
foreach (Pawn p in parent.Map.mapPawns.FreeColonists.Where(pawn => pawn.def.defName == "WulaSpecies" || pawn.def.defName == "WulaSpeciesReal"))
|
||||
{
|
||||
if (p.health.hediffSet.HasHediff(Props.hediffToRemove))
|
||||
{
|
||||
@@ -274,8 +276,38 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else if (p.Downed)
|
||||
{
|
||||
// This is handled by the WorkGiver, but we can add a note here if we want.
|
||||
// options.Add(new FloatMenuOption(p.LabelShortCap + " (" + "Incapacitated".Translate() + ")", null));
|
||||
float required = RequiredComponents(p);
|
||||
if (refuelableComp.Fuel < required)
|
||||
{
|
||||
options.Add(new FloatMenuOption(p.LabelShortCap + " (" + "Incapacitated".Translate() + ", " + "WULA_MaintenancePod_NotEnoughComponents".Translate(required.ToString("F0")) + ")", null));
|
||||
}
|
||||
else
|
||||
{
|
||||
Action action = delegate
|
||||
{
|
||||
var potentialRescuers = parent.Map.mapPawns.FreeColonistsSpawned.Where(colonist =>
|
||||
!colonist.Downed && colonist.CanReserveAndReach(p, PathEndMode.OnCell, Danger.Deadly) && colonist.CanReserveAndReach(parent, PathEndMode.InteractionCell, Danger.Deadly));
|
||||
|
||||
if (!potentialRescuers.Any())
|
||||
{
|
||||
Messages.Message("WULA_MaintenancePod_NoRescuer".Translate(p.Named("PAWN")), MessageTypeDefOf.RejectInput);
|
||||
return;
|
||||
}
|
||||
|
||||
var rescuerOptions = new List<FloatMenuOption>();
|
||||
foreach (var rescuer in potentialRescuers)
|
||||
{
|
||||
rescuerOptions.Add(new FloatMenuOption(rescuer.LabelCap, delegate
|
||||
{
|
||||
var haulJob = JobMaker.MakeJob(JobDefOf_WULA.WULA_HaulToMaintenancePod, p, parent);
|
||||
haulJob.count = 1;
|
||||
rescuer.jobs.TryTakeOrderedJob(haulJob, JobTag.Misc);
|
||||
}));
|
||||
}
|
||||
Find.WindowStack.Add(new FloatMenu(rescuerOptions));
|
||||
};
|
||||
options.Add(new FloatMenuOption(p.LabelShortCap + " (" + "Incapacitated".Translate() + ")", action));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace WulaFallenEmpire
|
||||
[DefOf]
|
||||
public static class JobDefOf_WULA
|
||||
{
|
||||
public static JobDef WULA_LoadComponentsToMaintenancePod;
|
||||
public static JobDef WULA_EnterMaintenancePod;
|
||||
|
||||
public static JobDef WULA_HaulToMaintenancePod;
|
||||
|
||||
static JobDefOf_WULA()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
|
||||
@@ -7,46 +7,50 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
public class JobDriver_HaulToMaintenancePod : JobDriver
|
||||
{
|
||||
private const TargetIndex PatientIndex = TargetIndex.A;
|
||||
private const TargetIndex TakeeIndex = TargetIndex.A;
|
||||
private const TargetIndex PodIndex = TargetIndex.B;
|
||||
|
||||
protected Pawn Patient => (Pawn)job.GetTarget(PatientIndex).Thing;
|
||||
protected Building_Bed Pod => (Building_Bed)job.GetTarget(PodIndex).Thing;
|
||||
protected Pawn Takee => (Pawn)job.GetTarget(TakeeIndex).Thing;
|
||||
protected Building Pod => (Building)job.GetTarget(PodIndex).Thing;
|
||||
protected CompMaintenancePod PodComp => Pod.TryGetComp<CompMaintenancePod>();
|
||||
|
||||
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
||||
{
|
||||
return pawn.Reserve(Patient, job, 1, -1, null, errorOnFailed) &&
|
||||
pawn.Reserve(Pod, job, 1, -1, null, errorOnFailed);
|
||||
return pawn.Reserve(Takee, job, 1, -1, null, errorOnFailed)
|
||||
&& pawn.Reserve(Pod, job, 1, -1, null, errorOnFailed);
|
||||
}
|
||||
|
||||
protected override IEnumerable<Toil> MakeNewToils()
|
||||
{
|
||||
this.FailOnDespawnedNullOrForbidden(PodIndex);
|
||||
this.FailOnDespawnedNullOrForbidden(PatientIndex);
|
||||
this.FailOnAggroMentalState(PatientIndex);
|
||||
this.FailOn(() => !Patient.Downed);
|
||||
// Standard failure conditions
|
||||
this.FailOnDestroyedOrNull(TakeeIndex);
|
||||
this.FailOnDestroyedOrNull(PodIndex);
|
||||
this.FailOnAggroMentalStateAndHostile(TakeeIndex);
|
||||
this.FailOn(() => PodComp == null); // Fail if the pod doesn't have our component
|
||||
this.FailOn(() => !pawn.CanReach(Pod, PathEndMode.InteractionCell, Danger.Deadly));
|
||||
this.FailOn(() => !Takee.Downed); // Can only haul downed pawns
|
||||
|
||||
var podComp = Pod.TryGetComp<CompMaintenancePod>();
|
||||
this.FailOn(() => podComp == null || podComp.State != MaintenancePodState.Idle || !podComp.PowerOn);
|
||||
// Go to the pawn to be rescued
|
||||
yield return Toils_Goto.GotoThing(TakeeIndex, PathEndMode.ClosestTouch)
|
||||
.FailOnDespawnedNullOrForbidden(TakeeIndex)
|
||||
.FailOnDespawnedNullOrForbidden(PodIndex)
|
||||
.FailOnSomeonePhysicallyInteracting(TakeeIndex);
|
||||
|
||||
// Go to the patient
|
||||
yield return Toils_Goto.GotoThing(PatientIndex, PathEndMode.OnCell);
|
||||
// Start carrying the pawn
|
||||
yield return Toils_Haul.StartCarryThing(TakeeIndex, false, true, false);
|
||||
|
||||
// Pick up the patient
|
||||
yield return Toils_Haul.StartCarryThing(PatientIndex);
|
||||
|
||||
// Carry the patient to the pod
|
||||
// Go to the maintenance pod
|
||||
yield return Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
|
||||
|
||||
// Place the patient in the pod
|
||||
yield return new Toil
|
||||
// Place the pawn inside the pod
|
||||
Toil placeInPod = ToilMaker.MakeToil("PlaceInPod");
|
||||
placeInPod.initAction = delegate
|
||||
{
|
||||
initAction = () =>
|
||||
{
|
||||
podComp.StartCycle(Patient);
|
||||
},
|
||||
defaultCompleteMode = ToilCompleteMode.Instant
|
||||
// The Comp will handle despawning the pawn and starting the cycle
|
||||
PodComp.StartCycle(Takee);
|
||||
};
|
||||
placeInPod.defaultCompleteMode = ToilCompleteMode.Instant;
|
||||
yield return placeInPod;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ namespace WulaFallenEmpire
|
||||
public static class ThingDefOf_WULA
|
||||
{
|
||||
public static ThingDef WULA_MaintenancePod;
|
||||
public static ThingDef Wula;
|
||||
|
||||
static ThingDefOf_WULA()
|
||||
{
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class WorkGiver_HaulToMaintenancePod : WorkGiver_Scanner
|
||||
{
|
||||
public override ThingRequest PotentialWorkThingRequest => ThingRequest.ForDef(ThingDefOf_WULA.WULA_MaintenancePod);
|
||||
|
||||
public override IEnumerable<Thing> PotentialWorkThingsGlobal(Pawn pawn)
|
||||
{
|
||||
return pawn.Map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf_WULA.WULA_MaintenancePod);
|
||||
}
|
||||
|
||||
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
|
||||
{
|
||||
if (!(t is Building pod) || !pawn.CanReserve(pod, 1, -1, null, forced))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var podComp = pod.GetComp<CompMaintenancePod>();
|
||||
if (podComp == null || podComp.State != MaintenancePodState.Idle || !podComp.PowerOn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Pawn patient = FindPatientFor(pawn, podComp);
|
||||
return patient != null && pawn.CanReserve(patient, 1, -1, null, forced);
|
||||
}
|
||||
|
||||
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
|
||||
{
|
||||
var pod = (Building)t;
|
||||
var podComp = pod.GetComp<CompMaintenancePod>();
|
||||
Pawn patient = FindPatientFor(pawn, podComp);
|
||||
if (patient == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return JobMaker.MakeJob(JobDefOf_WULA.WULA_HaulToMaintenancePod, patient, pod);
|
||||
}
|
||||
|
||||
private Pawn FindPatientFor(Pawn rescuer, CompMaintenancePod podComp)
|
||||
{
|
||||
return rescuer.Map.mapPawns.AllPawnsSpawned
|
||||
.Where(p => p.def == ThingDefOf_WULA.Wula &&
|
||||
p.Faction == rescuer.Faction &&
|
||||
!p.IsForbidden(rescuer) &&
|
||||
p.Downed && // Key condition: pawn cannot walk
|
||||
p.health.hediffSet.HasHediff(podComp.Props.hediffToRemove) &&
|
||||
podComp.RequiredComponents(p) <= podComp.parent.GetComp<CompRefuelable>().Fuel &&
|
||||
rescuer.CanReserve(p))
|
||||
.OrderBy(p => p.Position.DistanceTo(rescuer.Position))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,6 @@
|
||||
<Compile Include="Verb\Verb_ShootBeamExplosive.cs" />
|
||||
<Compile Include="Verb\VerbPropertiesExplosiveBeam.cs" />
|
||||
<Compile Include="WorkGiver_FeedWulaPatient.cs" />
|
||||
<Compile Include="WorkGiver_HaulToMaintenancePod.cs" />
|
||||
<Compile Include="WorkGiver_Warden_DeliverEnergy.cs" />
|
||||
<Compile Include="WorkGiver_Warden_FeedWula.cs" />
|
||||
<Compile Include="WorkGiverDefExtension_FeedWula.cs" />
|
||||
|
||||
Reference in New Issue
Block a user