This commit is contained in:
2025-09-02 12:21:49 +08:00
parent 06b0a74cbd
commit 61a7013946
12 changed files with 657 additions and 9 deletions

View File

@@ -83,7 +83,7 @@
<Compile Include="HediffComp_HiveMindDrone.cs" />
<Compile Include="CompAbilityEffect_BindDrone.cs" />
<Compile Include="CompProperties_AbilityBindDrone.cs" />
<Compile Include="Alert_UnlinkedHiveMindDrone.cs" />
<Compile Include="JobGiver_MaintainBuildings.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -9,7 +9,7 @@ namespace ArachnaeSwarm
{
public List<PawnKindDef> pawnKinds;
public List<PawnKindDef> whitelist;
public int delay = 0;
public List<PawnKindDelay> pawnKindDelays;
public bool destroyOnSpawn = false;
public IntRange spawnCount = new IntRange(1, 1);
public Type lordJob;
@@ -32,4 +32,10 @@ namespace ArachnaeSwarm
}
}
}
}
public class PawnKindDelay
{
public PawnKindDef pawnKind;
public int delay;
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Verse;
using RimWorld;
using Verse.AI;
@@ -45,7 +46,8 @@ namespace ArachnaeSwarm
public void StartIncubation()
{
spawningPawnKind = selectedPawnKind;
spawnUntilTick = Find.TickManager.TicksGame + Props.delay;
int delay = Props.pawnKindDelays?.FirstOrDefault(pkd => pkd.pawnKind == selectedPawnKind)?.delay ?? 0;
spawnUntilTick = Find.TickManager.TicksGame + delay;
}
public override void CompTick()

View File

@@ -0,0 +1,56 @@
using System.Collections.Generic;
using Verse;
using RimWorld;
using Verse.AI;
using Verse.AI.Group;
namespace ArachnaeSwarm
{
public class JobGiver_MaintainBuildings : JobGiver_AIFightEnemies
{
private bool onlyIfDamagingState;
// 新增属性用于存储可维护的ThingDef列表
public List<ThingDef> maintainableThingDefs;
private static readonly float CellsInScanRadius = GenRadial.NumCellsInRadius(7.9f);
public override ThinkNode DeepCopy(bool resolve = true)
{
JobGiver_MaintainBuildings obj = (JobGiver_MaintainBuildings)base.DeepCopy(resolve);
obj.onlyIfDamagingState = onlyIfDamagingState;
obj.maintainableThingDefs = maintainableThingDefs; // 复制列表
return obj;
}
protected override Job TryGiveJob(Pawn pawn)
{
Room room = pawn.GetRoom();
for (int i = 0; (float)i < CellsInScanRadius; i++)
{
IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[i];
if (!intVec.InBounds(pawn.Map) || intVec.GetRoom(pawn.Map) != room)
{
continue;
}
// 遍历可维护的ThingDef列表
foreach (ThingDef thingDef in maintainableThingDefs)
{
// 查找指定ThingDef的建筑
Thing targetThing = (Thing)pawn.Map.thingGrid.ThingAt(intVec, thingDef);
if (targetThing != null && pawn.CanReserve(targetThing))
{
CompMaintainable compMaintainable = targetThing.TryGetComp<CompMaintainable>();
if (compMaintainable != null && compMaintainable.CurStage != 0 && (!onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging))
{
return JobMaker.MakeJob(JobDefOf.Maintain, targetThing);
}
}
}
}
return null;
}
}
}