feat: 新增全局变量管理器以持久化数据并在满足条件时阻止独特角色复活
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -81,7 +81,7 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix(Pawn pawn, ref bool __result)
|
||||
public static bool Prefix(Pawn pawn)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace ArachnaeSwarm
|
||||
ArachnaeLog.Debug($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在");
|
||||
}
|
||||
|
||||
__result = false; // 返回 false 表示复活失败
|
||||
// __result = false; // void methods cannot return a value
|
||||
return false; // 跳过原始方法
|
||||
}
|
||||
}
|
||||
@@ -136,12 +136,13 @@ namespace ArachnaeSwarm
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
public static bool Prefix(Pawn pawn, ref bool __result)
|
||||
public static bool Prefix(Pawn pawn)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 检查 pawn 是否有 CompUniquePawn 组件
|
||||
var comp = pawn?.GetComp<CompUniquePawn>();
|
||||
if (pawn == null) return true;
|
||||
var comp = pawn.GetComp<CompUniquePawn>();
|
||||
if (comp != null && !string.IsNullOrEmpty(comp.Props?.globalVariable))
|
||||
{
|
||||
string variable = comp.Props.globalVariable;
|
||||
@@ -165,7 +166,7 @@ namespace ArachnaeSwarm
|
||||
ArachnaeLog.Debug($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在");
|
||||
}
|
||||
|
||||
__result = false; // 返回 false 表示复活失败
|
||||
// __result = false; // void methods cannot return a value
|
||||
return false; // 跳过原始方法
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user