暂存
This commit is contained in:
Binary file not shown.
@@ -90,7 +90,13 @@
|
|||||||
<spawnMtbHours>4</spawnMtbHours>
|
<spawnMtbHours>4</spawnMtbHours>
|
||||||
<spawnRadius>5</spawnRadius>
|
<spawnRadius>5</spawnRadius>
|
||||||
</li>
|
</li>
|
||||||
|
<li Class="ArachnaeSwarm.CompProperties_DelayedTerrainSpawn">
|
||||||
|
<delayTicks>60</delayTicks> <!-- 60 ticks = 1 second -->
|
||||||
|
<terrainToSpawn>ARA_InsectSludge</terrainToSpawn>
|
||||||
|
<spawnRadius>4.6</spawnRadius>
|
||||||
|
</li>
|
||||||
</comps>
|
</comps>
|
||||||
|
|
||||||
</ThingDef>
|
</ThingDef>
|
||||||
|
|
||||||
<TerrainDef ParentName="FloorBase">
|
<TerrainDef ParentName="FloorBase">
|
||||||
|
|||||||
@@ -85,6 +85,10 @@
|
|||||||
<Compile Include="CompProperties_AbilityBindDrone.cs" />
|
<Compile Include="CompProperties_AbilityBindDrone.cs" />
|
||||||
<Compile Include="JobGiver_MaintainBuildings.cs" />
|
<Compile Include="JobGiver_MaintainBuildings.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="CompProperties_DelayedTerrainSpawn.cs" />
|
||||||
|
<Compile Include="CompDelayedTerrainSpawn.cs" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="WULA_AutoMechCarrier\CompAutoMechCarrier.cs" />
|
<Compile Include="WULA_AutoMechCarrier\CompAutoMechCarrier.cs" />
|
||||||
<Compile Include="WULA_AutoMechCarrier\CompProperties_AutoMechCarrier.cs" />
|
<Compile Include="WULA_AutoMechCarrier\CompProperties_AutoMechCarrier.cs" />
|
||||||
|
|||||||
57
Source/ArachnaeSwarm/CompDelayedTerrainSpawn.cs
Normal file
57
Source/ArachnaeSwarm/CompDelayedTerrainSpawn.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
16
Source/ArachnaeSwarm/CompProperties_DelayedTerrainSpawn.cs
Normal file
16
Source/ArachnaeSwarm/CompProperties_DelayedTerrainSpawn.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user