✅ 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 @@
|
||||
// Building_GlobalWorkTable.cs (修改版本)
|
||||
// Building_GlobalWorkTable.cs (修改版本)
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -322,18 +322,18 @@ namespace WulaFallenEmpire
|
||||
// 显示成功消息
|
||||
Messages.Message("WULA_SilverTransferred".Translate(silverAmount), MessageTypeDefOf.PositiveEvent);
|
||||
|
||||
Log.Message($"[WULA] Transferred {silverAmount} silver from input to output storage");
|
||||
WulaLog.Debug($"[WULA] Transferred {silverAmount} silver from input to output storage");
|
||||
}
|
||||
else
|
||||
{
|
||||
Messages.Message("WULA_TransferFailed".Translate(), MessageTypeDefOf.RejectInput);
|
||||
Log.Error("[WULA] Failed to remove silver from input storage during transfer");
|
||||
WulaLog.Debug("[WULA] Failed to remove silver from input storage during transfer");
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Messages.Message("WULA_TransferError".Translate(), MessageTypeDefOf.RejectInput);
|
||||
Log.Error($"[WULA] Error during silver transfer: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error during silver transfer: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace WulaFallenEmpire
|
||||
//}
|
||||
//catch (System.Exception ex)
|
||||
//{
|
||||
// Log.Error($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
|
||||
// WulaLog.Debug($"[FactoryFacility Check] Error in HasFactoryFacilityFlyOver: {ex}");
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
@@ -593,7 +593,7 @@ namespace WulaFallenEmpire
|
||||
// 记录分配结果
|
||||
for (int i = 0; i < podContents.Count; i++)
|
||||
{
|
||||
Log.Message($"[Airdrop] Pod {i} contains {podContents[i].Count} items");
|
||||
WulaLog.Debug($"[Airdrop] Pod {i} contains {podContents[i].Count} items");
|
||||
}
|
||||
return podContents;
|
||||
}
|
||||
@@ -652,14 +652,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (pawnType.race == null)
|
||||
{
|
||||
Log.Error($"[Airdrop] GetRandomPawnKindForType: {pawnType.defName} is not a pawn type");
|
||||
WulaLog.Debug($"[Airdrop] GetRandomPawnKindForType: {pawnType.defName} is not a pawn type");
|
||||
return null;
|
||||
}
|
||||
// 获取工作台的派系
|
||||
Faction workTableFaction = this.Faction;
|
||||
if (workTableFaction == null)
|
||||
{
|
||||
Log.Error($"[Airdrop] Work table has no faction");
|
||||
WulaLog.Debug($"[Airdrop] Work table has no faction");
|
||||
return null;
|
||||
}
|
||||
// 获取该种族的所有PawnKindDef
|
||||
@@ -668,7 +668,7 @@ namespace WulaFallenEmpire
|
||||
.ToList();
|
||||
if (availableKinds.Count == 0)
|
||||
{
|
||||
Log.Error($"[Airdrop] No PawnKindDef found for race: {pawnType.defName}");
|
||||
WulaLog.Debug($"[Airdrop] No PawnKindDef found for race: {pawnType.defName}");
|
||||
return null;
|
||||
}
|
||||
// 最高优先级:与工作台派系完全相同的PawnKind
|
||||
@@ -702,12 +702,12 @@ namespace WulaFallenEmpire
|
||||
if (noFactionKinds.Count > 0)
|
||||
{
|
||||
var selected = noFactionKinds.RandomElement();
|
||||
Log.Message($"[Airdrop] Selected no-faction PawnKind: {selected.defName}");
|
||||
WulaLog.Debug($"[Airdrop] Selected no-faction PawnKind: {selected.defName}");
|
||||
return selected;
|
||||
}
|
||||
// 最后选择任何可用的PawnKind
|
||||
var selectedKind = availableKinds.RandomElement();
|
||||
Log.Message($"[Airdrop] Selected fallback PawnKind: {selectedKind.defName}");
|
||||
WulaLog.Debug($"[Airdrop] Selected fallback PawnKind: {selectedKind.defName}");
|
||||
return selectedKind;
|
||||
}
|
||||
|
||||
@@ -729,14 +729,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (contents == null || contents.Count == 0)
|
||||
{
|
||||
Log.Warning("[Airdrop] CreateDropPod: contents is null or empty");
|
||||
WulaLog.Debug("[Airdrop] CreateDropPod: contents is null or empty");
|
||||
return false;
|
||||
}
|
||||
Log.Message($"[Airdrop] Creating drop pod at {dropCell} with {contents.Count} items");
|
||||
WulaLog.Debug($"[Airdrop] Creating drop pod at {dropCell} with {contents.Count} items");
|
||||
// 检查目标单元格是否有效
|
||||
if (!dropCell.IsValid || !dropCell.InBounds(Map))
|
||||
{
|
||||
Log.Error($"[Airdrop] Invalid drop cell: {dropCell}");
|
||||
WulaLog.Debug($"[Airdrop] Invalid drop cell: {dropCell}");
|
||||
return false;
|
||||
}
|
||||
// 创建空投舱信息 - 使用 DropPodInfo 而不是 ActiveTransporterInfo
|
||||
@@ -752,29 +752,29 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (!container.TryAdd(thing, true))
|
||||
{
|
||||
Log.Error($"[Airdrop] Failed to add {thing.Label} to drop pod");
|
||||
WulaLog.Debug($"[Airdrop] Failed to add {thing.Label} to drop pod");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[Airdrop] Added {thing.Label} to drop pod");
|
||||
WulaLog.Debug($"[Airdrop] Added {thing.Label} to drop pod");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (container.Count == 0)
|
||||
{
|
||||
Log.Warning("[Airdrop] No items were successfully added to drop pod");
|
||||
WulaLog.Debug("[Airdrop] No items were successfully added to drop pod");
|
||||
return false;
|
||||
}
|
||||
dropPodInfo.innerContainer = container;
|
||||
// 生成空投舱
|
||||
DropPodUtility.MakeDropPodAt(dropCell, Map, dropPodInfo, Faction.OfPlayer);
|
||||
|
||||
Log.Message($"[Airdrop] Successfully created drop pod at {dropCell}");
|
||||
WulaLog.Debug($"[Airdrop] Successfully created drop pod at {dropCell}");
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[Airdrop] Failed to create drop pod at {dropCell}: {ex}");
|
||||
WulaLog.Debug($"[Airdrop] Failed to create drop pod at {dropCell}: {ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// GlobalProductionOrder.cs (修复成本计算,使用产物的costList)
|
||||
// GlobalProductionOrder.cs (修复成本计算,使用产物的costList)
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -37,7 +37,7 @@ namespace WulaFallenEmpire
|
||||
_progress = Mathf.Clamp01(value);
|
||||
if (value < 0f || value > 1f)
|
||||
{
|
||||
Log.Warning($"Progress clamped from {value} to {_progress} for {recipe?.defName ?? "unknown"}");
|
||||
WulaLog.Debug($"Progress clamped from {value} to {_progress} for {recipe?.defName ?? "unknown"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
@@ -94,7 +94,7 @@ namespace WulaFallenEmpire
|
||||
// 防止除零错误
|
||||
if (workAmount <= 0)
|
||||
{
|
||||
Log.Error($"Invalid workAmount ({workAmount}) for recipe {order.recipe.defName}");
|
||||
WulaLog.Debug($"Invalid workAmount ({workAmount}) for recipe {order.recipe.defName}");
|
||||
order.state = GlobalProductionOrder.ProductionState.Gathering;
|
||||
order.progress = 0f;
|
||||
return;
|
||||
@@ -110,7 +110,7 @@ namespace WulaFallenEmpire
|
||||
// 调试信息
|
||||
if (Find.TickManager.TicksGame % 300 == 0) // 每5秒输出一次
|
||||
{
|
||||
Log.Message($"[DEBUG] Order {order.recipe.defName}: " +
|
||||
WulaLog.Debug($"[DEBUG] Order {order.recipe.defName}: " +
|
||||
$"progress={order.progress:P2}, " +
|
||||
$"workAmount={workAmount}, " +
|
||||
$"increment={progressIncrement:E4}, " +
|
||||
@@ -153,7 +153,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
|
||||
// 最后的回退方案
|
||||
Log.Warning($"Could not determine work amount for recipe {order.recipe.defName}, using default value");
|
||||
WulaLog.Debug($"Could not determine work amount for recipe {order.recipe.defName}, using default value");
|
||||
return 1000f; // 默认工作量
|
||||
}
|
||||
|
||||
@@ -169,17 +169,17 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (Find.TickManager.TicksGame % 600 == 0) // 每10秒记录一次
|
||||
{
|
||||
Log.Message($"[INFO] Order {order.recipe.defName} started producing");
|
||||
WulaLog.Debug($"[INFO] Order {order.recipe.defName} started producing");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[WULA] Order {order.recipe.defName} had enough resources but failed to deduct them; staying in Gathering.");
|
||||
WulaLog.Debug($"[WULA] Order {order.recipe.defName} had enough resources but failed to deduct them; staying in Gathering.");
|
||||
}
|
||||
}
|
||||
else if (Find.TickManager.TicksGame % 1200 == 0) // 每20秒检查一次
|
||||
{
|
||||
Log.Message($"[DEBUG] Order {order.recipe.defName} is waiting. " +
|
||||
WulaLog.Debug($"[DEBUG] Order {order.recipe.defName} is waiting. " +
|
||||
$"HasEnoughResources: {order.HasEnoughResources()}");
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ namespace WulaFallenEmpire
|
||||
// 生产完成(资源已经在开始生产时扣除)
|
||||
order.Produce();
|
||||
|
||||
Log.Message($"[SUCCESS] Produced {order.recipe.products[0].thingDef.defName}, " +
|
||||
WulaLog.Debug($"[SUCCESS] Produced {order.recipe.products[0].thingDef.defName}, " +
|
||||
$"count: {order.currentCount}/{order.targetCount}");
|
||||
|
||||
// 重置进度
|
||||
@@ -200,7 +200,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
order.state = GlobalProductionOrder.ProductionState.Completed;
|
||||
Delete(order); // 同步 GlobalStorageWorldComponent.productionOrders
|
||||
Log.Message($"[COMPLETE] Order {order.recipe.defName} completed and removed");
|
||||
WulaLog.Debug($"[COMPLETE] Order {order.recipe.defName} completed and removed");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -222,23 +222,23 @@ namespace WulaFallenEmpire
|
||||
if (float.IsNaN(order.progress) || float.IsInfinity(order.progress))
|
||||
{
|
||||
order.progress = 0f;
|
||||
Log.Warning($"Fixed invalid progress for {order.recipe?.defName ?? "unknown"}");
|
||||
WulaLog.Debug($"Fixed invalid progress for {order.recipe?.defName ?? "unknown"}");
|
||||
}
|
||||
else if (order.progress < 0f)
|
||||
{
|
||||
order.progress = 0f;
|
||||
Log.Warning($"Fixed negative progress for {order.recipe?.defName ?? "unknown"}");
|
||||
WulaLog.Debug($"Fixed negative progress for {order.recipe?.defName ?? "unknown"}");
|
||||
}
|
||||
else if (order.progress > 1f)
|
||||
{
|
||||
order.progress = 1f;
|
||||
Log.Warning($"Fixed excessive progress for {order.recipe?.defName ?? "unknown"}");
|
||||
WulaLog.Debug($"Fixed excessive progress for {order.recipe?.defName ?? "unknown"}");
|
||||
}
|
||||
|
||||
// 修复状态
|
||||
if (order.recipe == null)
|
||||
{
|
||||
Log.Warning($"Removing order with null recipe");
|
||||
WulaLog.Debug($"Removing order with null recipe");
|
||||
Delete(order); // 同步 GlobalStorageWorldComponent.productionOrders
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// GlobalStorageWorldComponent.cs (移除材质相关存储)
|
||||
// GlobalStorageWorldComponent.cs (移除材质相关存储)
|
||||
using LudeonTK;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
@@ -247,7 +247,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
globalStorage.AddToInputStorage(ThingDefOf.Steel, 200);
|
||||
globalStorage.AddToInputStorage(ThingDefOf.ComponentIndustrial, 100);
|
||||
Log.Message("Added test resources to global storage");
|
||||
WulaLog.Debug("Added test resources to global storage");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace WulaFallenEmpire
|
||||
globalStorage.outputContainer.Remove(thing);
|
||||
GenPlace.TryPlaceThing(thing, workTable.Position, workTable.Map, ThingPlaceMode.Near);
|
||||
}
|
||||
Log.Message("Spawned all output products");
|
||||
WulaLog.Debug("Spawned all output products");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// ITab_GlobalBills.cs (移除材质选择功能)
|
||||
// ITab_GlobalBills.cs (移除材质选择功能)
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -622,7 +622,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!resourcesConsumed)
|
||||
{
|
||||
Log.Message($"[GOD MODE] Could not consume resources for {order.recipe.defName}, completing without resource consumption");
|
||||
WulaLog.Debug($"[GOD MODE] Could not consume resources for {order.recipe.defName}, completing without resource consumption");
|
||||
}
|
||||
|
||||
// 添加产品到输出存储
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -45,14 +45,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (!this.parent.Spawned)
|
||||
{
|
||||
Log.Error("Tried to launch " + this.parent + " but it's not spawned.");
|
||||
WulaLog.Debug("Tried to launch " + this.parent + " but it's not spawned.");
|
||||
return;
|
||||
}
|
||||
|
||||
var globalStorage = Find.World.GetComponent<GlobalStorageWorldComponent>();
|
||||
if (globalStorage == null)
|
||||
{
|
||||
Log.Error("Could not find GlobalStorageWorldComponent.");
|
||||
WulaLog.Debug("Could not find GlobalStorageWorldComponent.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -96,7 +96,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[CompGarbageShield] Could not find EventDef named '{Props.garbageShieldUIEventDefName}'.");
|
||||
WulaLog.Debug($"[CompGarbageShield] Could not find EventDef named '{Props.garbageShieldUIEventDefName}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -158,7 +158,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA ValueConverter] Error in GetConversionDescription: {ex}");
|
||||
WulaLog.Debug($"[WULA ValueConverter] Error in GetConversionDescription: {ex}");
|
||||
return "WULA_ConversionDescriptionError".Translate();
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!this.parent.Spawned)
|
||||
{
|
||||
Log.Error("Tried to convert " + this.parent + " but it's not spawned.");
|
||||
WulaLog.Debug("Tried to convert " + this.parent + " but it's not spawned.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("Could not find GlobalStorageWorldComponent.");
|
||||
WulaLog.Debug("Could not find GlobalStorageWorldComponent.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[CompValueConverter] Could not find EventDef named '{uiEventDefName}'.");
|
||||
WulaLog.Debug($"[CompValueConverter] Could not find EventDef named '{uiEventDefName}'.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,7 +378,7 @@ namespace WulaFallenEmpire
|
||||
public new void TryLaunch(PlanetTile destinationTile, TransportersArrivalAction arrivalAction)
|
||||
{
|
||||
// 这个方法不应该被直接调用,应该使用ConvertToCurrency
|
||||
Log.Warning("CompValueConverter.TryLaunch should not be called directly. Use ConvertToCurrency instead.");
|
||||
WulaLog.Debug("CompValueConverter.TryLaunch should not be called directly. Use ConvertToCurrency instead.");
|
||||
ConvertToCurrency();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
@@ -15,13 +15,13 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (!(t is Building_GlobalWorkTable table) || !table.Spawned || table.IsForbidden(pawn))
|
||||
{
|
||||
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Target invalid or forbidden. {t}");
|
||||
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Target invalid or forbidden. {t}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pawn.CanReserve(table, 1, -1, null, forced))
|
||||
{
|
||||
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Cannot reserve table.");
|
||||
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Cannot reserve table.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (forced)
|
||||
{
|
||||
Log.Message($"[WULA_DEBUG] HasJobOnThing: No gathering order found. Total orders: {table.globalOrderStack.orders.Count}");
|
||||
WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: No gathering order found. Total orders: {table.globalOrderStack.orders.Count}");
|
||||
foreach (var o in table.globalOrderStack.orders)
|
||||
{
|
||||
Log.Message($" - Order: {o.Label}, State: {o.state}, Paused: {o.paused}");
|
||||
WulaLog.Debug($" - Order: {o.Label}, State: {o.state}, Paused: {o.paused}");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -45,7 +45,7 @@ namespace WulaFallenEmpire
|
||||
var neededMaterials = GetNeededMaterials(order, table, globalStorage);
|
||||
if (neededMaterials.Count == 0)
|
||||
{
|
||||
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Order has enough resources.");
|
||||
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Order has enough resources.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace WulaFallenEmpire
|
||||
var ingredients = FindBestIngredients(pawn, table, neededMaterials);
|
||||
if (ingredients == null)
|
||||
{
|
||||
if (forced) Log.Message($"[WULA_DEBUG] HasJobOnThing: Could not find ingredients for {order.Label}.");
|
||||
if (forced) WulaLog.Debug($"[WULA_DEBUG] HasJobOnThing: Could not find ingredients for {order.Label}.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
var result = new List<KeyValuePair<Thing, int>>();
|
||||
|
||||
Log.Message($"[WULA_DEBUG] Needed materials: {string.Join(", ", neededMaterials.Select(k => $"{k.Key.defName} x{k.Value}"))}");
|
||||
WulaLog.Debug($"[WULA_DEBUG] Needed materials: {string.Join(", ", neededMaterials.Select(k => $"{k.Key.defName} x{k.Value}"))}");
|
||||
|
||||
foreach (var kvp in neededMaterials)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[WULA_DEBUG] Found {currentCount}/{countNeeded} of {def.defName}");
|
||||
WulaLog.Debug($"[WULA_DEBUG] Found {currentCount}/{countNeeded} of {def.defName}");
|
||||
}
|
||||
|
||||
return result.Count > 0 ? result : null;
|
||||
|
||||
Reference in New Issue
Block a user