搬运倒地的乌拉进维护
This commit is contained in:
Binary file not shown.
@@ -8,7 +8,14 @@
|
|||||||
<dismissEffects>
|
<dismissEffects>
|
||||||
<li>
|
<li>
|
||||||
<conditions>
|
<conditions>
|
||||||
</conditions>
|
<li Class="WulaFallenEmpire.Condition_FactionExists">
|
||||||
|
<!--
|
||||||
|
这会设置 Condition_FactionExists 类中的 'factionDef' 字段。
|
||||||
|
游戏会检查 defName 为 "Mechanoid" 的派系当前是否存在于世界地图上。
|
||||||
|
-->
|
||||||
|
<factionDef>Mechanoid</factionDef>
|
||||||
|
</li>
|
||||||
|
</conditions>
|
||||||
<effects>
|
<effects>
|
||||||
<li Class="WulaFallenEmpire.Effect_TriggerRaid">
|
<li Class="WulaFallenEmpire.Effect_TriggerRaid">
|
||||||
<letterLabel>来自乌拉帝国 大教堂的进攻</letterLabel>
|
<letterLabel>来自乌拉帝国 大教堂的进攻</letterLabel>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<isBad>false</isBad>
|
<isBad>false</isBad>
|
||||||
<initialSeverity>0</initialSeverity>
|
<initialSeverity>0</initialSeverity>
|
||||||
<minSeverity>0</minSeverity>
|
<minSeverity>0</minSeverity>
|
||||||
<maxSeverity>2</maxSeverity>
|
<maxSeverity>1</maxSeverity>
|
||||||
<!--<lethalSeverity>2</lethalSeverity>-->
|
<!--<lethalSeverity>2</lethalSeverity>-->
|
||||||
<comps>
|
<comps>
|
||||||
<li Class="WulaFallenEmpire.HediffCompProperties_MaintenanceNeed">
|
<li Class="WulaFallenEmpire.HediffCompProperties_MaintenanceNeed">
|
||||||
@@ -59,16 +59,6 @@
|
|||||||
</li>
|
</li>
|
||||||
</capMods>
|
</capMods>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<label>崩坏</label>
|
|
||||||
<minSeverity>2.0</minSeverity>
|
|
||||||
<capMods>
|
|
||||||
<li>
|
|
||||||
<capacity>Consciousness</capacity>
|
|
||||||
<setMax>0.1</setMax>
|
|
||||||
</li>
|
|
||||||
</capMods>
|
|
||||||
</li>
|
|
||||||
</stages>
|
</stages>
|
||||||
</HediffDef>
|
</HediffDef>
|
||||||
</Defs>
|
</Defs>
|
||||||
@@ -22,6 +22,7 @@
|
|||||||
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
|
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
|
||||||
</JobDef>
|
</JobDef>
|
||||||
|
|
||||||
|
|
||||||
<JobDef>
|
<JobDef>
|
||||||
<defName>WULA_HaulToMaintenancePod</defName>
|
<defName>WULA_HaulToMaintenancePod</defName>
|
||||||
<driverClass>WulaFallenEmpire.JobDriver_HaulToMaintenancePod</driverClass>
|
<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);
|
ticksRemaining = RequiredDuration(pawn);
|
||||||
|
|
||||||
// Move pawn inside
|
// Move pawn inside
|
||||||
pawn.DeSpawn();
|
innerContainer.TryAddOrTransfer(pawn);
|
||||||
innerContainer.TryAdd(pawn, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CycleFinished()
|
private void CycleFinished()
|
||||||
@@ -199,7 +198,10 @@ namespace WulaFallenEmpire
|
|||||||
|
|
||||||
if (state == MaintenancePodState.Running)
|
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());
|
sb.AppendLine("TimeLeft".Translate() + ": " + ticksRemaining.ToStringTicksToPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,7 +266,7 @@ namespace WulaFallenEmpire
|
|||||||
private List<FloatMenuOption> GetPawnOptions()
|
private List<FloatMenuOption> GetPawnOptions()
|
||||||
{
|
{
|
||||||
List<FloatMenuOption> options = new List<FloatMenuOption>();
|
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))
|
if (p.health.hediffSet.HasHediff(Props.hediffToRemove))
|
||||||
{
|
{
|
||||||
@@ -274,8 +276,38 @@ namespace WulaFallenEmpire
|
|||||||
}
|
}
|
||||||
else if (p.Downed)
|
else if (p.Downed)
|
||||||
{
|
{
|
||||||
// This is handled by the WorkGiver, but we can add a note here if we want.
|
float required = RequiredComponents(p);
|
||||||
// options.Add(new FloatMenuOption(p.LabelShortCap + " (" + "Incapacitated".Translate() + ")", null));
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ namespace WulaFallenEmpire
|
|||||||
[DefOf]
|
[DefOf]
|
||||||
public static class JobDefOf_WULA
|
public static class JobDefOf_WULA
|
||||||
{
|
{
|
||||||
public static JobDef WULA_LoadComponentsToMaintenancePod;
|
|
||||||
public static JobDef WULA_EnterMaintenancePod;
|
public static JobDef WULA_EnterMaintenancePod;
|
||||||
|
|
||||||
public static JobDef WULA_HaulToMaintenancePod;
|
public static JobDef WULA_HaulToMaintenancePod;
|
||||||
|
|
||||||
static JobDefOf_WULA()
|
static JobDefOf_WULA()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using RimWorld;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using RimWorld;
|
||||||
using Verse;
|
using Verse;
|
||||||
using Verse.AI;
|
using Verse.AI;
|
||||||
|
|
||||||
@@ -7,46 +7,50 @@ namespace WulaFallenEmpire
|
|||||||
{
|
{
|
||||||
public class JobDriver_HaulToMaintenancePod : JobDriver
|
public class JobDriver_HaulToMaintenancePod : JobDriver
|
||||||
{
|
{
|
||||||
private const TargetIndex PatientIndex = TargetIndex.A;
|
private const TargetIndex TakeeIndex = TargetIndex.A;
|
||||||
private const TargetIndex PodIndex = TargetIndex.B;
|
private const TargetIndex PodIndex = TargetIndex.B;
|
||||||
|
|
||||||
protected Pawn Patient => (Pawn)job.GetTarget(PatientIndex).Thing;
|
protected Pawn Takee => (Pawn)job.GetTarget(TakeeIndex).Thing;
|
||||||
protected Building_Bed Pod => (Building_Bed)job.GetTarget(PodIndex).Thing;
|
protected Building Pod => (Building)job.GetTarget(PodIndex).Thing;
|
||||||
|
protected CompMaintenancePod PodComp => Pod.TryGetComp<CompMaintenancePod>();
|
||||||
|
|
||||||
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
||||||
{
|
{
|
||||||
return pawn.Reserve(Patient, job, 1, -1, null, errorOnFailed) &&
|
return pawn.Reserve(Takee, job, 1, -1, null, errorOnFailed)
|
||||||
pawn.Reserve(Pod, job, 1, -1, null, errorOnFailed);
|
&& pawn.Reserve(Pod, job, 1, -1, null, errorOnFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<Toil> MakeNewToils()
|
protected override IEnumerable<Toil> MakeNewToils()
|
||||||
{
|
{
|
||||||
this.FailOnDespawnedNullOrForbidden(PodIndex);
|
// Standard failure conditions
|
||||||
this.FailOnDespawnedNullOrForbidden(PatientIndex);
|
this.FailOnDestroyedOrNull(TakeeIndex);
|
||||||
this.FailOnAggroMentalState(PatientIndex);
|
this.FailOnDestroyedOrNull(PodIndex);
|
||||||
this.FailOn(() => !Patient.Downed);
|
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>();
|
// Go to the pawn to be rescued
|
||||||
this.FailOn(() => podComp == null || podComp.State != MaintenancePodState.Idle || !podComp.PowerOn);
|
yield return Toils_Goto.GotoThing(TakeeIndex, PathEndMode.ClosestTouch)
|
||||||
|
.FailOnDespawnedNullOrForbidden(TakeeIndex)
|
||||||
|
.FailOnDespawnedNullOrForbidden(PodIndex)
|
||||||
|
.FailOnSomeonePhysicallyInteracting(TakeeIndex);
|
||||||
|
|
||||||
// Go to the patient
|
// Start carrying the pawn
|
||||||
yield return Toils_Goto.GotoThing(PatientIndex, PathEndMode.OnCell);
|
yield return Toils_Haul.StartCarryThing(TakeeIndex, false, true, false);
|
||||||
|
|
||||||
// Pick up the patient
|
// Go to the maintenance pod
|
||||||
yield return Toils_Haul.StartCarryThing(PatientIndex);
|
|
||||||
|
|
||||||
// Carry the patient to the pod
|
|
||||||
yield return Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
|
yield return Toils_Goto.GotoThing(PodIndex, PathEndMode.InteractionCell);
|
||||||
|
|
||||||
// Place the patient in the pod
|
// Place the pawn inside the pod
|
||||||
yield return new Toil
|
Toil placeInPod = ToilMaker.MakeToil("PlaceInPod");
|
||||||
|
placeInPod.initAction = delegate
|
||||||
{
|
{
|
||||||
initAction = () =>
|
// The Comp will handle despawning the pawn and starting the cycle
|
||||||
{
|
PodComp.StartCycle(Takee);
|
||||||
podComp.StartCycle(Patient);
|
|
||||||
},
|
|
||||||
defaultCompleteMode = ToilCompleteMode.Instant
|
|
||||||
};
|
};
|
||||||
|
placeInPod.defaultCompleteMode = ToilCompleteMode.Instant;
|
||||||
|
yield return placeInPod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@ namespace WulaFallenEmpire
|
|||||||
public static class ThingDefOf_WULA
|
public static class ThingDefOf_WULA
|
||||||
{
|
{
|
||||||
public static ThingDef WULA_MaintenancePod;
|
public static ThingDef WULA_MaintenancePod;
|
||||||
public static ThingDef Wula;
|
|
||||||
|
|
||||||
static ThingDefOf_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\Verb_ShootBeamExplosive.cs" />
|
||||||
<Compile Include="Verb\VerbPropertiesExplosiveBeam.cs" />
|
<Compile Include="Verb\VerbPropertiesExplosiveBeam.cs" />
|
||||||
<Compile Include="WorkGiver_FeedWulaPatient.cs" />
|
<Compile Include="WorkGiver_FeedWulaPatient.cs" />
|
||||||
<Compile Include="WorkGiver_HaulToMaintenancePod.cs" />
|
|
||||||
<Compile Include="WorkGiver_Warden_DeliverEnergy.cs" />
|
<Compile Include="WorkGiver_Warden_DeliverEnergy.cs" />
|
||||||
<Compile Include="WorkGiver_Warden_FeedWula.cs" />
|
<Compile Include="WorkGiver_Warden_FeedWula.cs" />
|
||||||
<Compile Include="WorkGiverDefExtension_FeedWula.cs" />
|
<Compile Include="WorkGiverDefExtension_FeedWula.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user