新亚种
This commit is contained in:
Binary file not shown.
@@ -1,9 +1,13 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\",
|
||||
"WorkspaceRootPath": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\",
|
||||
"Documents": [
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|e:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\compabilityeffect_randomhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\hediffs\\ara_hediffterrainspawn\\comphediffterrainspawn.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:hediffs\\ara_hediffterrainspawn\\comphediffterrainspawn.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|d:\\steamlibrary\\steamapps\\common\\rimworld\\mods\\arachnaeswarm\\source\\arachnaeswarm\\abilities\\compabilityeffect_randomhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{EAE0DB6B-E282-C812-7F5A-6D13E9D24581}|ArachnaeSwarm.csproj|solutionrelative:abilities\\compabilityeffect_randomhediff.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
@@ -23,12 +27,25 @@
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
"Title": "CompHediffTerrainSpawn.cs",
|
||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HediffTerrainSpawn\\CompHediffTerrainSpawn.cs",
|
||||
"RelativeDocumentMoniker": "Hediffs\\ARA_HediffTerrainSpawn\\CompHediffTerrainSpawn.cs",
|
||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_HediffTerrainSpawn\\CompHediffTerrainSpawn.cs",
|
||||
"RelativeToolTip": "Hediffs\\ARA_HediffTerrainSpawn\\CompHediffTerrainSpawn.cs",
|
||||
"ViewState": "AgIAAF4AAAAAAAAAAAAAAG4AAAAAAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-23T08:00:28.236Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "CompAbilityEffect_RandomHediff.cs",
|
||||
"DocumentMoniker": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"DocumentMoniker": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"RelativeDocumentMoniker": "Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"ToolTip": "E:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"RelativeToolTip": "Abilities\\CompAbilityEffect_RandomHediff.cs",
|
||||
"ViewState": "AgIAAM4AAAAAAAAAAAAswL8AAAA9AAAAAAAAAA==",
|
||||
"ViewState": "AgIAALoAAAAAAAAAAAAqwNcAAAAZAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-10-22T06:34:08.063Z",
|
||||
"EditorCaption": ""
|
||||
|
||||
@@ -132,6 +132,8 @@
|
||||
<Compile Include="EventSystem\QuestNode_Root_EventLetter.cs" />
|
||||
<Compile Include="HediffGiver\HediffGiver_NonPlayerFaction.cs" />
|
||||
<Compile Include="Hediffs\ARA_DrawMoteInRange\HediffComp_DrawMoteInRange.cs" />
|
||||
<Compile Include="Hediffs\ARA_HediffTerrainSpawn\CompHediffTerrainSpawn.cs" />
|
||||
<Compile Include="Hediffs\ARA_HediffTerrainSpawn\CompProperties_HediffTerrainSpawn.cs" />
|
||||
<Compile Include="Hediffs\HediffComp_LifespanDisplay.cs" />
|
||||
<Compile Include="Jobs\JobDriver_CarryPrisonerToRefuelingVat.cs" />
|
||||
<Compile Include="MentalState\MentalState_HiveMindCascade.cs" />
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
/// <summary>
|
||||
/// Hediff component that periodically changes terrain around the pawn.
|
||||
/// Runs at specified intervals while the hediff is active.
|
||||
/// </summary>
|
||||
public class CompHediffTerrainSpawn : HediffComp
|
||||
{
|
||||
private CompProperties_HediffTerrainSpawn Props => (CompProperties_HediffTerrainSpawn)props;
|
||||
|
||||
private int ticksUntilNextSpawn;
|
||||
private bool initialized = false;
|
||||
|
||||
public override void CompPostTick(ref float severityAdjustment)
|
||||
{
|
||||
base.CompPostTick(ref severityAdjustment);
|
||||
|
||||
// 初始化计数器
|
||||
if (!initialized)
|
||||
{
|
||||
ticksUntilNextSpawn = Props.intervalTicks;
|
||||
initialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查条件
|
||||
if (!CanSpawnTerrain())
|
||||
return;
|
||||
|
||||
// 倒计时
|
||||
ticksUntilNextSpawn--;
|
||||
if (ticksUntilNextSpawn <= 0)
|
||||
{
|
||||
DoTerrainSpawn();
|
||||
ticksUntilNextSpawn = Props.intervalTicks; // 重置计数器
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否满足地形生成条件
|
||||
/// </summary>
|
||||
private bool CanSpawnTerrain()
|
||||
{
|
||||
// 基本检查
|
||||
if (parent.pawn == null || parent.pawn.Destroyed || parent.pawn.Map == null ||
|
||||
Props.terrainToSpawn == null || Props.spawnRadius <= 0)
|
||||
return false;
|
||||
|
||||
// 检查可选条件
|
||||
if (Props.onlyWhenDowned && !parent.pawn.Downed)
|
||||
return false;
|
||||
|
||||
if (Props.onlyWhenMoving && (parent.pawn.pather == null || !parent.pawn.pather.Moving))
|
||||
return false;
|
||||
|
||||
// 确保pawn在地图内
|
||||
if (!parent.pawn.Position.InBounds(parent.pawn.Map))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行地形生成
|
||||
/// </summary>
|
||||
private void DoTerrainSpawn()
|
||||
{
|
||||
try
|
||||
{
|
||||
Map map = parent.pawn.Map;
|
||||
IntVec3 center = parent.pawn.Position;
|
||||
|
||||
foreach (IntVec3 current in GenRadial.RadialCellsAround(center, Props.spawnRadius, true))
|
||||
{
|
||||
if (current.InBounds(map) && current.Walkable(map))
|
||||
{
|
||||
// 检查当前地形是否有 ARA_Creep 标签
|
||||
TerrainDef currentTerrain = map.terrainGrid.TerrainAt(current);
|
||||
if (currentTerrain != null && HasCreepTag(currentTerrain))
|
||||
{
|
||||
continue; // 跳过有 ARA_Creep 标签的地面
|
||||
}
|
||||
|
||||
map.terrainGrid.SetTerrain(current, Props.terrainToSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"Error in CompHediffTerrainSpawn.DoTerrainSpawn: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查地形是否具有 ARA_Creep 标签
|
||||
/// </summary>
|
||||
private bool HasCreepTag(TerrainDef terrain)
|
||||
{
|
||||
return terrain.tags != null && terrain.tags.Contains("ARA_Creep");
|
||||
}
|
||||
|
||||
public override void CompExposeData()
|
||||
{
|
||||
base.CompExposeData();
|
||||
Scribe_Values.Look(ref ticksUntilNextSpawn, "ticksUntilNextSpawn", Props.intervalTicks);
|
||||
Scribe_Values.Look(ref initialized, "initialized", false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调试信息显示
|
||||
/// </summary>
|
||||
public override string CompDebugString()
|
||||
{
|
||||
if (!CanSpawnTerrain())
|
||||
return "Cannot spawn terrain: conditions not met";
|
||||
|
||||
return $"Next spawn in: {ticksUntilNextSpawn} ticks\n" +
|
||||
$"Interval: {Props.intervalTicks} ticks\n" +
|
||||
$"Radius: {Props.spawnRadius}\n" +
|
||||
$"Terrain: {Props.terrainToSpawn?.defName ?? "None"}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Verse;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
/// <summary>
|
||||
/// Properties for the CompHediffTerrainSpawn component.
|
||||
/// Allows a hediff to periodically change terrain around the pawn.
|
||||
/// </summary>
|
||||
public class CompProperties_HediffTerrainSpawn : HediffCompProperties
|
||||
{
|
||||
public TerrainDef terrainToSpawn;
|
||||
public float spawnRadius = 0f;
|
||||
public int intervalTicks = 60; // 默认1秒
|
||||
|
||||
// 可选:是否只在特定条件下生效
|
||||
public bool onlyWhenDowned = false;
|
||||
public bool onlyWhenMoving = false;
|
||||
|
||||
public CompProperties_HediffTerrainSpawn()
|
||||
{
|
||||
compClass = typeof(CompHediffTerrainSpawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user