✅ 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 RimWorld;
|
||||
using UnityEngine;
|
||||
@@ -30,7 +30,7 @@ namespace WulaFallenEmpire
|
||||
modExtension = def.GetModExtension<ExtraGraphicsExtension>();
|
||||
if (modExtension == null)
|
||||
{
|
||||
Log.Error($"Building_ExtraGraphics: No ExtraGraphicsExtension found for {def.defName}");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: No ExtraGraphicsExtension found for {def.defName}");
|
||||
// 创建默认配置避免空引用
|
||||
modExtension = new ExtraGraphicsExtension();
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
|
||||
case "metaoverlay":
|
||||
return ShaderDatabase.MetaOverlay;
|
||||
default:
|
||||
Log.Warning($"Building_ExtraGraphics: Shader '{shaderName}' not found, using TransparentPostLight as fallback");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: Shader '{shaderName}' not found, using TransparentPostLight as fallback");
|
||||
return ShaderDatabase.TransparentPostLight;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (ModExtension.graphicLayers == null || ModExtension.graphicLayers.Count == 0)
|
||||
{
|
||||
Log.Warning($"Building_ExtraGraphics: No graphic layers configured for {def.defName}");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: No graphic layers configured for {def.defName}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (string.IsNullOrEmpty(layer.texturePath))
|
||||
{
|
||||
Log.Warning($"Building_ExtraGraphics: Empty texture path in layer for {def.defName}");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: Empty texture path in layer for {def.defName}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (mesh == null || mat == null)
|
||||
{
|
||||
Log.Warning($"Building_ExtraGraphics: Unable to get mesh or material for rotating layer");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: Unable to get mesh or material for rotating layer");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"Building_ExtraGraphics: Error drawing rotating layer: {ex}");
|
||||
WulaLog.Debug($"Building_ExtraGraphics: Error drawing rotating layer: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace WulaFallenEmpire
|
||||
if (DebugSettings.godMode && i == 0 && Find.TickManager.TicksGame % 60 == 0)
|
||||
{
|
||||
// 只在开发模式下,每60帧输出一次第一条图层的旋转信息
|
||||
Log.Message($"{layer.animationType} 图层 {i}: 角度={rotationAngle:F1}°, 时间={layerAnimationTimes[i]:F2}s, 速度={rotateSpeed}°/s");
|
||||
WulaLog.Debug($"{layer.animationType} 图层 {i}: 角度={rotationAngle:F1}°, 时间={layerAnimationTimes[i]:F2}s, 速度={rotateSpeed}°/s");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
using UnityEngine;
|
||||
@@ -103,7 +103,7 @@ namespace WulaFallenEmpire
|
||||
map.fogGrid.ClearAllFog();
|
||||
|
||||
// 记录日志以便调试
|
||||
Log.Message($"[MapObserver] 开始监测地图: {mapParent.Label} at tile {target.Tile}");
|
||||
WulaLog.Debug($"[MapObserver] 开始监测地图: {mapParent.Label} at tile {target.Tile}");
|
||||
}
|
||||
}, "GeneratingMap", doAsynchronously: false, null);
|
||||
|
||||
@@ -128,12 +128,12 @@ namespace WulaFallenEmpire
|
||||
if (observedMap is Settlement settlement)
|
||||
{
|
||||
settlement.Name = $"监测点-{thingIDNumber}";
|
||||
Log.Message($"[MapObserver] 创建新监测点: {settlement.Name} at tile {target.Tile}");
|
||||
WulaLog.Debug($"[MapObserver] 创建新监测点: {settlement.Name} at tile {target.Tile}");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果observedMap不是Settlement,使用Label属性
|
||||
Log.Message($"[MapObserver] 创建新监测点: {observedMap.Label} at tile {target.Tile}");
|
||||
WulaLog.Debug($"[MapObserver] 创建新监测点: {observedMap.Label} at tile {target.Tile}");
|
||||
}
|
||||
|
||||
}, "GeneratingMap", doAsynchronously: false, null);
|
||||
@@ -165,7 +165,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
Find.World.worldObjects.Remove(observedMap);
|
||||
}
|
||||
Log.Message($"[MapObserver] 清理空置监测地图: {observedMap.Label}");
|
||||
WulaLog.Debug($"[MapObserver] 清理空置监测地图: {observedMap.Label}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,14 +176,14 @@ namespace WulaFallenEmpire
|
||||
// 断电或被关闭时停止监测
|
||||
if (observedMap != null && (signal == "PowerTurnedOff" || signal == "FlickedOff"))
|
||||
{
|
||||
Log.Message($"[MapObserver] 电力中断,停止监测: {observedMap.Label}");
|
||||
WulaLog.Debug($"[MapObserver] 电力中断,停止监测: {observedMap.Label}");
|
||||
StopObserving();
|
||||
}
|
||||
// 恢复电力时重新注册
|
||||
else if (observedMap != null && (signal == "PowerTurnedOn" || signal == "FlickedOn"))
|
||||
{
|
||||
activeObservers.Add(this);
|
||||
Log.Message($"[MapObserver] 电力恢复,继续监测: {observedMap.Label}");
|
||||
WulaLog.Debug($"[MapObserver] 电力恢复,继续监测: {observedMap.Label}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@ namespace WulaFallenEmpire
|
||||
// 检查是否有攻击动词
|
||||
if (currentEffectiveVerb == null)
|
||||
{
|
||||
Log.Error("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
|
||||
WulaLog.Debug("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace WulaFallenEmpire
|
||||
// 验证攻击动词是否存在
|
||||
if (verb == null)
|
||||
{
|
||||
Log.Error("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
|
||||
WulaLog.Debug("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
@@ -41,14 +41,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
currentState = BuildingBombardmentState.Bursting;
|
||||
nextInnerBurstTick = Find.TickManager.TicksGame;
|
||||
Log.Message($"[BuildingBombardment] Starting burst with {currentTargets.Count} targets");
|
||||
WulaLog.Debug($"[BuildingBombardment] Starting burst with {currentTargets.Count} targets");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有找到目标,等待下一轮
|
||||
currentState = BuildingBombardmentState.Idle;
|
||||
nextBurstTick = Find.TickManager.TicksGame + Props.burstIntervalTicks;
|
||||
Log.Message($"[BuildingBombardment] No targets found, waiting for next burst");
|
||||
WulaLog.Debug($"[BuildingBombardment] No targets found, waiting for next burst");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace WulaFallenEmpire
|
||||
// 当前组发射完毕
|
||||
currentState = BuildingBombardmentState.Idle;
|
||||
nextBurstTick = Find.TickManager.TicksGame + Props.burstIntervalTicks;
|
||||
Log.Message($"[BuildingBombardment] Burst completed, waiting for next burst");
|
||||
WulaLog.Debug($"[BuildingBombardment] Burst completed, waiting for next burst");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace WulaFallenEmpire
|
||||
nextInnerBurstTick = Find.TickManager.TicksGame + Props.innerBurstIntervalTicks;
|
||||
}
|
||||
|
||||
Log.Message($"[BuildingBombardment] Launched bombardment {currentBurstCount}/{currentTargets.Count}");
|
||||
WulaLog.Debug($"[BuildingBombardment] Launched bombardment {currentBurstCount}/{currentTargets.Count}");
|
||||
}
|
||||
|
||||
private void LaunchBombardment(LocalTargetInfo target)
|
||||
@@ -149,7 +149,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[BuildingBombardment] Error launching bombardment: {ex}");
|
||||
WulaLog.Debug($"[BuildingBombardment] Error launching bombardment: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using RimWorld;
|
||||
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
|
||||
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
|
||||
if (facilitiesComp == null)
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
|
||||
WulaLog.Debug($"[BuildingSpawner] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[BuildingSpawner] Exception while checking for FlyOver: {ex}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Exception while checking for FlyOver: {ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +223,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Props.buildingToSpawn == null)
|
||||
{
|
||||
Log.Error("[BuildingSpawner] Building def is null!");
|
||||
WulaLog.Debug("[BuildingSpawner] Building def is null!");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -237,7 +237,7 @@ namespace WulaFallenEmpire
|
||||
// 检查位置是否可用
|
||||
if (!CanSpawnAtPosition(spawnPos))
|
||||
{
|
||||
Log.Error($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (newBuilding == null)
|
||||
{
|
||||
Log.Error("[BuildingSpawner] Failed to create building!");
|
||||
WulaLog.Debug("[BuildingSpawner] Failed to create building!");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[BuildingSpawner] Error in ExecuteAutoBuildingSpawn: {ex}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Error in ExecuteAutoBuildingSpawn: {ex}");
|
||||
ResetCall();
|
||||
}
|
||||
}
|
||||
@@ -348,7 +348,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (Props.buildingToSpawn == null)
|
||||
{
|
||||
Log.Error("[BuildingSpawner] Building def is null!");
|
||||
WulaLog.Debug("[BuildingSpawner] Building def is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace WulaFallenEmpire
|
||||
// 检查位置是否可用
|
||||
if (!CanSpawnAtPosition(spawnPos))
|
||||
{
|
||||
Log.Error($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Cannot spawn building at {spawnPos}");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -384,7 +384,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (newBuilding == null)
|
||||
{
|
||||
Log.Error("[BuildingSpawner] Failed to create building!");
|
||||
WulaLog.Debug("[BuildingSpawner] Failed to create building!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -409,14 +409,14 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (parent?.Map == null)
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Parent map is null for {parent?.LabelShort}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Parent map is null for {parent?.LabelShort}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查是否在地图范围内
|
||||
if (!spawnPos.InBounds(parent.Map))
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Spawn position {spawnPos} is out of bounds for {parent?.LabelShort}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Spawn position {spawnPos} is out of bounds for {parent?.LabelShort}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ namespace WulaFallenEmpire
|
||||
ThingDef buildingDef = Props.buildingToSpawn;
|
||||
if (buildingDef == null)
|
||||
{
|
||||
Log.Error($"[BuildingSpawner] buildingToSpawn is null for {parent?.LabelShort}");
|
||||
WulaLog.Debug($"[BuildingSpawner] buildingToSpawn is null for {parent?.LabelShort}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ namespace WulaFallenEmpire
|
||||
// 检查建筑是否完全在地图范围内
|
||||
if (!rect.InBounds(parent.Map))
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Building rect {rect} for {buildingDef.defName} is out of bounds. Size: {buildingSize}, Position: {spawnPos}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Building rect {rect} for {buildingDef.defName} is out of bounds. Size: {buildingSize}, Position: {spawnPos}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -451,7 +451,7 @@ namespace WulaFallenEmpire
|
||||
if (rect.minX < safeMargin || rect.minZ < safeMargin ||
|
||||
rect.maxX >= pocketMap.Size.x - safeMargin || rect.maxZ >= pocketMap.Size.z - safeMargin)
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Building {buildingDef.defName} too close to pocket map edge. Rect: {rect}, Map Size: {pocketMap.Size}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Building {buildingDef.defName} too close to pocket map edge. Rect: {rect}, Map Size: {pocketMap.Size}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -461,7 +461,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (!cell.InBounds(parent.Map))
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Cell {cell} is out of bounds for building {buildingDef.defName}");
|
||||
WulaLog.Debug($"[BuildingSpawner] Cell {cell} is out of bounds for building {buildingDef.defName}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace WulaFallenEmpire
|
||||
// 跳过自己
|
||||
if (thing != parent)
|
||||
{
|
||||
Log.Warning($"[BuildingSpawner] Cell {cell} is blocked by {thing.def.defName} ({thing.LabelShort})");
|
||||
WulaLog.Debug($"[BuildingSpawner] Cell {cell} is blocked by {thing.def.defName} ({thing.LabelShort})");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using Verse;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace WulaFallenEmpire
|
||||
// 验证buildingToSpawn
|
||||
if (buildingToSpawn != null && buildingToSpawn.category != ThingCategory.Building)
|
||||
{
|
||||
Log.Error($"CompProperties_BuildingSpawner: buildingToSpawn must be a building, but got {buildingToSpawn.defName}");
|
||||
WulaLog.Debug($"CompProperties_BuildingSpawner: buildingToSpawn must be a building, but got {buildingToSpawn.defName}");
|
||||
buildingToSpawn = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
@@ -54,7 +54,7 @@ namespace WulaFallenEmpire
|
||||
ResetState();
|
||||
}
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 炮塔生成在 {parent.Position}, 检测范围: {Props.detectionRange}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 炮塔生成在 {parent.Position}, 检测范围: {Props.detectionRange}");
|
||||
}
|
||||
|
||||
// 在 StartEnergyLance 方法中修复光束创建逻辑
|
||||
@@ -63,7 +63,7 @@ namespace WulaFallenEmpire
|
||||
// 双重检查目标有效性
|
||||
if (currentTarget == null || !IsTargetValid(currentTarget))
|
||||
{
|
||||
Log.Warning($"[EnergyLanceTurret] 尝试启动能量光束但目标无效: {(currentTarget == null ? "目标为null" : "目标无效")}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 尝试启动能量光束但目标无效: {(currentTarget == null ? "目标为null" : "目标无效")}");
|
||||
|
||||
// 尝试重新寻找目标
|
||||
var potentialTargets = FindPotentialTargets();
|
||||
@@ -72,11 +72,11 @@ namespace WulaFallenEmpire
|
||||
currentTarget = potentialTargets
|
||||
.OrderBy(t => t.Position.DistanceTo(parent.Position))
|
||||
.First();
|
||||
Log.Message($"[EnergyLanceTurret] 重新获取目标: {currentTarget.LabelCap}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 重新获取目标: {currentTarget.LabelCap}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 无法重新获取目标,进入冷却");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 无法重新获取目标,进入冷却");
|
||||
StartCooldown();
|
||||
return;
|
||||
}
|
||||
@@ -88,12 +88,12 @@ namespace WulaFallenEmpire
|
||||
var lanceDef = Props.energyLanceDef ?? ThingDef.Named("EnergyLance");
|
||||
if (lanceDef == null)
|
||||
{
|
||||
Log.Error("[EnergyLanceTurret] 能量光束定义为空!");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 能量光束定义为空!");
|
||||
StartCooldown();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 创建能量光束: {lanceDef.defName} 目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 创建能量光束: {lanceDef.defName} 目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
|
||||
// 关键修复:光束直接在目标位置生成,而不是建筑位置
|
||||
activeLance = EnergyLance.MakeEnergyLance(
|
||||
@@ -109,7 +109,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (activeLance == null)
|
||||
{
|
||||
Log.Error("[EnergyLanceTurret] 能量光束创建失败!");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 能量光束创建失败!");
|
||||
StartCooldown();
|
||||
return;
|
||||
}
|
||||
@@ -131,11 +131,11 @@ namespace WulaFallenEmpire
|
||||
// 立即更新光束位置,确保光束在正确位置开始
|
||||
UpdateEnergyLancePosition();
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 能量光束启动成功,追踪目标: {currentTarget.LabelCap}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 能量光束启动成功,追踪目标: {currentTarget.LabelCap}");
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[EnergyLanceTurret] 启动能量光束错误: {ex}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 启动能量光束错误: {ex}");
|
||||
StartCooldown();
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace WulaFallenEmpire
|
||||
// 添加更多调试信息
|
||||
if (debugTickCounter % 30 == 0) // 每0.5秒输出一次位置信息
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 更新光束位置: 目标在 {currentTarget.Position}, 光束在 {activeLance.Position}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 更新光束位置: 目标在 {currentTarget.Position}, 光束在 {activeLance.Position}");
|
||||
}
|
||||
}
|
||||
else if (lastTargetPosition.IsValid && Find.TickManager.TicksGame - lastPositionUpdateTick <= Props.targetUpdateInterval * 2)
|
||||
@@ -209,12 +209,12 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (debugTickCounter % 30 == 0) // 每0.5秒输出一次冷却信息
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 冷却中: {cooldownTicksRemaining} ticks 剩余");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 冷却中: {cooldownTicksRemaining} ticks 剩余");
|
||||
}
|
||||
|
||||
if (cooldownTicksRemaining <= 0)
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 冷却完成,返回待机状态");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 冷却完成,返回待机状态");
|
||||
currentState = TurretState.Idle;
|
||||
isActive = false;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ namespace WulaFallenEmpire
|
||||
// 在预热过程中持续检查目标有效性
|
||||
if (currentTarget == null || !IsTargetValid(currentTarget))
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 预热过程中目标失效,取消预热");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 预热过程中目标失效,取消预热");
|
||||
ResetState();
|
||||
return;
|
||||
}
|
||||
@@ -235,12 +235,12 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (debugTickCounter % 10 == 0) // 每0.17秒输出一次预热信息
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 预热中: {warmupTicksRemaining} ticks 剩余, 目标: {currentTarget?.LabelCap ?? "无"}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 预热中: {warmupTicksRemaining} ticks 剩余, 目标: {currentTarget?.LabelCap ?? "无"}");
|
||||
}
|
||||
|
||||
if (warmupTicksRemaining <= 0)
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 预热完成,开始发射光束");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 预热完成,开始发射光束");
|
||||
StartEnergyLance();
|
||||
}
|
||||
}
|
||||
@@ -280,23 +280,23 @@ namespace WulaFallenEmpire
|
||||
private void OutputDebugInfo()
|
||||
{
|
||||
var targets = FindPotentialTargets();
|
||||
Log.Message($"[EnergyLanceTurret] 调试信息:");
|
||||
Log.Message($" - 状态: {currentState}");
|
||||
Log.Message($" - 当前目标: {currentTarget?.LabelCap ?? "无"}");
|
||||
Log.Message($" - 目标位置: {currentTarget?.Position.ToString() ?? "无"}");
|
||||
Log.Message($" - 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "是" : "否")}");
|
||||
Log.Message($" - 检测到目标数: {targets.Count}");
|
||||
Log.Message($" - 冷却剩余: {cooldownTicksRemaining}");
|
||||
Log.Message($" - 预热剩余: {warmupTicksRemaining}");
|
||||
Log.Message($" - 是否活跃: {isActive}");
|
||||
Log.Message($" - 目标丢失保护: {(targetLostTick >= 0 ? (Find.TickManager.TicksGame - targetLostTick) + " ticks前" : "无")}");
|
||||
Log.Message($" - 光束保护期: {(lanceCreationTick >= 0 ? (Find.TickManager.TicksGame - lanceCreationTick) + " ticks前创建" : "无")}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 调试信息:");
|
||||
WulaLog.Debug($" - 状态: {currentState}");
|
||||
WulaLog.Debug($" - 当前目标: {currentTarget?.LabelCap ?? "无"}");
|
||||
WulaLog.Debug($" - 目标位置: {currentTarget?.Position.ToString() ?? "无"}");
|
||||
WulaLog.Debug($" - 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "是" : "否")}");
|
||||
WulaLog.Debug($" - 检测到目标数: {targets.Count}");
|
||||
WulaLog.Debug($" - 冷却剩余: {cooldownTicksRemaining}");
|
||||
WulaLog.Debug($" - 预热剩余: {warmupTicksRemaining}");
|
||||
WulaLog.Debug($" - 是否活跃: {isActive}");
|
||||
WulaLog.Debug($" - 目标丢失保护: {(targetLostTick >= 0 ? (Find.TickManager.TicksGame - targetLostTick) + " ticks前" : "无")}");
|
||||
WulaLog.Debug($" - 光束保护期: {(lanceCreationTick >= 0 ? (Find.TickManager.TicksGame - lanceCreationTick) + " ticks前创建" : "无")}");
|
||||
|
||||
// 输出前3个检测到的目标
|
||||
for (int i = 0; i < Mathf.Min(3, targets.Count); i++)
|
||||
{
|
||||
var target = targets[i];
|
||||
Log.Message($" - 目标{i+1}: {target.LabelCap} 在 {target.Position}, 距离: {target.Position.DistanceTo(parent.Position):F1}");
|
||||
WulaLog.Debug($" - 目标{i+1}: {target.LabelCap} 在 {target.Position}, 距离: {target.Position.DistanceTo(parent.Position):F1}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace WulaFallenEmpire
|
||||
// 更新目标
|
||||
private void UpdateTarget()
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 更新目标检查 - 状态: {currentState}, 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "是" : "否")}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 更新目标检查 - 状态: {currentState}, 活跃光束: {(activeLance != null && !activeLance.Destroyed ? "是" : "否")}");
|
||||
|
||||
// 如果没有光束,寻找新目标
|
||||
if (activeLance == null || activeLance.Destroyed)
|
||||
@@ -333,7 +333,7 @@ namespace WulaFallenEmpire
|
||||
lastTargetPosition = currentTarget.Position;
|
||||
lastPositionUpdateTick = Find.TickManager.TicksGame;
|
||||
targetLostTick = -1; // 重置目标丢失计时
|
||||
Log.Message($"[EnergyLanceTurret] 目标仍然有效: {currentTarget.LabelCap}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 目标仍然有效: {currentTarget.LabelCap}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -344,11 +344,11 @@ namespace WulaFallenEmpire
|
||||
// 寻找新目标(首次)
|
||||
private void FindNewTarget()
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 寻找新目标...");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 寻找新目标...");
|
||||
|
||||
if (currentState != TurretState.Idle)
|
||||
{
|
||||
Log.Message($"[EnergyLanceTurret] 无法寻找目标 - 当前状态: {currentState}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 无法寻找目标 - 当前状态: {currentState}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -361,14 +361,14 @@ namespace WulaFallenEmpire
|
||||
.OrderBy(t => t.Position.DistanceTo(parent.Position))
|
||||
.First();
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 发现新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 发现新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
|
||||
// 开始预热
|
||||
StartWarmup();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 没有发现有效目标");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 没有发现有效目标");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace WulaFallenEmpire
|
||||
if (activeLance == null || activeLance.Destroyed)
|
||||
return;
|
||||
|
||||
Log.Message("[EnergyLanceTurret] 为现有光束寻找新目标...");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 为现有光束寻找新目标...");
|
||||
|
||||
var potentialTargets = FindPotentialTargets();
|
||||
|
||||
@@ -393,7 +393,7 @@ namespace WulaFallenEmpire
|
||||
lastPositionUpdateTick = Find.TickManager.TicksGame;
|
||||
targetLostTick = -1; // 重置目标丢失计时
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 切换到新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 切换到新目标: {currentTarget.LabelCap} 在 {currentTarget.Position}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -401,12 +401,12 @@ namespace WulaFallenEmpire
|
||||
if (targetLostTick < 0)
|
||||
{
|
||||
targetLostTick = Find.TickManager.TicksGame;
|
||||
Log.Message($"[EnergyLanceTurret] 目标丢失,开始保护期: {TARGET_LOST_GRACE_PERIOD} ticks");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 目标丢失,开始保护期: {TARGET_LOST_GRACE_PERIOD} ticks");
|
||||
}
|
||||
|
||||
currentTarget = null;
|
||||
lastTargetPosition = IntVec3.Invalid;
|
||||
Log.Message("[EnergyLanceTurret] 没有有效目标,发送空位置");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 没有有效目标,发送空位置");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
if (currentTarget == null)
|
||||
{
|
||||
Log.Warning("[EnergyLanceTurret] 尝试开始预热但没有目标");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 尝试开始预热但没有目标");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace WulaFallenEmpire
|
||||
isActive = true;
|
||||
currentState = TurretState.WarmingUp;
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 开始预热: {warmupTicksRemaining} ticks, 目标: {currentTarget.LabelCap}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 开始预热: {warmupTicksRemaining} ticks, 目标: {currentTarget.LabelCap}");
|
||||
}
|
||||
|
||||
// 更新光束目标位置
|
||||
@@ -519,7 +519,7 @@ namespace WulaFallenEmpire
|
||||
if (activeLance is EnergyLance energyLance)
|
||||
{
|
||||
energyLance.UpdateTargetPosition(targetPos);
|
||||
Log.Message($"[EnergyLanceTurret] 更新光束目标: {targetPos}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 更新光束目标: {targetPos}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -528,11 +528,11 @@ namespace WulaFallenEmpire
|
||||
if (moveMethod != null)
|
||||
{
|
||||
moveMethod.Invoke(activeLance, new object[] { targetPos });
|
||||
Log.Message($"[EnergyLanceTurret] 通过反射更新光束目标: {targetPos}");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 通过反射更新光束目标: {targetPos}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning("[EnergyLanceTurret] 无法更新光束目标位置");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 无法更新光束目标位置");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +543,7 @@ namespace WulaFallenEmpire
|
||||
if (activeLance == null || activeLance.Destroyed)
|
||||
{
|
||||
// 光束已销毁,进入冷却
|
||||
Log.Message("[EnergyLanceTurret] 光束已销毁,开始冷却");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 光束已销毁,开始冷却");
|
||||
StartCooldown();
|
||||
return;
|
||||
}
|
||||
@@ -558,7 +558,7 @@ namespace WulaFallenEmpire
|
||||
// 检查目标丢失保护期
|
||||
if (targetLostTick >= 0 && Find.TickManager.TicksGame - targetLostTick > TARGET_LOST_GRACE_PERIOD)
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 目标丢失保护期结束,销毁光束");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 目标丢失保护期结束,销毁光束");
|
||||
activeLance.Destroy();
|
||||
StartCooldown();
|
||||
return;
|
||||
@@ -567,7 +567,7 @@ namespace WulaFallenEmpire
|
||||
// 检查光束是否长时间没有收到位置更新
|
||||
if (Find.TickManager.TicksGame - lastPositionUpdateTick > Props.targetUpdateInterval * 3)
|
||||
{
|
||||
Log.Message("[EnergyLanceTurret] 光束长时间未收到位置更新,销毁");
|
||||
WulaLog.Debug("[EnergyLanceTurret] 光束长时间未收到位置更新,销毁");
|
||||
activeLance.Destroy();
|
||||
StartCooldown();
|
||||
}
|
||||
@@ -584,7 +584,7 @@ namespace WulaFallenEmpire
|
||||
targetLostTick = -1;
|
||||
currentState = TurretState.CoolingDown;
|
||||
|
||||
Log.Message($"[EnergyLanceTurret] 开始冷却: {cooldownTicksRemaining} ticks");
|
||||
WulaLog.Debug($"[EnergyLanceTurret] 开始冷却: {cooldownTicksRemaining} ticks");
|
||||
}
|
||||
|
||||
// 绘制检测范围
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
@@ -49,7 +49,7 @@ namespace WulaFallenEmpire
|
||||
if (faction != null && faction != parent.Faction)
|
||||
{
|
||||
parent.SetFaction(faction);
|
||||
Log.Message($"Set faction for {parent.Label} to {faction.Name}");
|
||||
WulaLog.Debug($"Set faction for {parent.Label} to {faction.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using System.Collections.Generic;
|
||||
@@ -45,14 +45,14 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[CompAutonomousMech] {pawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
|
||||
WulaLog.Debug($"[CompAutonomousMech] {pawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[CompAutonomousMech] Error switching weapon for {pawn?.LabelCap}: {ex}");
|
||||
WulaLog.Debug($"[CompAutonomousMech] Error switching weapon for {pawn?.LabelCap}: {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
@@ -86,7 +86,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"PhaseCombatTower: 找不到PawnKindDef '{pawnKindName}'");
|
||||
WulaLog.Debug($"PhaseCombatTower: 找不到PawnKindDef '{pawnKindName}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Verse;
|
||||
@@ -37,7 +37,7 @@ namespace WulaFallenEmpire
|
||||
var prefab = DefDatabase<PrefabDef>.GetNamed(PropsPrefab.prefabDefName, false);
|
||||
if (prefab == null)
|
||||
{
|
||||
Log.Error($"[PrefabSkyfallerCaller] Could not find PrefabDef named {PropsPrefab.prefabDefName}");
|
||||
WulaLog.Debug($"[PrefabSkyfallerCaller] Could not find PrefabDef named {PropsPrefab.prefabDefName}");
|
||||
return new List<ThingDefCountClass>(); // Return empty list to avoid null reference
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace WulaFallenEmpire
|
||||
// Final material check before launching
|
||||
if (!HasEnoughMaterials())
|
||||
{
|
||||
Log.Warning($"[PrefabSkyfallerCaller] Aborting skyfaller call due to insufficient materials at the last moment.");
|
||||
WulaLog.Debug($"[PrefabSkyfallerCaller] Aborting skyfaller call due to insufficient materials at the last moment.");
|
||||
ResetCall(); // Reset the calling state
|
||||
return;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"[PrefabSkyfallerCaller] Failed to create Skyfaller_PrefabSpawner. Created thing is of type {thing.GetType().FullName}. Def: {Props.skyfallerDef.defName}, ThingClass: {Props.skyfallerDef.thingClass.FullName}");
|
||||
WulaLog.Debug($"[PrefabSkyfallerCaller] Failed to create Skyfaller_PrefabSpawner. Created thing is of type {thing.GetType().FullName}. Def: {Props.skyfallerDef.defName}, ThingClass: {Props.skyfallerDef.thingClass.FullName}");
|
||||
// Fallback: spawn as normal skyfaller if possible, or just abort
|
||||
if (thing is Skyfaller normalSkyfaller)
|
||||
{
|
||||
@@ -138,7 +138,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (roof != null && !roof.isThickRoof && Props.allowThinRoof)
|
||||
{
|
||||
Log.Message($"[PrefabSkyfallerCaller] Destroying thin roof at {targetPos}");
|
||||
WulaLog.Debug($"[PrefabSkyfallerCaller] Destroying thin roof at {targetPos}");
|
||||
parent.Map.roofGrid.SetRoof(targetPos, null);
|
||||
|
||||
// 生成屋顶破坏效果
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
using RimWorld.Planet;
|
||||
@@ -79,7 +79,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[SkyfallerCaller] Found {allFlyOvers.Count} FlyOvers on map");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Found {allFlyOvers.Count} FlyOvers on map");
|
||||
|
||||
foreach (var thing in allFlyOvers)
|
||||
{
|
||||
@@ -89,28 +89,28 @@ namespace WulaFallenEmpire
|
||||
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
|
||||
if (facilitiesComp == null)
|
||||
{
|
||||
Log.Warning($"[SkyfallerCaller] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
|
||||
WulaLog.Debug($"[SkyfallerCaller] FlyOver at {flyOver.Position} has no CompFlyOverFacilities");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (facilitiesComp.HasFacility("BuildingdropperFacility"))
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Found valid FlyOver at {flyOver.Position} with BuildingdropperFacility");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Found valid FlyOver at {flyOver.Position} with BuildingdropperFacility");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] FlyOver at {flyOver.Position} missing BuildingdropperFacility. Has: {string.Join(", ", facilitiesComp.GetActiveFacilities())}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] FlyOver at {flyOver.Position} missing BuildingdropperFacility. Has: {string.Join(", ", facilitiesComp.GetActiveFacilities())}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message("[SkyfallerCaller] No FlyOver with BuildingdropperFacility found");
|
||||
WulaLog.Debug("[SkyfallerCaller] No FlyOver with BuildingdropperFacility found");
|
||||
return false;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[SkyfallerCaller] Exception while checking for FlyOver: {ex}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Exception while checking for FlyOver: {ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace WulaFallenEmpire
|
||||
callTick = Find.TickManager.TicksGame + Props.autoCallDelayTicks;
|
||||
calling = true;
|
||||
|
||||
Log.Message($"[SkyfallerCaller] Scheduled auto-call for non-player building {parent.Label} at tick {callTick}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Scheduled auto-call for non-player building {parent.Label} at tick {callTick}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,11 +185,11 @@ namespace WulaFallenEmpire
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Executing auto skyfaller call for non-player building at {parent.Position}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Executing auto skyfaller call for non-player building at {parent.Position}");
|
||||
|
||||
if (Props.skyfallerDef == null)
|
||||
{
|
||||
Log.Error("[SkyfallerCaller] Skyfaller def is null!");
|
||||
WulaLog.Debug("[SkyfallerCaller] Skyfaller def is null!");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -202,19 +202,19 @@ namespace WulaFallenEmpire
|
||||
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerDef);
|
||||
if (skyfaller == null)
|
||||
{
|
||||
Log.Error("[SkyfallerCaller] Failed to create skyfaller!");
|
||||
WulaLog.Debug("[SkyfallerCaller] Failed to create skyfaller!");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
|
||||
IntVec3 spawnPos = parent.Position;
|
||||
Log.Message($"[SkyfallerCaller] Spawning auto skyfaller at {spawnPos}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Spawning auto skyfaller at {spawnPos}");
|
||||
|
||||
GenSpawn.Spawn(skyfaller, spawnPos, parent.Map);
|
||||
|
||||
if (Props.destroyBuilding)
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Destroying non-player building {parent.Label}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Destroying non-player building {parent.Label}");
|
||||
parent.Destroy(DestroyMode.Vanish);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[SkyfallerCaller] Error in ExecuteAutoSkyfallerCall: {ex}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Error in ExecuteAutoSkyfallerCall: {ex}");
|
||||
ResetCall();
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,7 @@ namespace WulaFallenEmpire
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Message($"[SkyfallerCaller] Starting skyfaller call from {parent.Label} at {parent.Position}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Starting skyfaller call from {parent.Label} at {parent.Position}");
|
||||
|
||||
calling = true;
|
||||
used = true;
|
||||
@@ -295,11 +295,11 @@ namespace WulaFallenEmpire
|
||||
|
||||
protected virtual void ExecuteSkyfallerCall()
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Executing skyfaller call at {parent.Position}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Executing skyfaller call at {parent.Position}");
|
||||
|
||||
if (Props.skyfallerDef == null)
|
||||
{
|
||||
Log.Error("[SkyfallerCaller] Skyfaller def is null!");
|
||||
WulaLog.Debug("[SkyfallerCaller] Skyfaller def is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace WulaFallenEmpire
|
||||
var resourceCheck = CheckAndConsumeMaterials();
|
||||
if (!resourceCheck.HasEnoughMaterials)
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Aborting skyfaller call due to insufficient materials.");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Aborting skyfaller call due to insufficient materials.");
|
||||
ResetCall();
|
||||
return;
|
||||
}
|
||||
@@ -322,18 +322,18 @@ namespace WulaFallenEmpire
|
||||
Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(Props.skyfallerDef);
|
||||
if (skyfaller == null)
|
||||
{
|
||||
Log.Error("[SkyfallerCaller] Failed to create skyfaller!");
|
||||
WulaLog.Debug("[SkyfallerCaller] Failed to create skyfaller!");
|
||||
return;
|
||||
}
|
||||
|
||||
IntVec3 spawnPos = parent.Position;
|
||||
Log.Message($"[SkyfallerCaller] Spawning skyfaller at {spawnPos}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Spawning skyfaller at {spawnPos}");
|
||||
|
||||
GenSpawn.Spawn(skyfaller, spawnPos, parent.Map);
|
||||
|
||||
if (Props.destroyBuilding)
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Destroying building {parent.Label}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Destroying building {parent.Label}");
|
||||
parent.Destroy(DestroyMode.Vanish);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (roof != null && !roof.isThickRoof && Props.allowThinRoof)
|
||||
{
|
||||
Log.Message($"[SkyfallerCaller] Destroying thin roof at {targetPos}");
|
||||
WulaLog.Debug($"[SkyfallerCaller] Destroying thin roof at {targetPos}");
|
||||
parent.Map.roofGrid.SetRoof(targetPos, null);
|
||||
|
||||
// 生成屋顶破坏效果
|
||||
@@ -670,7 +670,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
// 在非 God Mode 下,这个方法不应该被调用
|
||||
// 实际的消耗在 CheckAndConsumeMaterials 中处理
|
||||
Log.Warning("[SkyfallerCaller] ConsumeMaterials called in non-God mode, this shouldn't happen");
|
||||
WulaLog.Debug("[SkyfallerCaller] ConsumeMaterials called in non-God mode, this shouldn't happen");
|
||||
}
|
||||
|
||||
// 其余方法保持不变...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
@@ -18,7 +18,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!eligibleDefs.Any())
|
||||
{
|
||||
Log.Warning("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
|
||||
WulaLog.Debug("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (!eligibleDefs.Any())
|
||||
{
|
||||
Log.Warning("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
|
||||
WulaLog.Debug("[Debug] No ThingDefs found with CompProperties_PrefabSkyfallerCaller");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace WulaFallenEmpire
|
||||
var currentMap = Find.CurrentMap;
|
||||
if (currentMap == null)
|
||||
{
|
||||
Log.Warning("[Debug] No current map found");
|
||||
WulaLog.Debug("[Debug] No current map found");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,11 +97,11 @@ namespace WulaFallenEmpire
|
||||
var compProps = thingDef.comps.OfType<CompProperties_PrefabSkyfallerCaller>().FirstOrDefault();
|
||||
if (compProps == null)
|
||||
{
|
||||
Log.Warning($"[Debug] Could not find CompProperties_PrefabSkyfallerCaller for {thingDef.defName}");
|
||||
WulaLog.Debug($"[Debug] Could not find CompProperties_PrefabSkyfallerCaller for {thingDef.defName}");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Message($"[Debug] Looking for spawn positions for {thingDef.defName} (Size: {thingDef.Size})");
|
||||
WulaLog.Debug($"[Debug] Looking for spawn positions for {thingDef.defName} (Size: {thingDef.Size})");
|
||||
|
||||
for (int i = 0; i < spawnCount && attempts < maxAttempts; i++)
|
||||
{
|
||||
@@ -120,11 +120,11 @@ namespace WulaFallenEmpire
|
||||
GenSpawn.Spawn(thing, spawnPos, currentMap);
|
||||
|
||||
successCount++;
|
||||
Log.Message($"[Debug] Successfully spawned {thingDef.defName} at {spawnPos} for faction {faction?.Name ?? "None"}");
|
||||
WulaLog.Debug($"[Debug] Successfully spawned {thingDef.defName} at {spawnPos} for faction {faction?.Name ?? "None"}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"[Debug] Failed to find valid spawn position for {thingDef.defName} (attempt {attempts})");
|
||||
WulaLog.Debug($"[Debug] Failed to find valid spawn position for {thingDef.defName} (attempt {attempts})");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace WulaFallenEmpire
|
||||
var potentialCells = new List<IntVec3>();
|
||||
|
||||
// 策略1:首先尝试玩家基地附近的开放区域
|
||||
Log.Message($"[Debug] Searching near base area...");
|
||||
WulaLog.Debug($"[Debug] Searching near base area...");
|
||||
var baseCells = GetOpenAreaCellsNearBase(map, thingDef.Size);
|
||||
foreach (var cell in baseCells)
|
||||
{
|
||||
@@ -157,12 +157,12 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (potentialCells.Count > 0)
|
||||
{
|
||||
Log.Message($"[Debug] Found {potentialCells.Count} positions near base");
|
||||
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions near base");
|
||||
return potentialCells.RandomElement();
|
||||
}
|
||||
|
||||
// 策略2:搜索整个地图的开阔区域
|
||||
Log.Message($"[Debug] Searching open areas...");
|
||||
WulaLog.Debug($"[Debug] Searching open areas...");
|
||||
var openAreas = FindOpenAreas(map, thingDef.Size, 1000);
|
||||
foreach (var cell in openAreas)
|
||||
{
|
||||
@@ -175,12 +175,12 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (potentialCells.Count > 0)
|
||||
{
|
||||
Log.Message($"[Debug] Found {potentialCells.Count} positions in open areas");
|
||||
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions in open areas");
|
||||
return potentialCells.RandomElement();
|
||||
}
|
||||
|
||||
// 策略3:使用随机采样
|
||||
Log.Message($"[Debug] Trying random sampling...");
|
||||
WulaLog.Debug($"[Debug] Trying random sampling...");
|
||||
for (int i = 0; i < 500; i++)
|
||||
{
|
||||
IntVec3 randomCell = new IntVec3(
|
||||
@@ -198,11 +198,11 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (potentialCells.Count > 0)
|
||||
{
|
||||
Log.Message($"[Debug] Found {potentialCells.Count} positions via random sampling");
|
||||
WulaLog.Debug($"[Debug] Found {potentialCells.Count} positions via random sampling");
|
||||
return potentialCells.RandomElement();
|
||||
}
|
||||
|
||||
Log.Warning($"[Debug] No valid positions found for {thingDef.defName}");
|
||||
WulaLog.Debug($"[Debug] No valid positions found for {thingDef.defName}");
|
||||
return IntVec3.Invalid;
|
||||
}
|
||||
|
||||
@@ -415,12 +415,12 @@ namespace WulaFallenEmpire
|
||||
}
|
||||
}
|
||||
|
||||
Log.Message($"[Debug] Force cleared {clearedCount} objects for skyfaller drop");
|
||||
WulaLog.Debug($"[Debug] Force cleared {clearedCount} objects for skyfaller drop");
|
||||
return clearedCount > 0;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.Error($"[Debug] Error force clearing area: {ex}");
|
||||
WulaLog.Debug($"[Debug] Error force clearing area: {ex}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
@@ -13,14 +13,14 @@ namespace WulaFallenEmpire
|
||||
// Don't spawn the innerThing, we are spawning a prefab instead.
|
||||
if (string.IsNullOrEmpty(prefabDefName))
|
||||
{
|
||||
Log.Error("[Skyfaller_PrefabSpawner] prefabDefName is null or empty. Cannot spawn prefab.");
|
||||
WulaLog.Debug("[Skyfaller_PrefabSpawner] prefabDefName is null or empty. Cannot spawn prefab.");
|
||||
return;
|
||||
}
|
||||
|
||||
PrefabDef prefabDef = DefDatabase<PrefabDef>.GetNamed(prefabDefName, false);
|
||||
if (prefabDef == null)
|
||||
{
|
||||
Log.Error($"[Skyfaller_PrefabSpawner] Could not find PrefabDef named {prefabDefName}.");
|
||||
WulaLog.Debug($"[Skyfaller_PrefabSpawner] Could not find PrefabDef named {prefabDefName}.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -372,7 +372,7 @@ namespace WulaFallenEmpire
|
||||
// 确保 parent 不为 null
|
||||
if (_parent == null || _parent.parent == null)
|
||||
{
|
||||
Log.Warning("[StorageTurret] Parent is null when updating gun verbs");
|
||||
WulaLog.Debug("[StorageTurret] Parent is null when updating gun verbs");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RimWorld;
|
||||
@@ -157,7 +157,7 @@ namespace WulaFallenEmpire
|
||||
warmupTicksLeft--;
|
||||
if (warmupTicksLeft % 60 == 0)
|
||||
{
|
||||
Log.Message($"[WULA] Teleport warmup: {warmupTicksLeft} ticks left.");
|
||||
WulaLog.Debug($"[WULA] Teleport warmup: {warmupTicksLeft} ticks left.");
|
||||
foreach (var member in GroupMembers)
|
||||
{
|
||||
Props.warmupEffecter?.Spawn(member.parent, member.parent.Map).Cleanup();
|
||||
@@ -166,7 +166,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (warmupTicksLeft <= 0)
|
||||
{
|
||||
Log.Message("[WULA] Warmup finished. Attempting teleport...");
|
||||
WulaLog.Debug("[WULA] Warmup finished. Attempting teleport...");
|
||||
TryTeleport();
|
||||
isWarmingUp = false;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
private void TryTeleport()
|
||||
{
|
||||
Log.Message($"[WULA] TryTeleport called. Target valid: {target.IsValid}, Tile: {target.Tile}, Cell: {target.Cell}");
|
||||
WulaLog.Debug($"[WULA] TryTeleport called. Target valid: {target.IsValid}, Tile: {target.Tile}, Cell: {target.Cell}");
|
||||
|
||||
if (!target.IsValid)
|
||||
{
|
||||
@@ -349,7 +349,7 @@ namespace WulaFallenEmpire
|
||||
|
||||
if (targetMap == null)
|
||||
{
|
||||
Log.Message($"[WULA] Target map is null. Generating map for tile {target.Tile}...");
|
||||
WulaLog.Debug($"[WULA] Target map is null. Generating map for tile {target.Tile}...");
|
||||
targetMap = GetOrGenerateTargetMap(target.Tile);
|
||||
if (targetMap == null)
|
||||
{
|
||||
@@ -360,7 +360,7 @@ namespace WulaFallenEmpire
|
||||
targetCell = targetMap.Center;
|
||||
}
|
||||
|
||||
Log.Message($"[WULA] Teleporting to map {targetMap.Index}, cell {targetCell}");
|
||||
WulaLog.Debug($"[WULA] Teleporting to map {targetMap.Index}, cell {targetCell}");
|
||||
TeleportContents(targetMap, targetCell);
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ namespace WulaFallenEmpire
|
||||
List<ThingToTeleport> thingsToTeleport = new List<ThingToTeleport>();
|
||||
List<Pair<IntVec3, TerrainDef>> terrainToTeleport = new List<Pair<IntVec3, TerrainDef>>();
|
||||
|
||||
Log.Message($"[WULA] Collecting data from {cells.Count} cells in group");
|
||||
WulaLog.Debug($"[WULA] Collecting data from {cells.Count} cells in group");
|
||||
|
||||
// 1. 收集数据
|
||||
HashSet<Thing> collectedThings = new HashSet<Thing>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -164,7 +164,7 @@ namespace WulaFallenEmpire
|
||||
// 播放转换效果
|
||||
PlayTransformEffects(position, map);
|
||||
|
||||
Log.Message($"[TransformSystem] Building -> Pawn transformation completed at {position}. Path grid updated.");
|
||||
WulaLog.Debug($"[TransformSystem] Building -> Pawn transformation completed at {position}. Path grid updated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using RimWorld;
|
||||
using RimWorld;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
@@ -288,7 +288,7 @@ namespace WulaFallenEmpire
|
||||
lastValidationResult = null;
|
||||
lastValidationReason = null;
|
||||
|
||||
Log.Message($"[TransformSystem] Pawn -> Building transformation completed at {desiredPosition}. Path grid updated.");
|
||||
WulaLog.Debug($"[TransformSystem] Pawn -> Building transformation completed at {desiredPosition}. Path grid updated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user