1
This commit is contained in:
Binary file not shown.
@@ -83,9 +83,33 @@
|
|||||||
<li>ARA_ChitinArmor</li>
|
<li>ARA_ChitinArmor</li>
|
||||||
</enablesNeeds>
|
</enablesNeeds>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>重设中</label>
|
||||||
|
<capMods>
|
||||||
|
<li>
|
||||||
|
<capacity>Consciousness</capacity>
|
||||||
|
<setMax>0.5</setMax>
|
||||||
|
</li>
|
||||||
|
</capMods>
|
||||||
|
<minSeverity>0.99</minSeverity>
|
||||||
|
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
||||||
|
<disablesNeeds>
|
||||||
|
<li>Mood</li>
|
||||||
|
<li>Joy</li>
|
||||||
|
<li>Beauty</li>
|
||||||
|
<li>Comfort</li>
|
||||||
|
<li>Outdoors</li>
|
||||||
|
<li>Indoors</li>
|
||||||
|
<li>DrugDesire</li>
|
||||||
|
<li>RoomSize</li>
|
||||||
|
</disablesNeeds>
|
||||||
|
<enablesNeeds>
|
||||||
|
<li>ARA_ChitinArmor</li>
|
||||||
|
</enablesNeeds>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<label>已连接</label>
|
<label>已连接</label>
|
||||||
<minSeverity>1</minSeverity>
|
<minSeverity>1.25</minSeverity>
|
||||||
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
||||||
<disablesNeeds>
|
<disablesNeeds>
|
||||||
<li>Mood</li>
|
<li>Mood</li>
|
||||||
@@ -256,7 +280,70 @@
|
|||||||
<scenarioCanAdd>false</scenarioCanAdd>
|
<scenarioCanAdd>false</scenarioCanAdd>
|
||||||
<stages>
|
<stages>
|
||||||
<li>
|
<li>
|
||||||
|
<label>未连接</label>
|
||||||
|
<capMods>
|
||||||
|
<li>
|
||||||
|
<capacity>Consciousness</capacity>
|
||||||
|
<setMax>0.2</setMax>
|
||||||
|
</li>
|
||||||
|
</capMods>
|
||||||
<minSeverity>0</minSeverity>
|
<minSeverity>0</minSeverity>
|
||||||
|
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
||||||
|
<disablesNeeds>
|
||||||
|
<li>Mood</li>
|
||||||
|
<li>Joy</li>
|
||||||
|
<li>Beauty</li>
|
||||||
|
<li>Comfort</li>
|
||||||
|
<li>Outdoors</li>
|
||||||
|
<li>Indoors</li>
|
||||||
|
<li>DrugDesire</li>
|
||||||
|
<li>RoomSize</li>
|
||||||
|
</disablesNeeds>
|
||||||
|
<enablesNeeds>
|
||||||
|
<li>ARA_ChitinArmor</li>
|
||||||
|
</enablesNeeds>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>重设中</label>
|
||||||
|
<capMods>
|
||||||
|
<li>
|
||||||
|
<capacity>Consciousness</capacity>
|
||||||
|
<setMax>0.5</setMax>
|
||||||
|
</li>
|
||||||
|
</capMods>
|
||||||
|
<minSeverity>0.99</minSeverity>
|
||||||
|
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
||||||
|
<disablesNeeds>
|
||||||
|
<li>Mood</li>
|
||||||
|
<li>Joy</li>
|
||||||
|
<li>Beauty</li>
|
||||||
|
<li>Comfort</li>
|
||||||
|
<li>Outdoors</li>
|
||||||
|
<li>Indoors</li>
|
||||||
|
<li>DrugDesire</li>
|
||||||
|
<li>RoomSize</li>
|
||||||
|
</disablesNeeds>
|
||||||
|
<enablesNeeds>
|
||||||
|
<li>ARA_ChitinArmor</li>
|
||||||
|
</enablesNeeds>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>已连接</label>
|
||||||
|
<minSeverity>1.25</minSeverity>
|
||||||
|
<foodPoisoningChanceFactor>0</foodPoisoningChanceFactor>
|
||||||
|
<disablesNeeds>
|
||||||
|
<li>Mood</li>
|
||||||
|
<li>Joy</li>
|
||||||
|
<li>Beauty</li>
|
||||||
|
<li>Comfort</li>
|
||||||
|
<li>Outdoors</li>
|
||||||
|
<li>Indoors</li>
|
||||||
|
<li>DrugDesire</li>
|
||||||
|
<li>RoomSize</li>
|
||||||
|
</disablesNeeds>
|
||||||
|
<enablesNeeds>
|
||||||
|
<li>ARA_ChitinArmor</li>
|
||||||
|
</enablesNeeds>
|
||||||
</li>
|
</li>
|
||||||
</stages>
|
</stages>
|
||||||
<comps>
|
<comps>
|
||||||
|
|||||||
Binary file not shown.
@@ -92,7 +92,7 @@
|
|||||||
"RelativeDocumentMoniker": "Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
"RelativeDocumentMoniker": "Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
||||||
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
"ToolTip": "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\Mods\\ArachnaeSwarm\\Source\\ArachnaeSwarm\\Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
||||||
"RelativeToolTip": "Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
"RelativeToolTip": "Hediffs\\ARA_GestaltNode\\HediffComp_GestaltNode.cs",
|
||||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAkAAAAFAAAAAAAAAA==",
|
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAAnAAAAAAAAAA==",
|
||||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
"WhenOpened": "2026-02-14T02:36:39.249Z",
|
"WhenOpened": "2026-02-14T02:36:39.249Z",
|
||||||
"EditorCaption": ""
|
"EditorCaption": ""
|
||||||
|
|||||||
@@ -34,6 +34,26 @@ namespace ArachnaeSwarm
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const int DELAY_TICKS = 60;
|
private const int DELAY_TICKS = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 过渡开始时间(ticks)
|
||||||
|
/// </summary>
|
||||||
|
private int transitionStartTick = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 过渡期持续时间(ticks),5秒
|
||||||
|
/// </summary>
|
||||||
|
private const int TRANSITION_DURATION = 300; // 5秒
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 过渡后的目标严重性
|
||||||
|
/// </summary>
|
||||||
|
private float targetSeverityAfterTransition = 1.0f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否正在过渡中
|
||||||
|
/// </summary>
|
||||||
|
private bool isTransitioning = false;
|
||||||
|
|
||||||
// === 属性 ===
|
// === 属性 ===
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -76,6 +96,35 @@ namespace ArachnaeSwarm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否在过渡期中
|
||||||
|
/// </summary>
|
||||||
|
public bool IsInTransition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (transitionStartTick < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return Find.TickManager.TicksGame - transitionStartTick < TRANSITION_DURATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前过渡进度(0-1)
|
||||||
|
/// </summary>
|
||||||
|
public float TransitionProgress
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!IsInTransition || transitionStartTick < 0)
|
||||||
|
return 1.0f;
|
||||||
|
|
||||||
|
int elapsed = Find.TickManager.TicksGame - transitionStartTick;
|
||||||
|
return Mathf.Clamp01((float)elapsed / TRANSITION_DURATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取 GestaltTracker
|
/// 获取 GestaltTracker
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -151,11 +200,14 @@ namespace ArachnaeSwarm
|
|||||||
InitializeAfterDelay();
|
InitializeAfterDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查过渡状态
|
||||||
|
UpdateTransitionState();
|
||||||
|
|
||||||
// 正常的Tick逻辑
|
// 正常的Tick逻辑
|
||||||
if (NodeType == GestaltNodeType.HiveNode)
|
if (NodeType == GestaltNodeType.HiveNode)
|
||||||
{
|
{
|
||||||
// 定期更新严重性
|
// 定期更新严重性(如果不在过渡中)
|
||||||
if (Find.TickManager.TicksGame % 60 == 0) // 每60tick检查一次
|
if (!IsInTransition && Find.TickManager.TicksGame % 60 == 0) // 每60tick检查一次
|
||||||
{
|
{
|
||||||
UpdateSeverityBasedOnConnection();
|
UpdateSeverityBasedOnConnection();
|
||||||
}
|
}
|
||||||
@@ -199,6 +251,74 @@ namespace ArachnaeSwarm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新过渡状态
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateTransitionState()
|
||||||
|
{
|
||||||
|
if (!isTransitioning || transitionStartTick < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 检查是否过渡完成
|
||||||
|
if (!IsInTransition)
|
||||||
|
{
|
||||||
|
// 过渡完成,设置目标严重性
|
||||||
|
if (parent != null && Mathf.Abs(parent.Severity - targetSeverityAfterTransition) > 0.01f)
|
||||||
|
{
|
||||||
|
parent.Severity = targetSeverityAfterTransition;
|
||||||
|
|
||||||
|
// 通知Pawn状态改变
|
||||||
|
var pawn = Pawn;
|
||||||
|
if (pawn?.health != null)
|
||||||
|
{
|
||||||
|
pawn.health.Notify_HediffChanged(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Message($"[GestaltNode] {Pawn?.LabelShort} 过渡完成,严重性: {targetSeverityAfterTransition}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置过渡状态
|
||||||
|
transitionStartTick = -1;
|
||||||
|
isTransitioning = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 在过渡中,保持中间态严重性1
|
||||||
|
if (parent != null && Mathf.Abs(parent.Severity - 1.0f) > 0.01f)
|
||||||
|
{
|
||||||
|
parent.Severity = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 开始过渡
|
||||||
|
/// </summary>
|
||||||
|
private void StartTransition(bool isConnecting)
|
||||||
|
{
|
||||||
|
// 设置目标严重性
|
||||||
|
targetSeverityAfterTransition = isConnecting ? 1.5f : 0.5f;
|
||||||
|
|
||||||
|
// 记录过渡开始时间
|
||||||
|
transitionStartTick = Find.TickManager.TicksGame;
|
||||||
|
isTransitioning = true;
|
||||||
|
|
||||||
|
// 立即设置到中间态(严重性1)
|
||||||
|
if (parent != null)
|
||||||
|
{
|
||||||
|
parent.Severity = 1.0f;
|
||||||
|
|
||||||
|
// 通知Pawn状态改变
|
||||||
|
var pawn = Pawn;
|
||||||
|
if (pawn?.health != null)
|
||||||
|
{
|
||||||
|
pawn.health.Notify_HediffChanged(parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Message($"[GestaltNode] {Pawn?.LabelShort} 开始过渡,目标: {(isConnecting ? "连接" : "断开")} ({targetSeverityAfterTransition})");
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据连接状态更新 Hediff 严重性
|
/// 根据连接状态更新 Hediff 严重性
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -215,23 +335,32 @@ namespace ArachnaeSwarm
|
|||||||
|
|
||||||
bool isConnected = IsConnectedToOverlord();
|
bool isConnected = IsConnectedToOverlord();
|
||||||
|
|
||||||
// 只有连接状态改变时才更新,避免每帧都设置
|
// 检查连接状态是否改变
|
||||||
if (isConnected != wasConnected)
|
if (isConnected != wasConnected)
|
||||||
{
|
{
|
||||||
float targetSeverity = isConnected ? 1.5f : 0.5f;
|
// 连接状态改变,开始过渡
|
||||||
|
StartTransition(isConnected);
|
||||||
// 平滑过渡到目标严重性
|
|
||||||
if (Mathf.Abs(parent.Severity - targetSeverity) > 0.01f)
|
|
||||||
{
|
|
||||||
parent.Severity = targetSeverity;
|
|
||||||
}
|
|
||||||
|
|
||||||
wasConnected = isConnected;
|
wasConnected = isConnected;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 连接状态没有改变,但可能不在过渡中,需要确保严重性正确
|
||||||
|
// 如果不在过渡中,直接设置到目标严重性
|
||||||
|
if (!IsInTransition)
|
||||||
|
{
|
||||||
|
float currentTargetSeverity = isConnected ? 1.5f : 0.5f;
|
||||||
|
|
||||||
|
if (Mathf.Abs(parent.Severity - currentTargetSeverity) > 0.01f)
|
||||||
|
{
|
||||||
|
parent.Severity = currentTargetSeverity;
|
||||||
|
|
||||||
// 如果严重性改变,需要重新计算Pawn的能力
|
// 如果严重性改变,需要重新计算Pawn的能力
|
||||||
pawn.health.Notify_HediffChanged(parent);
|
pawn.health.Notify_HediffChanged(parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查是否连接到 Overlord
|
/// 检查是否连接到 Overlord
|
||||||
@@ -363,6 +492,9 @@ namespace ArachnaeSwarm
|
|||||||
Scribe_Values.Look(ref wasConnected, "wasConnected", false);
|
Scribe_Values.Look(ref wasConnected, "wasConnected", false);
|
||||||
Scribe_Values.Look(ref spawnTimestamp, "spawnTimestamp", -1);
|
Scribe_Values.Look(ref spawnTimestamp, "spawnTimestamp", -1);
|
||||||
Scribe_Values.Look(ref isInitialized, "isInitialized", false);
|
Scribe_Values.Look(ref isInitialized, "isInitialized", false);
|
||||||
|
Scribe_Values.Look(ref transitionStartTick, "transitionStartTick", -1);
|
||||||
|
Scribe_Values.Look(ref targetSeverityAfterTransition, "targetSeverityAfterTransition", 1.0f);
|
||||||
|
Scribe_Values.Look(ref isTransitioning, "isTransitioning", false);
|
||||||
|
|
||||||
// 加载后,如果已经过了延迟期,标记为已初始化
|
// 加载后,如果已经过了延迟期,标记为已初始化
|
||||||
if (Scribe.mode == LoadSaveMode.PostLoadInit && spawnTimestamp >= 0)
|
if (Scribe.mode == LoadSaveMode.PostLoadInit && spawnTimestamp >= 0)
|
||||||
@@ -372,6 +504,22 @@ namespace ArachnaeSwarm
|
|||||||
{
|
{
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果正在过渡中,恢复过渡状态
|
||||||
|
if (transitionStartTick >= 0 && isTransitioning)
|
||||||
|
{
|
||||||
|
// 检查过渡是否已经完成
|
||||||
|
if (!IsInTransition)
|
||||||
|
{
|
||||||
|
// 过渡已完成,设置最终严重性
|
||||||
|
if (parent != null)
|
||||||
|
{
|
||||||
|
parent.Severity = targetSeverityAfterTransition;
|
||||||
|
}
|
||||||
|
transitionStartTick = -1;
|
||||||
|
isTransitioning = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,12 +532,23 @@ namespace ArachnaeSwarm
|
|||||||
if (pawn == null)
|
if (pawn == null)
|
||||||
return "Pawn is null";
|
return "Pawn is null";
|
||||||
|
|
||||||
|
string transitionInfo = "无";
|
||||||
|
if (IsInTransition)
|
||||||
|
{
|
||||||
|
transitionInfo = $"过渡中,进度: {TransitionProgress:P0},目标: {targetSeverityAfterTransition}";
|
||||||
|
}
|
||||||
|
else if (isTransitioning)
|
||||||
|
{
|
||||||
|
transitionInfo = $"过渡完成,目标: {targetSeverityAfterTransition}";
|
||||||
|
}
|
||||||
|
|
||||||
return $"NodeType: {NodeType}\n" +
|
return $"NodeType: {NodeType}\n" +
|
||||||
$"SpawnTimestamp: {spawnTimestamp}\n" +
|
$"SpawnTimestamp: {spawnTimestamp}\n" +
|
||||||
$"IsPastSpawnDelay: {IsPastSpawnDelay}\n" +
|
$"IsPastSpawnDelay: {IsPastSpawnDelay}\n" +
|
||||||
$"IsInitialized: {isInitialized}\n" +
|
$"IsInitialized: {isInitialized}\n" +
|
||||||
$"WasConnected: {wasConnected}\n" +
|
$"WasConnected: {wasConnected}\n" +
|
||||||
$"IsConnected: {IsConnectedToOverlord()}\n" +
|
$"IsConnected: {IsConnectedToOverlord()}\n" +
|
||||||
|
$"Transition: {transitionInfo}\n" +
|
||||||
$"CurrentSeverity: {parent?.Severity ?? 0f}";
|
$"CurrentSeverity: {parent?.Severity ?? 0f}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user