✅ 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 RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@@ -25,17 +25,17 @@ namespace WulaFallenEmpire
|
||||
protected override void Impact()
|
||||
{
|
||||
// Re-adding debug logs for stage 6
|
||||
Log.Message($"[WULA] Stage 6: Impact - ArmedShuttleIncoming Impact() called. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
|
||||
WulaLog.Debug($"[WULA] Stage 6: Impact - ArmedShuttleIncoming Impact() called. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
|
||||
|
||||
Thing innerThing = innerContainer.FirstOrDefault();
|
||||
if (innerThing is Building_ArmedShuttle shuttle)
|
||||
{
|
||||
Log.Message("[WULA] Stage 6: Impact - InnerThing is a Building_ArmedShuttle. Attempting to notify arrival.");
|
||||
WulaLog.Debug("[WULA] Stage 6: Impact - InnerThing is a Building_ArmedShuttle. Attempting to notify arrival.");
|
||||
shuttle.TryGetComp<CompLaunchable>()?.Notify_Arrived();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[WULA] Stage 6: Impact - InnerThing is NOT a Building_ArmedShuttle or is NULL. Type: {innerThing?.GetType().Name ?? "NULL"}. This is the cause of the issue.");
|
||||
WulaLog.Debug($"[WULA] Stage 6: Impact - InnerThing is NOT a Building_ArmedShuttle or is NULL. Type: {innerThing?.GetType().Name ?? "NULL"}. This is the cause of the issue.");
|
||||
}
|
||||
|
||||
// Calling base.Impact() will handle the actual spawning of the innerThing.
|
||||
@@ -47,7 +47,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
base.SpawnSetup(map, respawningAfterLoad);
|
||||
// Re-adding debug logs for stage 5
|
||||
Log.Message($"[WULA] Stage 5: Landing Sequence - ArmedShuttleIncoming spawned. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
|
||||
WulaLog.Debug($"[WULA] Stage 5: Landing Sequence - ArmedShuttleIncoming spawned. InnerThing (via innerContainer) is: {innerContainer.FirstOrDefault()?.ToString() ?? "NULL"}");
|
||||
if (!respawningAfterLoad && !base.BeingTransportedOnGravship)
|
||||
{
|
||||
angle = GetAngle(0f, base.Rotation);
|
||||
@@ -58,7 +58,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (!hasImpacted)
|
||||
{
|
||||
Log.Error("Destroying armed shuttle skyfaller without ever having impacted"); // Changed log message
|
||||
WulaLog.Debug("Destroying armed shuttle skyfaller without ever having impacted"); // Changed log message
|
||||
}
|
||||
base.Destroy(mode);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RimWorld;
|
||||
@@ -212,7 +212,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (gun == null)
|
||||
{
|
||||
Log.Error("Turret had null gun after loading. Recreating.");
|
||||
WulaLog.Debug("Turret had null gun after loading. Recreating.");
|
||||
MakeGun();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -137,7 +137,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
public Building_ArmedShuttleWithPocket()
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] Building_ArmedShuttleWithPocket constructor called");
|
||||
WulaLog.Debug("[WULA-DEBUG] Building_ArmedShuttleWithPocket constructor called");
|
||||
// 不再初始化innerContainer,只使用CompTransporter的容器
|
||||
}
|
||||
|
||||
@@ -149,14 +149,14 @@ namespace WulaFallenEmpire
|
||||
|
||||
public override void PostMake()
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] PostMake called");
|
||||
WulaLog.Debug("[WULA-DEBUG] PostMake called");
|
||||
base.PostMake();
|
||||
// 不再初始化innerContainer,只使用CompTransporter的容器
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] ExposeData called, mode: {Scribe.mode}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] ExposeData called, mode: {Scribe.mode}");
|
||||
|
||||
base.ExposeData();
|
||||
Scribe_References.Look(ref pocketMap, "pocketMap");
|
||||
@@ -171,24 +171,24 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (Scribe.mode == LoadSaveMode.PostLoadInit)
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] PostLoadInit: Validating components after load");
|
||||
WulaLog.Debug("[WULA-DEBUG] PostLoadInit: Validating components after load");
|
||||
|
||||
// 验证CompTransporter组件是否正常
|
||||
CompTransporter transporter = this.GetComp<CompTransporter>();
|
||||
if (transporter == null)
|
||||
{
|
||||
Log.Error("[WULA-ERROR] CompTransporter is missing after load! This will cause item storage issues.");
|
||||
WulaLog.Debug("[WULA-ERROR] CompTransporter is missing after load! This will cause item storage issues.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] CompTransporter loaded successfully with {transporter.innerContainer?.Count ?? 0} items");
|
||||
WulaLog.Debug($"[WULA-DEBUG] CompTransporter loaded successfully with {transporter.innerContainer?.Count ?? 0} items");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] DeSpawn called with mode: {mode}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] DeSpawn called with mode: {mode}");
|
||||
|
||||
// 只在真正销毁时清理口袋地图,发射时保留
|
||||
if (ShouldDestroyPocketMapOnDeSpawn(mode))
|
||||
@@ -197,7 +197,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] Destroying pocket map due to shuttle destruction");
|
||||
WulaLog.Debug("[WULA-DEBUG] Destroying pocket map due to shuttle destruction");
|
||||
|
||||
// 将口袋空间中的物品和人员转移到主地图
|
||||
TransferAllFromPocketToMainMap();
|
||||
@@ -209,19 +209,19 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA-ERROR] Error cleaning up pocket map: {ex}");
|
||||
WulaLog.Debug($"[WULA-ERROR] Error cleaning up pocket map: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] Preserving pocket map during shuttle launch/transport");
|
||||
WulaLog.Debug("[WULA-DEBUG] Preserving pocket map during shuttle launch/transport");
|
||||
// 发射时暂停传送功能,但保留口袋空间
|
||||
transportDisabled = true;
|
||||
if (pocketMap != null && exit != null)
|
||||
{
|
||||
// 标记传送功能暂停
|
||||
Log.Message("[WULA-DEBUG] Transport functionality disabled during flight");
|
||||
WulaLog.Debug("[WULA-DEBUG] Transport functionality disabled during flight");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace WulaFallenEmpire
|
||||
case DestroyMode.FailConstruction: // 建造失败,删除口袋空间
|
||||
return true;
|
||||
default:
|
||||
Log.Warning($"[WULA-WARNING] Unknown DestroyMode: {mode}, defaulting to preserve pocket map");
|
||||
WulaLog.Debug($"[WULA-WARNING] Unknown DestroyMode: {mode}, defaulting to preserve pocket map");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -432,16 +432,16 @@ namespace WulaFallenEmpire
|
||||
// 在口袋地图中心放置退出点
|
||||
CreateExitPoint();
|
||||
|
||||
Log.Message($"[WULA] Successfully created pocket map of size {pocketMapSize} for armed shuttle");
|
||||
WulaLog.Debug($"[WULA] Successfully created pocket map of size {pocketMapSize} for armed shuttle");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("[WULA] Failed to create pocket map");
|
||||
WulaLog.Debug("[WULA] Failed to create pocket map");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Exception creating pocket map: {ex}");
|
||||
WulaLog.Debug($"[WULA] Exception creating pocket map: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,16 +490,16 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
|
||||
GenPlace.TryPlaceThing(exitBuilding, exitPos, pocketMap, ThingPlaceMode.Direct);
|
||||
Log.Message($"[WULA] Created exit point at {exitPos} in pocket map");
|
||||
WulaLog.Debug($"[WULA] Created exit point at {exitPos} in pocket map");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("[WULA] Could not find valid position for exit point in pocket map");
|
||||
WulaLog.Debug("[WULA] Could not find valid position for exit point in pocket map");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error creating exit point: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error creating exit point: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error transferring pawn {pawn?.LabelShort} to pocket space: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error transferring pawn {pawn?.LabelShort} to pocket space: {ex}");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -536,17 +536,17 @@ namespace WulaFallenEmpire
|
||||
/// </summary>
|
||||
private void TransferAllFromPocketToMainMap()
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] TransferAllFromPocketToMainMap started");
|
||||
WulaLog.Debug("[WULA-DEBUG] TransferAllFromPocketToMainMap started");
|
||||
|
||||
if (pocketMap == null)
|
||||
{
|
||||
Log.Warning("[WULA-DEBUG] TransferAllFromPocketToMainMap: pocketMap is null, nothing to transfer");
|
||||
WulaLog.Debug("[WULA-DEBUG] TransferAllFromPocketToMainMap: pocketMap is null, nothing to transfer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Spawned)
|
||||
{
|
||||
Log.Error("[WULA-ERROR] TransferAllFromPocketToMainMap: Shuttle not spawned, cannot transfer items");
|
||||
WulaLog.Debug("[WULA-ERROR] TransferAllFromPocketToMainMap: Shuttle not spawned, cannot transfer items");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -556,28 +556,28 @@ namespace WulaFallenEmpire
|
||||
CompTransporter transporter = this.GetComp<CompTransporter>();
|
||||
if (transporter == null)
|
||||
{
|
||||
Log.Error("[WULA-ERROR] CompTransporter not found on shuttle! Cannot transfer items.");
|
||||
WulaLog.Debug("[WULA-ERROR] CompTransporter not found on shuttle! Cannot transfer items.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Message($"[WULA-DEBUG] Found CompTransporter with {transporter.innerContainer.Count} existing items");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Found CompTransporter with {transporter.innerContainer.Count} existing items");
|
||||
|
||||
// 转移所有殖民者
|
||||
List<Pawn> pawnsToTransfer = pocketMap.mapPawns.AllPawnsSpawned.ToList();
|
||||
|
||||
Log.Message($"[WULA-DEBUG] Found {pawnsToTransfer.Count} colonists to transfer");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Found {pawnsToTransfer.Count} colonists to transfer");
|
||||
|
||||
foreach (Pawn pawn in pawnsToTransfer)
|
||||
{
|
||||
if (pawn.Spawned)
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Transferring pawn: {pawn.LabelShort}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Transferring pawn: {pawn.LabelShort}");
|
||||
pawn.DeSpawn();
|
||||
|
||||
// 直接放入穿梭机的容器,如果失败就放到地面
|
||||
if (!transporter.innerContainer.TryAdd(pawn))
|
||||
{
|
||||
Log.Warning($"[WULA-WARNING] Container full, placing pawn {pawn.LabelShort} near shuttle");
|
||||
WulaLog.Debug($"[WULA-WARNING] Container full, placing pawn {pawn.LabelShort} near shuttle");
|
||||
// 如果容器满了,放到穿梭机附近
|
||||
IntVec3 spawnPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 5,
|
||||
p => p.Standable(this.Map) && !p.GetThingList(this.Map).Any(t => t is Pawn));
|
||||
@@ -585,16 +585,16 @@ namespace WulaFallenEmpire
|
||||
if (spawnPos.IsValid)
|
||||
{
|
||||
GenPlace.TryPlaceThing(pawn, spawnPos, this.Map, ThingPlaceMode.Near);
|
||||
Log.Message($"[WULA-DEBUG] Placed pawn {pawn.LabelShort} at {spawnPos}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Placed pawn {pawn.LabelShort} at {spawnPos}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WULA-ERROR] Could not find valid position for pawn {pawn.LabelShort}");
|
||||
WulaLog.Debug($"[WULA-ERROR] Could not find valid position for pawn {pawn.LabelShort}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Successfully added pawn {pawn.LabelShort} to container");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Successfully added pawn {pawn.LabelShort} to container");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -603,46 +603,46 @@ namespace WulaFallenEmpire
|
||||
List<Thing> itemsToTransfer = pocketMap.listerThings.AllThings
|
||||
.Where(t => t.def.category == ThingCategory.Item && t.def.EverHaulable).ToList();
|
||||
|
||||
Log.Message($"[WULA-DEBUG] Found {itemsToTransfer.Count} items to transfer");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Found {itemsToTransfer.Count} items to transfer");
|
||||
|
||||
foreach (Thing item in itemsToTransfer)
|
||||
{
|
||||
if (item.Spawned)
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Transferring item: {item.LabelShort} (stack: {item.stackCount})");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Transferring item: {item.LabelShort} (stack: {item.stackCount})");
|
||||
item.DeSpawn();
|
||||
|
||||
// 直接使用穿梭机的主容器
|
||||
if (!transporter.innerContainer.TryAdd(item))
|
||||
{
|
||||
Log.Warning($"[WULA-WARNING] Container full, dropping item {item.LabelShort} near shuttle");
|
||||
WulaLog.Debug($"[WULA-WARNING] Container full, dropping item {item.LabelShort} near shuttle");
|
||||
// 如果容器满了,丢到穿梭机附近(玩家可以手动重新装载)
|
||||
IntVec3 dropPos = CellFinder.RandomClosewalkCellNear(this.Position, this.Map, 3);
|
||||
if (dropPos.IsValid)
|
||||
{
|
||||
GenPlace.TryPlaceThing(item, dropPos, this.Map, ThingPlaceMode.Near);
|
||||
Messages.Message($"容器已满:{item.LabelShort} 被放置在穿梭机附近", this, MessageTypeDefOf.CautionInput);
|
||||
Log.Message($"[WULA-DEBUG] Dropped item {item.LabelShort} at {dropPos}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Dropped item {item.LabelShort} at {dropPos}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort}");
|
||||
WulaLog.Debug($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Successfully added item {item.LabelShort} to container");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Successfully added item {item.LabelShort} to container");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[WULA-DEBUG] Transfer complete. Container now has {transporter.innerContainer.Count} total items");
|
||||
Log.Message($"[WULA-SUCCESS] Transferred {pawnsToTransfer.Count} pawns and {itemsToTransfer.Count} items from pocket space");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Transfer complete. Container now has {transporter.innerContainer.Count} total items");
|
||||
WulaLog.Debug($"[WULA-SUCCESS] Transferred {pawnsToTransfer.Count} pawns and {itemsToTransfer.Count} items from pocket space");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA-ERROR] Error transferring from pocket map: {ex}");
|
||||
Log.Error($"[WULA-ERROR] Stack trace: {ex.StackTrace}");
|
||||
WulaLog.Debug($"[WULA-ERROR] Error transferring from pocket map: {ex}");
|
||||
WulaLog.Debug($"[WULA-ERROR] Stack trace: {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,19 +927,19 @@ namespace WulaFallenEmpire
|
||||
pocketExit.targetMap = this.Map;
|
||||
pocketExit.targetPos = this.Position;
|
||||
pocketExit.parentShuttle = this;
|
||||
Log.Message($"[WULA] Updated pocket map exit target to shuttle location: {this.Map?.uniqueID} at {this.Position}");
|
||||
WulaLog.Debug($"[WULA] Updated pocket map exit target to shuttle location: {this.Map?.uniqueID} at {this.Position}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 穿梭机不在地图上(可能在飞行中),记录警告但保持原有目标
|
||||
Log.Warning($"[WULA] Shuttle not spawned, pocket map exit target may be outdated. Current target: {pocketExit.targetMap?.uniqueID} at {pocketExit.targetPos}");
|
||||
WulaLog.Debug($"[WULA] Shuttle not spawned, pocket map exit target may be outdated. Current target: {pocketExit.targetMap?.uniqueID} at {pocketExit.targetPos}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error updating exit point target: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error updating exit point target: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -967,13 +967,13 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WULA] Auto-synced pocket items. Current status: {GetPocketSpaceDebugInfo()}");
|
||||
WulaLog.Debug($"[WULA] Auto-synced pocket items. Current status: {GetPocketSpaceDebugInfo()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error during auto-sync: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error during auto-sync: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -983,7 +983,7 @@ namespace WulaFallenEmpire
|
||||
/// </summary>
|
||||
public override void SpawnSetup(Map map, bool respawningAfterLoad)
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] SpawnSetup called: map={map?.uniqueID}, respawning={respawningAfterLoad}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] SpawnSetup called: map={map?.uniqueID}, respawning={respawningAfterLoad}");
|
||||
|
||||
// 保存旧位置信息
|
||||
Map oldMap = this.Map;
|
||||
@@ -997,19 +997,19 @@ namespace WulaFallenEmpire
|
||||
// 验证口袋地图的父级对象是否存在于世界列表中
|
||||
if (pocketMap.Parent is PocketMapParent pocketParent && !Find.World.pocketMaps.Contains(pocketParent))
|
||||
{
|
||||
Log.Warning($"[WULA] Pocket map parent for map ID {pocketMap.uniqueID} was not found in the world list. Re-adding it to prevent data loss.");
|
||||
WulaLog.Debug($"[WULA] Pocket map parent for map ID {pocketMap.uniqueID} was not found in the world list. Re-adding it to prevent data loss.");
|
||||
Find.World.pocketMaps.Add(pocketParent);
|
||||
}
|
||||
|
||||
// 验证口袋地图本身是否存在于游戏地图列表中
|
||||
if (!Find.Maps.Contains(pocketMap))
|
||||
{
|
||||
Log.Warning($"[WULA] Pocket map ID {pocketMap.uniqueID} was not found in the game's map list. Re-registering it.");
|
||||
WulaLog.Debug($"[WULA] Pocket map ID {pocketMap.uniqueID} was not found in the game's map list. Re-registering it.");
|
||||
|
||||
// 在重新添加前,进行安全检查,防止添加已损坏的地图
|
||||
if (!Find.Maps.Contains(pocketMap) && (pocketMap.mapPawns == null || pocketMap.Tile < 0))
|
||||
{
|
||||
Log.Error("[WULA] Cannot re-register a corrupted pocket map. The contents of the pocket space are likely lost. This is a critical error.");
|
||||
WulaLog.Debug("[WULA] Cannot re-register a corrupted pocket map. The contents of the pocket space are likely lost. This is a critical error.");
|
||||
Messages.Message("WULA.PocketSpace.MapInvalidAndRecovering".Translate(), this, MessageTypeDefOf.NegativeEvent);
|
||||
pocketMap = null;
|
||||
pocketMapGenerated = false;
|
||||
@@ -1018,7 +1018,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
// 重新注册地图,使其再次“激活”
|
||||
Current.Game.AddMap(pocketMap);
|
||||
Log.Message($"[WULA] Pocket map {pocketMap.uniqueID} successfully re-registered.");
|
||||
WulaLog.Debug($"[WULA] Pocket map {pocketMap.uniqueID} successfully re-registered.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1030,23 +1030,23 @@ namespace WulaFallenEmpire
|
||||
CompTransporter transporter = this.GetComp<CompTransporter>();
|
||||
if (transporter == null)
|
||||
{
|
||||
Log.Error("[WULA-ERROR] CompTransporter missing in SpawnSetup! This will cause serious issues.");
|
||||
WulaLog.Debug("[WULA-ERROR] CompTransporter missing in SpawnSetup! This will cause serious issues.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] CompTransporter found with {transporter.innerContainer?.Count ?? 0} items");
|
||||
WulaLog.Debug($"[WULA-DEBUG] CompTransporter found with {transporter.innerContainer?.Count ?? 0} items");
|
||||
}
|
||||
|
||||
// 如果是从飞行状态恢复,重新启用传送功能
|
||||
if (transportDisabled)
|
||||
{
|
||||
Log.Message("[WULA-DEBUG] Re-enabling transport functionality after landing");
|
||||
WulaLog.Debug("[WULA-DEBUG] Re-enabling transport functionality after landing");
|
||||
transportDisabled = false;
|
||||
|
||||
// 如果有口袋空间,确保退出点正确连接到新地图
|
||||
if (pocketMapGenerated && pocketMap != null && exit != null)
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Reconnecting pocket space exit to new map: {map?.uniqueID} at {this.Position}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Reconnecting pocket space exit to new map: {map?.uniqueID} at {this.Position}");
|
||||
// 退出点会在 UpdateExitPointTarget 中自动更新
|
||||
}
|
||||
}
|
||||
@@ -1055,25 +1055,25 @@ namespace WulaFallenEmpire
|
||||
if (def.HasModExtension<PocketMapProperties>())
|
||||
{
|
||||
var portalProps = def.GetModExtension<PocketMapProperties>();
|
||||
Log.Message($"[WULA-DEBUG] Loading portal properties from ThingDef");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Loading portal properties from ThingDef");
|
||||
|
||||
if (portalProps.pocketMapGenerator != null)
|
||||
{
|
||||
mapGenerator = portalProps.pocketMapGenerator;
|
||||
Log.Message($"[WULA-DEBUG] Set mapGenerator: {mapGenerator.defName}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Set mapGenerator: {mapGenerator.defName}");
|
||||
}
|
||||
if (portalProps.exitDef != null)
|
||||
{
|
||||
exitDef = portalProps.exitDef;
|
||||
Log.Message($"[WULA-DEBUG] Set exitDef: {exitDef.defName}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Set exitDef: {exitDef.defName}");
|
||||
}
|
||||
if (portalProps.pocketMapSize != IntVec2.Zero)
|
||||
{
|
||||
pocketMapSize = portalProps.pocketMapSize;
|
||||
Log.Message($"[WULA-DEBUG] Set pocketMapSize: {pocketMapSize}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Set pocketMapSize: {pocketMapSize}");
|
||||
}
|
||||
allowDirectAccess = portalProps.allowDirectAccess;
|
||||
Log.Message($"[WULA-DEBUG] Set allowDirectAccess: {allowDirectAccess}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Set allowDirectAccess: {allowDirectAccess}");
|
||||
}
|
||||
|
||||
// 初始化地图生成器和退出点定义(如果 XML 中没有配置)
|
||||
@@ -1082,23 +1082,23 @@ namespace WulaFallenEmpire
|
||||
mapGenerator = DefDatabase<MapGeneratorDef>.GetNamed("AncientStockpile", false)
|
||||
?? DefDatabase<MapGeneratorDef>.GetNamed("Base_Player", false)
|
||||
?? MapGeneratorDefOf.Base_Player;
|
||||
Log.Message($"[WULA-DEBUG] Using fallback mapGenerator: {mapGenerator.defName}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Using fallback mapGenerator: {mapGenerator.defName}");
|
||||
}
|
||||
|
||||
if (exitDef == null)
|
||||
{
|
||||
exitDef = DefDatabase<ThingDef>.GetNamed("WULA_PocketMapExit", false)
|
||||
?? ThingDefOf.Door;
|
||||
Log.Message($"[WULA-DEBUG] Using fallback exitDef: {exitDef.defName}");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Using fallback exitDef: {exitDef.defName}");
|
||||
}
|
||||
|
||||
// 如果位置发生了变化,记录日志
|
||||
if (oldMap != null && (oldMap != map || oldPos != this.Position))
|
||||
{
|
||||
Log.Message($"[WULA-DEBUG] Shuttle moved from {oldMap?.uniqueID}:{oldPos} to {map?.uniqueID}:{this.Position}, updating pocket map exit target");
|
||||
WulaLog.Debug($"[WULA-DEBUG] Shuttle moved from {oldMap?.uniqueID}:{oldPos} to {map?.uniqueID}:{this.Position}, updating pocket map exit target");
|
||||
}
|
||||
|
||||
Log.Message($"[WULA-DEBUG] SpawnSetup completed successfully");
|
||||
WulaLog.Debug($"[WULA-DEBUG] SpawnSetup completed successfully");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -61,7 +61,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
targetMap = parentShuttle.Map;
|
||||
targetPos = parentShuttle.Position;
|
||||
Log.Message($"[WULA] Updated exit target to shuttle location: {targetMap?.uniqueID} at {targetPos}");
|
||||
WulaLog.Debug($"[WULA] Updated exit target to shuttle location: {targetMap?.uniqueID} at {targetPos}");
|
||||
}
|
||||
}
|
||||
else if (parentShuttle != null && !parentShuttle.Spawned)
|
||||
@@ -70,7 +70,7 @@ namespace WulaFallenEmpire
|
||||
// 保持原有目标,但记录警告
|
||||
if (this.IsHashIntervalTick(2500)) // 每隔一段时间检查一次
|
||||
{
|
||||
Log.Warning($"[WULA] Parent shuttle is not spawned, exit target may be outdated. Last known: {targetMap?.uniqueID} at {targetPos}");
|
||||
WulaLog.Debug($"[WULA] Parent shuttle is not spawned, exit target may be outdated. Last known: {targetMap?.uniqueID} at {targetPos}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error exiting pocket space: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error exiting pocket space: {ex}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort} in pocket map.");
|
||||
WulaLog.Debug($"[WULA-ERROR] Could not find valid drop position for item {item.LabelShort} in pocket map.");
|
||||
item.Destroy(); // 实在没地方放,就销毁
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
if (transferableOneWay.things.Contains(t))
|
||||
{
|
||||
Log.Error("Tried to add the same thing twice to TransferableOneWay: " + t);
|
||||
WulaLog.Debug("Tried to add the same thing twice to TransferableOneWay: " + t);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
@@ -21,7 +21,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Message($"[WULA] Generating WULA pocket space, map size: {map.Size}");
|
||||
WulaLog.Debug($"[WULA] Generating WULA pocket space, map size: {map.Size}");
|
||||
|
||||
// 获取地图边界
|
||||
IntVec3 mapSize = map.Size;
|
||||
@@ -32,7 +32,7 @@ namespace WulaFallenEmpire
|
||||
// 生成内部地板
|
||||
GenerateFloor(map);
|
||||
|
||||
Log.Message("[WULA] WULA pocket space generation completed");
|
||||
WulaLog.Debug("[WULA] WULA pocket space generation completed");
|
||||
|
||||
// 添加预制件生成
|
||||
// 如果指定了预制件Def名称,则加载并生成
|
||||
@@ -42,17 +42,17 @@ namespace WulaFallenEmpire
|
||||
if (customPrefabDef != null)
|
||||
{
|
||||
GeneratePrefab(map, customPrefabDef);
|
||||
Log.Message($"[WULA] Generated custom prefab: {customPrefabDef.defName}");
|
||||
WulaLog.Debug($"[WULA] Generated custom prefab: {customPrefabDef.defName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[WULA] Custom prefab '{prefabDefName}' not found. Skipping prefab generation.");
|
||||
WulaLog.Debug($"[WULA] Custom prefab '{prefabDefName}' not found. Skipping prefab generation.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error generating WULA pocket space: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error generating WULA pocket space: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace WulaFallenEmpire
|
||||
Thing wall = ThingMaker.MakeThing(rockWallDef);
|
||||
wall.SetFaction(null);
|
||||
GenPlace.TryPlaceThing(wall, pos, map, ThingPlaceMode.Direct);
|
||||
Log.Warning("[WULA] WulaWall not found, using fallback wall");
|
||||
WulaLog.Debug("[WULA] WulaWall not found, using fallback wall");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (floorDef == null)
|
||||
{
|
||||
Log.Warning("[WULA] WulaFloor not found, using fallback floor");
|
||||
WulaLog.Debug("[WULA] WulaFloor not found, using fallback floor");
|
||||
}
|
||||
|
||||
// 清理内部区域并设置正确的地板
|
||||
@@ -141,7 +141,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[WULA] Set floor for internal area ({mapSize.x-2}x{mapSize.z-2}) to {(floorDef?.defName ?? fallbackFloor?.defName)}");
|
||||
WulaLog.Debug($"[WULA] Set floor for internal area ({mapSize.x-2}x{mapSize.z-2}) to {(floorDef?.defName ?? fallbackFloor?.defName)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -192,7 +192,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Prefs.DevMode) // 只在开发模式下输出详细日志
|
||||
{
|
||||
Log.Message($"[WULA] Removing {thing.def.defName} at {pos} to make space for floor");
|
||||
WulaLog.Debug($"[WULA] Removing {thing.def.defName} at {pos} to make space for floor");
|
||||
}
|
||||
thing.Destroy(DestroyMode.Vanish);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (thing.def.category == ThingCategory.Building && thing.def.Fillage == FillCategory.Full)
|
||||
{
|
||||
Log.Warning($"[WULA] Force removing remaining building {thing.def.defName} at {pos}");
|
||||
WulaLog.Debug($"[WULA] Force removing remaining building {thing.def.defName} at {pos}");
|
||||
thing.Destroy(DestroyMode.Vanish);
|
||||
}
|
||||
}
|
||||
@@ -215,13 +215,13 @@ namespace WulaFallenEmpire
|
||||
map.terrainGrid.SetTerrain(pos, floorDef);
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[WULA] Set terrain at {pos} to {floorDef.defName}");
|
||||
WulaLog.Debug($"[WULA] Set terrain at {pos} to {floorDef.defName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"[WULA] Error clearing cell at {pos}: {ex}");
|
||||
WulaLog.Debug($"[WULA] Error clearing cell at {pos}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (prefabDef == null)
|
||||
{
|
||||
Log.Error("[WULA] PrefabDef is null, cannot generate prefab.");
|
||||
WulaLog.Debug("[WULA] PrefabDef is null, cannot generate prefab.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
// 这里需要递归调用GeneratePrefab,但为了简化,暂时只处理顶层
|
||||
// 实际项目中,可能需要更复杂的逻辑来处理子预制件的位置和旋转
|
||||
Log.Warning($"[WULA] Sub-prefabs are not fully supported in this simple generator: {subPrefabData.data.def.defName}");
|
||||
WulaLog.Debug($"[WULA] Sub-prefabs are not fully supported in this simple generator: {subPrefabData.data.def.defName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace WulaFallenEmpire
|
||||
public void Notify_ThingAdded(Thing t)
|
||||
{
|
||||
// 这里可以添加逻辑来处理物品被添加到口袋空间的情况
|
||||
Log.Message($"[WULA] Item {t.LabelCap} added to pocket space container.");
|
||||
WulaLog.Debug($"[WULA] Item {t.LabelCap} added to pocket space container.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,7 +59,7 @@ namespace WulaFallenEmpire
|
||||
public void Notify_ThingRemoved(Thing t)
|
||||
{
|
||||
// 这里可以添加逻辑来处理物品被从口袋空间移除的情况
|
||||
Log.Message($"[WULA] Item {t.LabelCap} removed from pocket space container.");
|
||||
WulaLog.Debug($"[WULA] Item {t.LabelCap} removed from pocket space container.");
|
||||
}
|
||||
|
||||
public void ExposeData()
|
||||
|
||||
Reference in New Issue
Block a user