This commit is contained in:
2025-09-02 14:33:33 +08:00
parent b1d6df2523
commit 8672eb9f40
5 changed files with 83 additions and 0 deletions

Binary file not shown.

View File

@@ -90,7 +90,13 @@
<spawnMtbHours>4</spawnMtbHours>
<spawnRadius>5</spawnRadius>
</li>
<li Class="ArachnaeSwarm.CompProperties_DelayedTerrainSpawn">
<delayTicks>60</delayTicks> <!-- 60 ticks = 1 second -->
<terrainToSpawn>ARA_InsectSludge</terrainToSpawn>
<spawnRadius>4.6</spawnRadius>
</li>
</comps>
</ThingDef>
<TerrainDef ParentName="FloorBase">

View File

@@ -85,6 +85,10 @@
<Compile Include="CompProperties_AbilityBindDrone.cs" />
<Compile Include="JobGiver_MaintainBuildings.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="CompProperties_DelayedTerrainSpawn.cs" />
<Compile Include="CompDelayedTerrainSpawn.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="WULA_AutoMechCarrier\CompAutoMechCarrier.cs" />
<Compile Include="WULA_AutoMechCarrier\CompProperties_AutoMechCarrier.cs" />

View File

@@ -0,0 +1,57 @@
using RimWorld;
using Verse;
namespace ArachnaeSwarm
{
public class CompDelayedTerrainSpawn : ThingComp
{
private CompProperties_DelayedTerrainSpawn Props => (CompProperties_DelayedTerrainSpawn)props;
private int ticksToSpawn;
private bool started;
public override void PostSpawnSetup(bool respawningAfterLoad)
{
base.PostSpawnSetup(respawningAfterLoad);
StartDelayedSpawn();
}
public override void CompTick()
{
base.CompTick();
if (started)
{
ticksToSpawn--;
if (ticksToSpawn <= 0)
{
DoTerrainSpawn();
}
}
}
private void StartDelayedSpawn()
{
started = true;
ticksToSpawn = Props.delayTicks;
}
private void DoTerrainSpawn()
{
if (parent.Destroyed)
{
return;
}
if (Props.terrainToSpawn != null)
{
foreach (IntVec3 current in GenRadial.RadialCellsAround(parent.Position, Props.spawnRadius, true))
{
if (current.InBounds(parent.Map) && current.Walkable(parent.Map))
{
parent.Map.terrainGrid.SetTerrain(current, Props.terrainToSpawn);
}
}
}
}
}
}

View File

@@ -0,0 +1,16 @@
using Verse;
namespace ArachnaeSwarm
{
public class CompProperties_DelayedTerrainSpawn : CompProperties
{
public int delayTicks = 0;
public TerrainDef terrainToSpawn;
public float spawnRadius = 0f;
public CompProperties_DelayedTerrainSpawn()
{
compClass = typeof(CompDelayedTerrainSpawn);
}
}
}