存
This commit is contained in:
Binary file not shown.
13
1.6/1.6/Defs/JobDefs/SuperCarry_JobDef.xml
Normal file
13
1.6/1.6/Defs/JobDefs/SuperCarry_JobDef.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
|
||||
<JobDef>
|
||||
<defName>SuperCarry</defName>
|
||||
<driverClass>ArachnaeSwarm.JobDriver_SuperCarry</driverClass>
|
||||
<reportString>正在超级携带 TargetA。</reportString>
|
||||
<suspendable>false</suspendable>
|
||||
<allowOpportunisticPrefix>true</allowOpportunisticPrefix>
|
||||
<carryThingAfterJob>true</carryThingAfterJob>
|
||||
</JobDef>
|
||||
|
||||
</Defs>
|
||||
@@ -261,6 +261,13 @@
|
||||
<apparelTags>
|
||||
</apparelTags>
|
||||
<apparelMoney>0</apparelMoney>
|
||||
<modExtensions>
|
||||
<li Class="ArachnaeSwarm.SuperCarryExtension">
|
||||
<canSuperCarry>true</canSuperCarry>
|
||||
<requiresFlight>true</requiresFlight>
|
||||
<canCarryHostile>false</canCarryHostile>
|
||||
</li>
|
||||
</modExtensions>
|
||||
</PawnKindDef>
|
||||
<PawnKindDef ParentName="ArachnaeNodeABasePawnKind">
|
||||
<defName>ArachnaeNode_Race_NeuroSwarm</defName>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<LanguageData>
|
||||
|
||||
<SuperCarry>强制携带 {0}</SuperCarry>
|
||||
|
||||
</LanguageData>
|
||||
@@ -222,6 +222,11 @@
|
||||
<Compile Include="HarmonyPatches\Patch_ForceTargetable.cs" />
|
||||
<Compile Include="Building_Comps\CompForceTargetable.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="SuperCarryExtension.cs" />
|
||||
<Compile Include="FloatMenuOptionProvider_SuperCarry.cs" />
|
||||
<Compile Include="JobDriver_SuperCarry.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Buildings\Wormhole\Building_WormholePortal_A.cs" />
|
||||
<Compile Include="Buildings\Wormhole\Building_WormholePortal_B.cs" />
|
||||
|
||||
63
Source/ArachnaeSwarm/FloatMenuOptionProvider_SuperCarry.cs
Normal file
63
Source/ArachnaeSwarm/FloatMenuOptionProvider_SuperCarry.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class FloatMenuOptionProvider_SuperCarry : FloatMenuOptionProvider
|
||||
{
|
||||
protected override bool Drafted => true;
|
||||
protected override bool Undrafted => false;
|
||||
protected override bool Multiselect => false;
|
||||
protected override bool RequiresManipulation => true;
|
||||
|
||||
protected override bool AppliesInt(FloatMenuContext context)
|
||||
{
|
||||
var extension = context.FirstSelectedPawn.kindDef.GetModExtension<SuperCarryExtension>();
|
||||
if (extension == null || !extension.canSuperCarry)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (extension.requiresFlight)
|
||||
{
|
||||
if (context.FirstSelectedPawn.flight == null || !context.FirstSelectedPawn.flight.Flying)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override FloatMenuOption GetSingleOptionFor(Pawn clickedPawn, FloatMenuContext context)
|
||||
{
|
||||
Pawn carrier = context.FirstSelectedPawn;
|
||||
var extension = carrier.kindDef.GetModExtension<SuperCarryExtension>();
|
||||
|
||||
if (clickedPawn == carrier) return null;
|
||||
|
||||
// 新增:检查是否允许携带敌对单位
|
||||
if (clickedPawn.HostileTo(Faction.OfPlayer) && (extension == null || !extension.canCarryHostile))
|
||||
{
|
||||
return new FloatMenuOption("CannotCarry".Translate(clickedPawn) + ": " + "CarriedPawnHostile".Translate(), null);
|
||||
}
|
||||
|
||||
if (!carrier.CanReach(clickedPawn, PathEndMode.ClosestTouch, Danger.Deadly))
|
||||
{
|
||||
return new FloatMenuOption("CannotCarry".Translate(clickedPawn) + ": " + "NoPath".Translate().CapitalizeFirst(), null);
|
||||
}
|
||||
if (!carrier.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
|
||||
{
|
||||
return new FloatMenuOption("CannotCarry".Translate(carrier) + ": " + "Incapable".Translate().CapitalizeFirst(), null);
|
||||
}
|
||||
|
||||
return FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("SuperCarry".Translate(clickedPawn.LabelShort, clickedPawn), delegate
|
||||
{
|
||||
Job job = JobMaker.MakeJob(DefDatabase<JobDef>.GetNamed("SuperCarry"), clickedPawn);
|
||||
job.count = 1;
|
||||
carrier.jobs.TryTakeOrderedJob(job, JobTag.Misc);
|
||||
}), carrier, clickedPawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Source/ArachnaeSwarm/JobDriver_SuperCarry.cs
Normal file
31
Source/ArachnaeSwarm/JobDriver_SuperCarry.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class JobDriver_SuperCarry : JobDriver
|
||||
{
|
||||
private const TargetIndex TakeeIndex = TargetIndex.A;
|
||||
|
||||
protected Pawn Takee => (Pawn)job.GetTarget(TargetIndex.A).Thing;
|
||||
|
||||
public override bool TryMakePreToilReservations(bool errorOnFailed)
|
||||
{
|
||||
return pawn.Reserve(Takee, job, 1, -1, null, errorOnFailed);
|
||||
}
|
||||
|
||||
protected override IEnumerable<Toil> MakeNewToils()
|
||||
{
|
||||
this.FailOnDestroyedOrNull(TargetIndex.A);
|
||||
this.FailOnAggroMentalState(TargetIndex.A);
|
||||
|
||||
yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch)
|
||||
.FailOnDespawnedNullOrForbidden(TargetIndex.A)
|
||||
.FailOnSomeonePhysicallyInteracting(TargetIndex.A);
|
||||
|
||||
yield return Toils_Haul.StartCarryThing(TargetIndex.A);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Source/ArachnaeSwarm/SuperCarryExtension.cs
Normal file
11
Source/ArachnaeSwarm/SuperCarryExtension.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
public class SuperCarryExtension : DefModExtension
|
||||
{
|
||||
public bool canSuperCarry = false;
|
||||
public bool requiresFlight = false;
|
||||
public bool canCarryHostile = false; // 新增字段
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user