✅ WulaFallenEmpireSettings.cs - 添加了 public bool enableDebugLogs = false; 字段和保存配置
✅ WulaLog.cs - 修改了DebugEnabled属性,仅检查enableDebugLogs设置(不检查DevMode) ✅ WulaFallenEmpireMod.cs - 在DoSettingsWindowContents中添加了UI复选框,显示"Enable Debug Logs"选项 ✅ 替换了所有848个Log.Message/Error/Warning调用为WulaLog.Debug()
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
@@ -57,7 +57,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Failed to load AI history from {path}: {ex}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Failed to load AI history from {path}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Failed to save AI history to {path}: {ex}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Failed to save AI history to {path}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Failed to clear AI history at {path}: {ex}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Failed to clear AI history at {path}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -25,7 +25,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
{
|
||||
if (string.IsNullOrEmpty(_baseUrl))
|
||||
{
|
||||
Log.Error("[WulaAI] Base URL is missing.");
|
||||
WulaLog.Debug("[WulaAI] Base URL is missing.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
string jsonBody = jsonBuilder.ToString();
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Sending request to {endpoint} (model={_model}, messages={messages?.Count ?? 0})");
|
||||
Log.Message($"[WulaAI] Request body (truncated):\n{TruncateForLog(jsonBody)}");
|
||||
WulaLog.Debug($"[WulaAI] Sending request to {endpoint} (model={_model}, messages={messages?.Count ?? 0})");
|
||||
WulaLog.Debug($"[WulaAI] Request body (truncated):\n{TruncateForLog(jsonBody)}");
|
||||
}
|
||||
|
||||
using (UnityWebRequest request = new UnityWebRequest(endpoint, "POST"))
|
||||
@@ -93,14 +93,14 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
|
||||
if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
|
||||
{
|
||||
Log.Error($"[WulaAI] API Error: {request.error}\nResponse (truncated): {TruncateForLog(request.downloadHandler.text)}");
|
||||
WulaLog.Debug($"[WulaAI] API Error: {request.error}\nResponse (truncated): {TruncateForLog(request.downloadHandler.text)}");
|
||||
return null;
|
||||
}
|
||||
|
||||
string responseText = request.downloadHandler.text;
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Raw Response (truncated): {TruncateForLog(responseText)}");
|
||||
WulaLog.Debug($"[WulaAI] Raw Response (truncated): {TruncateForLog(responseText)}");
|
||||
}
|
||||
return ExtractContent(responseText);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ namespace WulaFallenEmpire.EventSystem.AI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Error parsing response: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Error parsing response: {ex}");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -129,7 +129,7 @@ namespace WulaFallenEmpire.EventSystem.AI.Tools
|
||||
float baseMaxPoints = StorytellerUtility.DefaultThreatPointsNow(map);
|
||||
float adjustedMaxPoints = baseMaxPoints * goodwillFactor * 1.5f;
|
||||
|
||||
Log.Message($"[WulaAI] send_reinforcement: totalCost={totalCost}, adjustedMaxPoints={adjustedMaxPoints}");
|
||||
WulaLog.Debug($"[WulaAI] send_reinforcement: totalCost={totalCost}, adjustedMaxPoints={adjustedMaxPoints}");
|
||||
if (totalCost > adjustedMaxPoints)
|
||||
{
|
||||
return $"Error: Total cost {totalCost} exceeds limit {adjustedMaxPoints:F0}. Reduce unit count.";
|
||||
|
||||
@@ -127,7 +127,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Failed to persist AI history: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Failed to persist AI history: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[WulaAI] Failed to load portrait: {path}");
|
||||
WulaLog.Debug($"[WulaAI] Failed to load portrait: {path}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ You are 'The Legion', a super AI of the Wula Empire. Your personality is authori
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[WulaAI] Portrait ID {id} not found.");
|
||||
WulaLog.Debug($"[WulaAI] Portrait ID {id} not found.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ Example (changing to a neutral expression):
|
||||
var phase = (RequestPhase)phaseIndex;
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] ===== Turn {phaseIndex}/4 ({phase}) =====");
|
||||
WulaLog.Debug($"[WulaAI] ===== Turn {phaseIndex}/4 ({phase}) =====");
|
||||
}
|
||||
|
||||
bool toolsEnabled = phase != RequestPhase.Reply;
|
||||
@@ -592,7 +592,7 @@ Example (changing to a neutral expression):
|
||||
{
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Turn {phaseIndex}/4 reply request (attempt {attempts + 1})");
|
||||
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 reply request (attempt {attempts + 1})");
|
||||
}
|
||||
string reply = await client.GetChatCompletionAsync(systemInstruction, _history);
|
||||
if (string.IsNullOrEmpty(reply))
|
||||
@@ -622,7 +622,7 @@ Example (changing to a neutral expression):
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Turn {phaseIndex}/4 tool request");
|
||||
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 tool request");
|
||||
}
|
||||
string response = await client.GetChatCompletionAsync(systemInstruction, _history);
|
||||
if (string.IsNullOrEmpty(response))
|
||||
@@ -638,7 +638,7 @@ Example (changing to a neutral expression):
|
||||
PersistHistory();
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Turn {phaseIndex}/4 missing XML; retrying once");
|
||||
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 missing XML; retrying once");
|
||||
}
|
||||
response = await client.GetChatCompletionAsync(systemInstruction, _history);
|
||||
if (string.IsNullOrEmpty(response))
|
||||
@@ -652,7 +652,7 @@ Example (changing to a neutral expression):
|
||||
{
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Warning($"[WulaAI] Turn {phaseIndex}/4 still missing XML after retry; forcing <no_action/>");
|
||||
WulaLog.Debug($"[WulaAI] Turn {phaseIndex}/4 still missing XML after retry; forcing <no_action/>");
|
||||
}
|
||||
response = phase == RequestPhase.Cosmetic
|
||||
? "<change_expression><expression_id>2</expression_id></change_expression>"
|
||||
@@ -666,7 +666,7 @@ Example (changing to a neutral expression):
|
||||
PersistHistory();
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message("[WulaAI] Turn 3/4 missing <change_expression>; retrying once");
|
||||
WulaLog.Debug("[WulaAI] Turn 3/4 missing <change_expression>; retrying once");
|
||||
}
|
||||
|
||||
string retry = await client.GetChatCompletionAsync(systemInstruction, _history);
|
||||
@@ -678,7 +678,7 @@ Example (changing to a neutral expression):
|
||||
{
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Warning("[WulaAI] Turn 3/4 still missing <change_expression> after retry; forcing default expression_id=2");
|
||||
WulaLog.Debug("[WulaAI] Turn 3/4 still missing <change_expression> after retry; forcing default expression_id=2");
|
||||
}
|
||||
response = "<change_expression><expression_id>2</expression_id></change_expression>";
|
||||
}
|
||||
@@ -689,7 +689,7 @@ Example (changing to a neutral expression):
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Exception in RunPhasedRequestAsync: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Exception in RunPhasedRequestAsync: {ex}");
|
||||
_currentResponse = "Wula_AI_Error_Internal".Translate(ex.Message);
|
||||
}
|
||||
finally
|
||||
@@ -792,7 +792,7 @@ Example (changing to a neutral expression):
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Executing tool (phase {phase}): {toolName} with args: {argsXml}");
|
||||
WulaLog.Debug($"[WulaAI] Executing tool (phase {phase}): {toolName} with args: {argsXml}");
|
||||
}
|
||||
|
||||
string signature = $"{toolName}:{Regex.Replace(argsXml ?? "", @"\s+", " ").Trim()}";
|
||||
@@ -918,7 +918,7 @@ Example (changing to a neutral expression):
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Exception in GenerateResponse: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Exception in GenerateResponse: {ex}");
|
||||
_currentResponse = "Wula_AI_Error_Internal".Translate(ex.Message);
|
||||
}
|
||||
finally
|
||||
@@ -1069,7 +1069,7 @@ Example (changing to a neutral expression):
|
||||
if (tool == null)
|
||||
{
|
||||
string errorMsg = $"Error: Tool '{toolName}' not found.";
|
||||
Log.Error($"[WulaAI] {errorMsg}");
|
||||
WulaLog.Debug($"[WulaAI] {errorMsg}");
|
||||
combinedResults.AppendLine(errorMsg);
|
||||
continue;
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ Example (changing to a neutral expression):
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WulaAI] Executing tool: {toolName} with args: {argsXml}");
|
||||
WulaLog.Debug($"[WulaAI] Executing tool: {toolName} with args: {argsXml}");
|
||||
}
|
||||
|
||||
// Record tool signature for loop detection (before execution, so errors also count)
|
||||
@@ -1096,7 +1096,7 @@ Example (changing to a neutral expression):
|
||||
if (Prefs.DevMode && !string.IsNullOrEmpty(result))
|
||||
{
|
||||
string toLog = result.Length <= 2000 ? result : result.Substring(0, 2000) + $"... (truncated, total {result.Length} chars)";
|
||||
Log.Message($"[WulaAI] Tool '{toolName}' result: {toLog}");
|
||||
WulaLog.Debug($"[WulaAI] Tool '{toolName}' result: {toLog}");
|
||||
}
|
||||
|
||||
if (toolName == "modify_goodwill")
|
||||
@@ -1154,7 +1154,7 @@ Example (changing to a neutral expression):
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Exception in HandleXmlToolUsage: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Exception in HandleXmlToolUsage: {ex}");
|
||||
_history.Add(("tool", $"Error processing tool call: {ex.Message}"));
|
||||
PersistHistory();
|
||||
await GenerateResponse(isContinuation: true);
|
||||
@@ -1535,7 +1535,7 @@ Example (changing to a neutral expression):
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaAI] Failed to clear AI history: {ex}");
|
||||
WulaLog.Debug($"[WulaAI] Failed to clear AI history: {ex}");
|
||||
}
|
||||
|
||||
Messages.Message("已清除 AI 对话上下文历史。", MessageTypeDefOf.NeutralEvent);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System; // Required for Activator
|
||||
using System; // Required for Activator
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
@@ -51,7 +51,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'.");
|
||||
WulaLog.Debug($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'.");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Verse;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
@@ -58,7 +58,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Warning($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
|
||||
WulaLog.Debug($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
|
||||
reason = "Type mismatch or parsing error during comparison.";
|
||||
return false;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ namespace WulaFallenEmpire
|
||||
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
||||
if (!eventVarManager.HasVariable(name))
|
||||
{
|
||||
Log.Message($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f.");
|
||||
WulaLog.Debug($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f.");
|
||||
eventVarManager.SetVariable(name, 0f);
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ namespace WulaFallenEmpire
|
||||
if (float.IsNaN(compareValue))
|
||||
{
|
||||
reason = $"Comparison variable '{valueVariableName}' not set or not a number.";
|
||||
Log.Warning($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}");
|
||||
WulaLog.Debug($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool met = Compare(variable, compareValue);
|
||||
Log.Message($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}");
|
||||
WulaLog.Debug($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}");
|
||||
if (!met)
|
||||
{
|
||||
reason = $"Requires {name} {GetOperatorString()} {compareValue} (Current: {variable})";
|
||||
@@ -195,12 +195,12 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Warning($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
|
||||
WulaLog.Debug($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
|
||||
reason = "Type mismatch or parsing error during comparison.";
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Message($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}");
|
||||
WulaLog.Debug($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}");
|
||||
if (!met)
|
||||
{
|
||||
reason = $"Requires {name} != {compareValueStr} (Current: {variable})";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Verse;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
@@ -40,7 +40,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
|
||||
WulaLog.Debug($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
|
||||
return flagExists;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
@@ -60,7 +60,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}");
|
||||
}
|
||||
actions.RemoveAt(i);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace WulaFallenEmpire
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 错误处理:如果滚动视图出现问题,回退到简单标签
|
||||
Log.Warning($"[CustomDisplay] Error in description scroll view: {ex.Message}");
|
||||
WulaLog.Debug($"[CustomDisplay] Error in description scroll view: {ex.Message}");
|
||||
Widgets.Label(outRect, text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System; // Required for Activator
|
||||
using System; // Required for Activator
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -29,7 +29,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -64,7 +64,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (incident == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_FireIncident has a null incident Def.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_FireIncident has a null incident Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!incident.Worker.TryExecute(parms))
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Could not fire incident {incident.defName}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Could not fire incident {incident.defName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,14 +145,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (faction == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
|
||||
if (targetFaction == null)
|
||||
{
|
||||
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,14 +204,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (faction == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
|
||||
if (targetFaction == null)
|
||||
{
|
||||
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -230,12 +230,12 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (kindDef == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef.");
|
||||
return;
|
||||
}
|
||||
if (storeAs.NullOrEmpty())
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,14 +269,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (thingDef == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_GiveThing has a null thingDef.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_GiveThing has a null thingDef.");
|
||||
return;
|
||||
}
|
||||
|
||||
Map currentMap = Find.CurrentMap;
|
||||
if (currentMap == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,14 +303,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (kindDef == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef.");
|
||||
return;
|
||||
}
|
||||
|
||||
Map map = Find.CurrentMap;
|
||||
if (map == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace WulaFallenEmpire
|
||||
valueStr = eventVarManager.GetVariable<object>(valueVariableName)?.ToString();
|
||||
if (valueStr == null)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,7 @@ namespace WulaFallenEmpire
|
||||
object variable = eventVarManager.GetVariable<object>(name);
|
||||
if (variable == null)
|
||||
{
|
||||
Log.Message($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0.");
|
||||
WulaLog.Debug($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0.");
|
||||
variable = 0;
|
||||
}
|
||||
|
||||
@@ -406,12 +406,12 @@ namespace WulaFallenEmpire
|
||||
newValue = Modify(currentVal, modVal, operation);
|
||||
}
|
||||
|
||||
Log.Message($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}");
|
||||
WulaLog.Debug($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}");
|
||||
eventVarManager.SetVariable(name, newValue);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace WulaFallenEmpire
|
||||
case VariableOperation.Multiply: return current * modifier;
|
||||
case VariableOperation.Divide:
|
||||
if (modifier != 0) return current / modifier;
|
||||
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero.");
|
||||
return current;
|
||||
default: return current;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
|
||||
return;
|
||||
}
|
||||
Find.World.GetComponent<EventVariableManager>().ClearVariable(name);
|
||||
@@ -453,17 +453,17 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (quest == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
|
||||
return;
|
||||
}
|
||||
// 使用标准的任务生成方法,而不是创建raw quest
|
||||
// ʹ<EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><EFBFBD><EFBFBD>raw quest
|
||||
Quest newQuest = QuestUtility.GenerateQuestAndMakeAvailable(quest, 0);
|
||||
|
||||
if (newQuest != null)
|
||||
{
|
||||
Log.Message($"[WulaFallenEmpire] Successfully added quest: {quest.defName}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Successfully added quest: {quest.defName}");
|
||||
|
||||
// 如果不是自动接受的任务,发送可用信件
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD>
|
||||
if (!newQuest.root.autoAccept)
|
||||
{
|
||||
QuestUtility.SendLetterQuestAvailable(newQuest);
|
||||
@@ -471,7 +471,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Failed to generate quest: {quest.defName}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Failed to generate quest: {quest.defName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -484,7 +484,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (research == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -507,14 +507,14 @@ namespace WulaFallenEmpire
|
||||
Map map = Find.CurrentMap;
|
||||
if (map == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map.");
|
||||
return;
|
||||
}
|
||||
|
||||
Faction factionInst = Find.FactionManager.FirstFactionOfDef(this.faction);
|
||||
if (factionInst == null)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (factionDef == null || string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -589,12 +589,12 @@ namespace WulaFallenEmpire
|
||||
if (faction != null)
|
||||
{
|
||||
int goodwill = faction.GoodwillWith(Faction.OfPlayer);
|
||||
Log.Message($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, goodwill);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, 0);
|
||||
}
|
||||
}
|
||||
@@ -608,13 +608,13 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName).");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName).");
|
||||
return;
|
||||
}
|
||||
|
||||
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
||||
float realPlayTime = Find.GameInfo.RealPlayTimeInteracting;
|
||||
Log.Message($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, realPlayTime);
|
||||
}
|
||||
}
|
||||
@@ -627,13 +627,13 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName).");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName).");
|
||||
return;
|
||||
}
|
||||
|
||||
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
||||
int daysPassed = GenDate.DaysPassed;
|
||||
Log.Message($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, daysPassed);
|
||||
}
|
||||
}
|
||||
@@ -646,20 +646,20 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(variableName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName).");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName).");
|
||||
return;
|
||||
}
|
||||
|
||||
Map currentMap = Find.CurrentMap;
|
||||
if (currentMap == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map.");
|
||||
return;
|
||||
}
|
||||
|
||||
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
||||
float wealth = currentMap.wealthWatcher.WealthTotal;
|
||||
Log.Message($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
|
||||
eventVarManager.SetVariable(variableName, wealth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
@@ -20,13 +20,13 @@ namespace WulaFallenEmpire
|
||||
Map currentMap = Find.CurrentMap;
|
||||
if (currentMap == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller cannot execute without a current map.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller cannot execute without a current map.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (skyfallerDef == null)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller has a null skyfallerDef.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller has a null skyfallerDef.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!dropCenter.IsValid)
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_CallSkyfaller could not find a valid drop spot.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_CallSkyfaller could not find a valid drop spot.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace WulaFallenEmpire
|
||||
Find.LetterStack.ReceiveLetter(letterLabel, letterText, letterDef ?? LetterDefOf.NeutralEvent);
|
||||
}
|
||||
|
||||
Log.Message($"[WulaFallenEmpire] Scheduled skyfaller '{skyfallerDef.defName}' at {dropCenter} with {delayTicks} ticks delay");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Scheduled skyfaller '{skyfallerDef.defName}' at {dropCenter} with {delayTicks} ticks delay");
|
||||
}
|
||||
|
||||
private IntVec3 FindDropSpotWithClearance(Map map, int radius)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using WulaFallenEmpire.EventSystem.AI;
|
||||
@@ -26,7 +26,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Effect_OpenAIConversation could not find EventDef named '{defName}'");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Effect_OpenAIConversation could not find EventDef named '{defName}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// 在 EffectBase.cs 中添加以下类
|
||||
// 在 EffectBase.cs 中添加以下类
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(flagName))
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] Effect_SetTimedFlag has a null or empty flagName.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] Effect_SetTimedFlag has a null or empty flagName.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace WulaFallenEmpire
|
||||
eventVarManager.SetTimedFlag(flagName, durationTicks);
|
||||
|
||||
string durationInfo = durationTicks < 0 ? "permanent" : $"{durationTicks} ticks";
|
||||
Log.Message($"[EventSystem] Set timed flag '{flagName}' with duration: {durationInfo}");
|
||||
WulaLog.Debug($"[EventSystem] Set timed flag '{flagName}' with duration: {durationInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
@@ -76,7 +76,7 @@ namespace WulaFallenEmpire
|
||||
if (kvp.Value >= 0 && currentTick >= kvp.Value)
|
||||
{
|
||||
flagsToRemove.Add(kvp.Key);
|
||||
Log.Message($"[EventSystem] Flag '{kvp.Key}' expired and will be removed.");
|
||||
WulaLog.Debug($"[EventSystem] Flag '{kvp.Key}' expired and will be removed.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace WulaFallenEmpire
|
||||
if (string.IsNullOrEmpty(name)) return;
|
||||
|
||||
// Log the variable change
|
||||
Log.Message($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}.");
|
||||
WulaLog.Debug($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}.");
|
||||
|
||||
// Clear any existing variable with the same name to prevent type confusion
|
||||
ClearVariable(name);
|
||||
@@ -120,7 +120,7 @@ namespace WulaFallenEmpire
|
||||
else if (value != null)
|
||||
{
|
||||
stringVars[name] = value.ToString();
|
||||
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,13 +138,13 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
// 负数表示永久flag
|
||||
expiryTick = -1;
|
||||
Log.Message($"[EventSystem] Setting permanent flag '{flagName}'.");
|
||||
WulaLog.Debug($"[EventSystem] Setting permanent flag '{flagName}'.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 正数表示有时间限制的flag
|
||||
expiryTick = Find.TickManager.TicksGame + durationTicks;
|
||||
Log.Message($"[EventSystem] Setting timed flag '{flagName}' with duration {durationTicks} ticks (expires at tick {expiryTick}).");
|
||||
WulaLog.Debug($"[EventSystem] Setting timed flag '{flagName}' with duration {durationTicks} ticks (expires at tick {expiryTick}).");
|
||||
}
|
||||
|
||||
timedFlags[flagName] = expiryTick;
|
||||
@@ -172,7 +172,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
// 如果过期了,移除它
|
||||
timedFlags.Remove(flagName);
|
||||
Log.Message($"[EventSystem] Flag '{flagName}' has expired and was removed.");
|
||||
WulaLog.Debug($"[EventSystem] Flag '{flagName}' has expired and was removed.");
|
||||
}
|
||||
return isActive;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}");
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (HasVariable(name))
|
||||
{
|
||||
Log.Message($"[EventSystem] Clearing variable '{name}'.");
|
||||
WulaLog.Debug($"[EventSystem] Clearing variable '{name}'.");
|
||||
}
|
||||
intVars.Remove(name);
|
||||
floatVars.Remove(name);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using RimWorld.QuestGen;
|
||||
using System;
|
||||
using Verse;
|
||||
@@ -25,7 +25,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (defName.NullOrEmpty())
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] QuestNode_EventLetter: eventDefName is not specified.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] QuestNode_EventLetter: eventDefName is not specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,11 +49,11 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
base.Notify_QuestSignalReceived(signal);
|
||||
|
||||
Log.Message($"[WulaFallenEmpire] QuestPart_EventLetter received signal: '{signal.tag}', waiting for: '{inSignal}'");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] QuestPart_EventLetter received signal: '{signal.tag}', waiting for: '{inSignal}'");
|
||||
|
||||
if (signal.tag == inSignal)
|
||||
{
|
||||
Log.Message($"[WulaFallenEmpire] Signal matched! Opening EventDef: {eventDefName}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Signal matched! Opening EventDef: {eventDefName}");
|
||||
OpenEventDefWindow(eventDefName);
|
||||
}
|
||||
}
|
||||
@@ -65,26 +65,26 @@ namespace WulaFallenEmpire
|
||||
EventDef eventDef = DefDatabase<EventDef>.GetNamed(defName, false);
|
||||
if (eventDef == null)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] EventDef '{defName}' not found in DefDatabase.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] EventDef '{defName}' not found in DefDatabase.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventDef.windowType == null)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] EventDef '{defName}' has null windowType.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] EventDef '{defName}' has null windowType.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Message($"[WulaFallenEmpire] Creating window instance for {defName} with type {eventDef.windowType}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Creating window instance for {defName} with type {eventDef.windowType}");
|
||||
Window window = (Window)Activator.CreateInstance(eventDef.windowType, eventDef);
|
||||
|
||||
Log.Message($"[WulaFallenEmpire] Adding window to WindowStack");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Adding window to WindowStack");
|
||||
Find.WindowStack.Add(window);
|
||||
Log.Message($"[WulaFallenEmpire] Successfully opened EventDef window: {defName}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Successfully opened EventDef window: {defName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] Error opening EventDef window '{defName}': {ex}");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] Error opening EventDef window '{defName}': {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using RimWorld.QuestGen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,7 +28,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (defName.NullOrEmpty())
|
||||
{
|
||||
Log.Error("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
|
||||
WulaLog.Debug("[WulaFallenEmpire] QuestNode_Root_EventLetter: eventDefName is not specified.");
|
||||
return false;
|
||||
}
|
||||
|
||||
EventDef eventDef = DefDatabase<EventDef>.GetNamed(defName, false);
|
||||
if (eventDef == null)
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] QuestNode_Root_EventLetter: EventDef '{defName}' not found.");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] QuestNode_Root_EventLetter: EventDef '{defName}' not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WulaFallenEmpire] QuestNode_Root_EventLetter: Could not find EventDef '{defName}'");
|
||||
WulaLog.Debug($"[WulaFallenEmpire] QuestNode_Root_EventLetter: Could not find EventDef '{defName}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using RimWorld.QuestGen;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
@@ -97,7 +97,7 @@ namespace WulaFallenEmpire
|
||||
string targetName = targetVariableName.GetValue(slate);
|
||||
if (string.IsNullOrEmpty(targetName))
|
||||
{
|
||||
Log.Error("[QuestNode_WriteToEventVariablesWithAdd] targetVariableName is null or empty!");
|
||||
WulaLog.Debug("[QuestNode_WriteToEventVariablesWithAdd] targetVariableName is null or empty!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] No value to operate for variable '{targetName}'.");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] No value to operate for variable '{targetName}'.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ namespace WulaFallenEmpire
|
||||
var eventVarManager = Find.World.GetComponent<EventVariableManager>();
|
||||
if (eventVarManager == null)
|
||||
{
|
||||
Log.Error("[QuestNode_WriteToEventVariablesWithAdd] EventVariableManager not found!");
|
||||
WulaLog.Debug("[QuestNode_WriteToEventVariablesWithAdd] EventVariableManager not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -132,10 +132,10 @@ namespace WulaFallenEmpire
|
||||
// 记录操作前的状态
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Message($"[QuestNode_WriteToEventVariablesWithAdd] Operation for variable '{targetName}':");
|
||||
Log.Message($" - Mode: {writeMode}");
|
||||
Log.Message($" - Current value: {currentValue ?? "[null]"} (Type: {currentValue?.GetType().Name ?? "null"})");
|
||||
Log.Message($" - Source value: {sourceValue ?? "[null]"} (Type: {sourceValue?.GetType().Name ?? "null"})");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Operation for variable '{targetName}':");
|
||||
WulaLog.Debug($" - Mode: {writeMode}");
|
||||
WulaLog.Debug($" - Current value: {currentValue ?? "[null]"} (Type: {currentValue?.GetType().Name ?? "null"})");
|
||||
WulaLog.Debug($" - Source value: {sourceValue ?? "[null]"} (Type: {sourceValue?.GetType().Name ?? "null"})");
|
||||
}
|
||||
|
||||
// 根据写入模式计算新值
|
||||
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Message($" - Operation skipped (new value is null)");
|
||||
WulaLog.Debug($" - Operation skipped (new value is null)");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace WulaFallenEmpire
|
||||
slate.Remove(sourceVariableName.GetValue(slate));
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Message($" - Removed source variable '{sourceVariableName.GetValue(slate)}' from Slate");
|
||||
WulaLog.Debug($" - Removed source variable '{sourceVariableName.GetValue(slate)}' from Slate");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,11 +171,11 @@ namespace WulaFallenEmpire
|
||||
bool writeVerified = (readBackValue == null && newValue == null) ||
|
||||
(readBackValue != null && readBackValue.Equals(newValue));
|
||||
|
||||
Log.Message($" - New value written: {newValue} (Type: {newValue.GetType().Name})");
|
||||
Log.Message($" - Write verified: {writeVerified}");
|
||||
WulaLog.Debug($" - New value written: {newValue} (Type: {newValue.GetType().Name})");
|
||||
WulaLog.Debug($" - Write verified: {writeVerified}");
|
||||
if (!writeVerified)
|
||||
{
|
||||
Log.Warning($" - Verification failed! Expected: {newValue}, Got: {readBackValue}");
|
||||
WulaLog.Debug($" - Verification failed! Expected: {newValue}, Got: {readBackValue}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Message($" - Variable exists and overwrite is false, keeping current value");
|
||||
WulaLog.Debug($" - Variable exists and overwrite is false, keeping current value");
|
||||
}
|
||||
return currentValue; // 不覆盖,返回原值
|
||||
}
|
||||
@@ -281,7 +281,7 @@ namespace WulaFallenEmpire
|
||||
case MathOperator.Divide:
|
||||
if (source == 0)
|
||||
{
|
||||
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Division by zero for variable operation");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Division by zero for variable operation");
|
||||
return currentValue;
|
||||
}
|
||||
result = current / source;
|
||||
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Math operation failed: {ex.Message}");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Math operation failed: {ex.Message}");
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
@@ -404,7 +404,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] Cannot increment non-numeric type: {currentValue.GetType().Name}");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Cannot increment non-numeric type: {currentValue.GetType().Name}");
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
@@ -427,7 +427,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Error($"[QuestNode_WriteToEventVariablesWithAdd] Increment operation failed: {ex.Message}");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Increment operation failed: {ex.Message}");
|
||||
}
|
||||
return currentValue;
|
||||
}
|
||||
@@ -437,7 +437,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Warning($"[QuestNode_WriteToEventVariablesWithAdd] Type mismatch for operation: {mismatchReason}");
|
||||
WulaLog.Debug($"[QuestNode_WriteToEventVariablesWithAdd] Type mismatch for operation: {mismatchReason}");
|
||||
}
|
||||
|
||||
switch (onTypeMismatch)
|
||||
@@ -448,7 +448,7 @@ namespace WulaFallenEmpire
|
||||
case TypeMismatchBehavior.Skip:
|
||||
if (logDebug.GetValue(slate))
|
||||
{
|
||||
Log.Message($" - Skipping operation due to type mismatch");
|
||||
WulaLog.Debug($" - Skipping operation due to type mismatch");
|
||||
}
|
||||
return currentValue; // 保持原值
|
||||
|
||||
|
||||
Reference in New Issue
Block a user