diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll
index 4c3dbca..d1be993 100644
Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ
diff --git a/1.6/1.6/Defs/Thing_building/ARA_Building.xml b/1.6/1.6/Defs/Thing_building/ARA_Building.xml
index 1ac496a..bdf866e 100644
--- a/1.6/1.6/Defs/Thing_building/ARA_Building.xml
+++ b/1.6/1.6/Defs/Thing_building/ARA_Building.xml
@@ -249,7 +249,6 @@
1200000
- 60
ARA_InsectCreep
6
@@ -425,7 +424,6 @@
- 60
ARA_InsectCreep
3
@@ -482,7 +480,6 @@
- 60
ARA_InsectCreep
6
diff --git a/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml b/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml
index 6d9b930..82f2c50 100644
--- a/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml
+++ b/1.6/1.6/Defs/Thing_building/ARA_InteractiveEggSac.xml
@@ -86,7 +86,6 @@
5
- 60
ARA_InsectCreep
4.6
@@ -147,7 +146,6 @@
5
- 15
ARA_InsectCreep
8
diff --git a/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompDelayedTerrainSpawn.cs b/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompDelayedTerrainSpawn.cs
index e861ef3..c65f320 100644
--- a/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompDelayedTerrainSpawn.cs
+++ b/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompDelayedTerrainSpawn.cs
@@ -3,55 +3,55 @@ using Verse;
namespace ArachnaeSwarm
{
+ ///
+ /// Spawns terrain around the parent thing instantly upon spawning.
+ /// Despite the class name, this component does NOT use any delay or Tick-based updates.
+ /// The logic runs only ONCE during the PostSpawnSetup phase for maximum performance.
+ /// There is no background counting or any process that continues after the spawn.
+ ///
public class CompDelayedTerrainSpawn : ThingComp
{
private CompProperties_DelayedTerrainSpawn Props => (CompProperties_DelayedTerrainSpawn)props;
- private int ticksToSpawn;
- private bool started;
-
+ ///
+ /// This is the ONLY time this component's logic runs. It is called by the game when the object is created on the map.
+ ///
+ /// True if loading from a save, which we will ignore.
public override void PostSpawnSetup(bool respawningAfterLoad)
{
base.PostSpawnSetup(respawningAfterLoad);
- StartDelayedSpawn();
- }
- public override void CompTick()
- {
- base.CompTick();
- if (started)
+ // We only run this logic for brand new objects, not for objects loaded from a save file.
+ if (!respawningAfterLoad)
{
- ticksToSpawn--;
- if (ticksToSpawn == 0)
- {
- DoTerrainSpawn();
- }
+ DoTerrainSpawn();
}
}
- private void StartDelayedSpawn()
- {
- started = true;
- ticksToSpawn = Props.delayTicks;
- }
-
+ ///
+ /// This method performs the one-time action of spawning terrain.
+ /// It includes strong safety checks to prevent errors if the object is not fully initialized.
+ ///
private void DoTerrainSpawn()
{
- if (parent.Destroyed)
+ // Safety Check: We ensure the object and its map exist before trying to do anything.
+ // If these conditions are not met, the method does nothing and simply stops.
+ if (parent == null || parent.Destroyed || parent.Map == null || Props.terrainToSpawn == null)
{
- return;
+ return; // Stop execution if anything is not ready.
}
- if (Props.terrainToSpawn != null)
+ // The core logic: iterate through nearby cells and change their terrain.
+ foreach (IntVec3 current in GenRadial.RadialCellsAround(parent.Position, Props.spawnRadius, true))
{
- foreach (IntVec3 current in GenRadial.RadialCellsAround(parent.Position, Props.spawnRadius, true))
+ if (current.InBounds(parent.Map) && current.Walkable(parent.Map))
{
- if (current.InBounds(parent.Map) && current.Walkable(parent.Map))
- {
- parent.Map.terrainGrid.SetTerrain(current, Props.terrainToSpawn);
- }
+ parent.Map.terrainGrid.SetTerrain(current, Props.terrainToSpawn);
}
}
}
+
+ // NOTICE: There is NO CompTick() method here. This component does not perform any updates after it has spawned.
+ // NOTICE: There is NO ExposeData() method for timers because there are NO timers to save.
}
}
\ No newline at end of file
diff --git a/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompProperties_DelayedTerrainSpawn.cs b/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompProperties_DelayedTerrainSpawn.cs
index 5eb53fb..e4b56c1 100644
--- a/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompProperties_DelayedTerrainSpawn.cs
+++ b/Source/ArachnaeSwarm/ARA_BuildingTerrainSpawn/CompProperties_DelayedTerrainSpawn.cs
@@ -2,14 +2,18 @@ using Verse;
namespace ArachnaeSwarm
{
+ ///
+ /// Properties for the CompDelayedTerrainSpawn component.
+ /// The logic has been optimized to run instantly on spawn, so the 'delayTicks' field is no longer used.
+ ///
public class CompProperties_DelayedTerrainSpawn : CompProperties
{
- public int delayTicks = 0;
public TerrainDef terrainToSpawn;
public float spawnRadius = 0f;
public CompProperties_DelayedTerrainSpawn()
{
+ // The component logic now runs instantly, but the class name is kept for compatibility.
compClass = typeof(CompDelayedTerrainSpawn);
}
}