精神崩溃
This commit is contained in:
@@ -36,6 +36,10 @@ namespace ArachnaeSwarm
|
||||
{
|
||||
// Master is invalid or unlinked, start/continue unlinked timer
|
||||
ticksUnlinked += 60; // Increment by 60 because we check every 60 ticks
|
||||
|
||||
// 更新严重性到未连接状态
|
||||
droneHediff.UpdateSeverity();
|
||||
|
||||
if (ticksUnlinked >= Props.unlinkedDieDelayTicks)
|
||||
{
|
||||
Log.Message($"[ArachnaeSwarm] Drone {parent.pawn.LabelShort} was unlinked from master for too long and will die. Forcing death.");
|
||||
@@ -48,10 +52,41 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
else
|
||||
{
|
||||
// Master is valid, reset unlinked timer
|
||||
// Master is valid, reset unlinked timer and update severity
|
||||
ticksUnlinked = 0;
|
||||
droneHediff.UpdateSeverity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当无人机被绑定到主节点时调用
|
||||
/// </summary>
|
||||
public void OnLinkedToMaster()
|
||||
{
|
||||
Hediff_HiveMindDrone droneHediff = parent as Hediff_HiveMindDrone;
|
||||
if (droneHediff != null)
|
||||
{
|
||||
// 重置未连接计时器
|
||||
ticksUnlinked = 0;
|
||||
// 更新严重性到连接状态
|
||||
droneHediff.UpdateSeverity();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当无人机与主节点断开连接时调用
|
||||
/// </summary>
|
||||
public void OnUnlinkedFromMaster()
|
||||
{
|
||||
Hediff_HiveMindDrone droneHediff = parent as Hediff_HiveMindDrone;
|
||||
if (droneHediff != null)
|
||||
{
|
||||
// 开始未连接计时器
|
||||
ticksUnlinked = 0; // 重置后开始计数
|
||||
// 更新严重性到未连接状态
|
||||
droneHediff.UpdateSeverity();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace ArachnaeSwarm
|
||||
public override void PostAdd(DamageInfo? dinfo)
|
||||
{
|
||||
base.PostAdd(dinfo);
|
||||
// 设置初始严重性
|
||||
UpdateSeverity();
|
||||
// No direct linking in PostAdd, master will link manually
|
||||
}
|
||||
|
||||
@@ -56,6 +58,7 @@ namespace ArachnaeSwarm
|
||||
masterHediff?.DeregisterDrone(this.pawn);
|
||||
}
|
||||
}
|
||||
|
||||
public override string TipStringExtra
|
||||
{
|
||||
get
|
||||
@@ -67,6 +70,30 @@ namespace ArachnaeSwarm
|
||||
return "ARA_TipString_NotLinked".Translate();
|
||||
}
|
||||
}
|
||||
// PostTick logic moved to HediffComp_HiveMindDrone
|
||||
|
||||
/// <summary>
|
||||
/// 更新严重性:未连接0.5,已连接1.5
|
||||
/// </summary>
|
||||
public void UpdateSeverity()
|
||||
{
|
||||
// 检查连接状态
|
||||
bool isLinked = IsLinkedToValidMaster();
|
||||
|
||||
// 设置固定严重性
|
||||
this.Severity = isLinked ? 1.5f : 0.5f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否连接到有效的主节点
|
||||
/// </summary>
|
||||
private bool IsLinkedToValidMaster()
|
||||
{
|
||||
if (this.target is Pawn masterPawn && masterPawn != null && !masterPawn.Destroyed && !masterPawn.Dead)
|
||||
{
|
||||
// 检查主节点是否有HiveMindMaster hediff
|
||||
return masterPawn.health.hediffSet.HasHediff(HediffDef.Named("ARA_HiveMindMaster"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user