暂存
This commit is contained in:
Binary file not shown.
@@ -15,6 +15,7 @@
|
|||||||
<passability>PassThroughOnly</passability>
|
<passability>PassThroughOnly</passability>
|
||||||
<fillPercent>0.3</fillPercent>
|
<fillPercent>0.3</fillPercent>
|
||||||
<rotatable>false</rotatable>
|
<rotatable>false</rotatable>
|
||||||
|
<tickerType>Normal</tickerType>
|
||||||
<terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
|
<terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
|
||||||
<statBases>
|
<statBases>
|
||||||
<MaxHitPoints>20</MaxHitPoints>
|
<MaxHitPoints>20</MaxHitPoints>
|
||||||
|
|||||||
@@ -48,25 +48,65 @@ namespace ArachnaeSwarm
|
|||||||
if (spawnUntilTick > 0 && Find.TickManager.TicksGame >= spawnUntilTick)
|
if (spawnUntilTick > 0 && Find.TickManager.TicksGame >= spawnUntilTick)
|
||||||
{
|
{
|
||||||
SpawnPawn(spawningPawnKind);
|
SpawnPawn(spawningPawnKind);
|
||||||
spawnUntilTick = -1;
|
|
||||||
spawningPawnKind = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnPawn(PawnKindDef pawnKind)
|
private void SpawnPawn(PawnKindDef pawnKind)
|
||||||
{
|
{
|
||||||
Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKind, parent.Faction));
|
try
|
||||||
GenSpawn.Spawn(pawn, parent.Position, parent.Map);
|
|
||||||
|
|
||||||
if (Props.lordJob != null)
|
|
||||||
{
|
{
|
||||||
Lord lord = LordMaker.MakeNewLord(parent.Faction, (LordJob)System.Activator.CreateInstance(Props.lordJob), parent.Map);
|
if (pawnKind == null)
|
||||||
lord.AddPawn(pawn);
|
{
|
||||||
|
Log.Warning("CompSpawnPawnFromList: Tried to spawn pawn but pawnKind is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parent.Spawned || parent.Map == null)
|
||||||
|
{
|
||||||
|
Log.Error($"CompSpawnPawnFromList: Cannot spawn pawn. Parent {parent} is not spawned or map is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKind, parent.Faction));
|
||||||
|
if (pawn == null)
|
||||||
|
{
|
||||||
|
Log.Error($"CompSpawnPawnFromList: Failed to generate pawn of kind {pawnKind.defName} for faction {parent.Faction?.Name ?? "null"}.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GenSpawn.Spawn(pawn, parent.Position, parent.Map) == null)
|
||||||
|
{
|
||||||
|
Log.Error($"CompSpawnPawnFromList: Failed to spawn pawn {pawn} at {parent.Position}.");
|
||||||
|
if (!pawn.Destroyed)
|
||||||
|
{
|
||||||
|
pawn.Destroy();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Props.lordJob != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LordJob lordJobInstance = (LordJob)System.Activator.CreateInstance(Props.lordJob);
|
||||||
|
Lord lord = LordMaker.MakeNewLord(parent.Faction, lordJobInstance, parent.Map);
|
||||||
|
lord.AddPawn(pawn);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Log.Error($"CompSpawnPawnFromList: Error creating LordJob {Props.lordJob?.Name ?? "null"} or assigning pawn {pawn}. Exception: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Props.destroyOnSpawn)
|
||||||
|
{
|
||||||
|
parent.Destroy(DestroyMode.Vanish);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
if (Props.destroyOnSpawn)
|
|
||||||
{
|
{
|
||||||
parent.Destroy(DestroyMode.Vanish);
|
spawnUntilTick = -1;
|
||||||
|
spawningPawnKind = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user