创建了 ArachnaeSwarmSettings.cs - 包含 enableDebugLogs 字段

 创建了 ArachnaeLog.cs - 中央化日志类,仅检查mod设置(不检查DevMode)
 创建了 ArachnaeSwarmMod.cs - Mod主类,提供UI设置选项
 修改了 MainHarmony.cs - 移除重复的Harmony初始化(现在由ArachnaeSwarmMod处理)
 修改了 .csproj - 添加了3个新文件到编译列表
 替换了所有582个 Log.Message/Error/Warning 调用为 ArachnaeLog.Debug()
This commit is contained in:
2025-12-15 13:11:45 +08:00
parent 8e5cbb1b15
commit 675ac8b298
77 changed files with 731 additions and 673 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -133,7 +133,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error transferring gene {geneDef.defName}: {ex}"); ArachnaeLog.Debug($"Error transferring gene {geneDef.defName}: {ex}");
} }
} }
} }
@@ -152,7 +152,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"Gene injection: {caster.Label} transferred {transferredGenes.Count} genes to {target.Label}"); ArachnaeLog.Debug($"Gene injection: {caster.Label} transferred {transferredGenes.Count} genes to {target.Label}");
} }
} }
else else

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using RimWorld.Planet; using RimWorld.Planet;
using Verse; using Verse;
using UnityEngine; using UnityEngine;
@@ -44,12 +44,12 @@ namespace ArachnaeSwarm
// 新增:检查目标是否无法行动(倒地) // 新增:检查目标是否无法行动(倒地)
if (target.Pawn != null && IsTargetImmobilized(target.Pawn)) if (target.Pawn != null && IsTargetImmobilized(target.Pawn))
{ {
Log.Message($"[夺舍] 目标 {target.Pawn.LabelShort} 无法行动,直接执行夺舍"); ArachnaeLog.Debug($"[夺舍] 目标 {target.Pawn.LabelShort} 无法行动,直接执行夺舍");
DoPossession(this.parent.pawn, target.Pawn); DoPossession(this.parent.pawn, target.Pawn);
} }
else else
{ {
Log.Message($"[夺舍] 目标可以行动,执行标准夺舍流程"); ArachnaeLog.Debug($"[夺舍] 目标可以行动,执行标准夺舍流程");
DoPossession(this.parent.pawn, target.Pawn); DoPossession(this.parent.pawn, target.Pawn);
} }
} }
@@ -62,14 +62,14 @@ namespace ArachnaeSwarm
// 检查是否倒地 // 检查是否倒地
if (target.Downed) if (target.Downed)
{ {
Log.Message($"[夺舍] 目标 {target.LabelShort} 处于倒地状态"); ArachnaeLog.Debug($"[夺舍] 目标 {target.LabelShort} 处于倒地状态");
return true; return true;
} }
// 检查是否无法移动 // 检查是否无法移动
if (!target.health.capacities.CapableOf(PawnCapacityDefOf.Moving)) if (!target.health.capacities.CapableOf(PawnCapacityDefOf.Moving))
{ {
Log.Message($"[夺舍] 目标 {target.LabelShort} 无法移动"); ArachnaeLog.Debug($"[夺舍] 目标 {target.LabelShort} 无法移动");
return true; return true;
} }
@@ -78,14 +78,14 @@ namespace ArachnaeSwarm
target.health.hediffSet.HasHediff(HediffDefOf.CryptosleepSickness) || target.health.hediffSet.HasHediff(HediffDefOf.CryptosleepSickness) ||
target.health.hediffSet.HasHediff(HediffDefOf.FoodPoisoning)) target.health.hediffSet.HasHediff(HediffDefOf.FoodPoisoning))
{ {
Log.Message($"[夺舍] 目标 {target.LabelShort} 有严重的移动障碍"); ArachnaeLog.Debug($"[夺舍] 目标 {target.LabelShort} 有严重的移动障碍");
return true; return true;
} }
// 检查是否被束缚或囚禁 // 检查是否被束缚或囚禁
if (target.IsPrisoner || target.HostFaction != null) if (target.IsPrisoner || target.HostFaction != null)
{ {
Log.Message($"[夺舍] 目标 {target.LabelShort} 被囚禁或束缚"); ArachnaeLog.Debug($"[夺舍] 目标 {target.LabelShort} 被囚禁或束缚");
return true; return true;
} }
@@ -98,7 +98,7 @@ namespace ArachnaeSwarm
// 如果目标无法行动100%成功率 // 如果目标无法行动100%成功率
if (IsTargetImmobilized(targetPawn)) if (IsTargetImmobilized(targetPawn))
{ {
Log.Message($"[夺舍] 目标 {targetPawn.LabelShort} 无法行动,寄生成功率: 100%"); ArachnaeLog.Debug($"[夺舍] 目标 {targetPawn.LabelShort} 无法行动,寄生成功率: 100%");
return 1f; return 1f;
} }
@@ -107,7 +107,7 @@ namespace ArachnaeSwarm
float bonusFromDamage = damageDealt * Props.successChanceBonusPerDamage; float bonusFromDamage = damageDealt * Props.successChanceBonusPerDamage;
float finalChance = Mathf.Clamp01(baseChance + bonusFromDamage); float finalChance = Mathf.Clamp01(baseChance + bonusFromDamage);
Log.Message($"[夺舍] 目标 {targetPawn.LabelShort} 可以行动,寄生成功率: {finalChance:P0} (基础: {baseChance:P0}, 伤害加成: {bonusFromDamage:P0})"); ArachnaeLog.Debug($"[夺舍] 目标 {targetPawn.LabelShort} 可以行动,寄生成功率: {finalChance:P0} (基础: {baseChance:P0}, 伤害加成: {bonusFromDamage:P0})");
return finalChance; return finalChance;
} }
@@ -115,12 +115,12 @@ namespace ArachnaeSwarm
{ {
if (targetPawn == null || caster == null) return; if (targetPawn == null || caster == null) return;
Log.Message($"[夺舍] 开始执行。施法者: {caster.LabelShort}, 目标: {targetPawn.LabelShort}"); ArachnaeLog.Debug($"[夺舍] 开始执行。施法者: {caster.LabelShort}, 目标: {targetPawn.LabelShort}");
// 1. 捕获原宿主的完整数据,用于死亡后恢复尸体 // 1. 捕获原宿主的完整数据,用于死亡后恢复尸体
OriginalPawnData originalHostData = new OriginalPawnData(); OriginalPawnData originalHostData = new OriginalPawnData();
originalHostData.CaptureData(targetPawn); originalHostData.CaptureData(targetPawn);
Log.Message($"[夺舍] 已捕获原始宿主 {targetPawn.LabelShort} 的完整数据。"); ArachnaeLog.Debug($"[夺舍] 已捕获原始宿主 {targetPawn.LabelShort} 的完整数据。");
// 2. 备份原宿主的技能,用于后续合并 // 2. 备份原宿主的技能,用于后续合并
var originalTargetSkills = new Dictionary<SkillDef, (int level, Passion passion)>(); var originalTargetSkills = new Dictionary<SkillDef, (int level, Passion passion)>();
@@ -141,7 +141,7 @@ namespace ArachnaeSwarm
// 4. 将抱脸虫存入Hediff // 4. 将抱脸虫存入Hediff
if (hediff.casterContainer.TryAdd(originalCaster, true)) if (hediff.casterContainer.TryAdd(originalCaster, true))
{ {
Log.Message($"[夺舍] 成功将 {caster.LabelShort} 的原始副本存入Hediff。"); ArachnaeLog.Debug($"[夺舍] 成功将 {caster.LabelShort} 的原始副本存入Hediff。");
// 5. 灵魂转移,此时 targetPawn 的技能被 caster 的技能覆盖 // 5. 灵魂转移,此时 targetPawn 的技能被 caster 的技能覆盖
PawnDataUtility.TransferSoul(caster, targetPawn); PawnDataUtility.TransferSoul(caster, targetPawn);
@@ -155,7 +155,7 @@ namespace ArachnaeSwarm
// 6. 技能合并:在灵魂转移后,直接在最终的身体 (targetPawn) 上进行合并 // 6. 技能合并:在灵魂转移后,直接在最终的身体 (targetPawn) 上进行合并
if (targetPawn.skills != null) if (targetPawn.skills != null)
{ {
Log.Message("[夺舍] 开始合并技能..."); ArachnaeLog.Debug("[夺舍] 开始合并技能...");
foreach (var skillRecord in targetPawn.skills.skills) foreach (var skillRecord in targetPawn.skills.skills)
{ {
if (originalTargetSkills.TryGetValue(skillRecord.def, out var originalSkill)) if (originalTargetSkills.TryGetValue(skillRecord.def, out var originalSkill))
@@ -172,7 +172,7 @@ namespace ArachnaeSwarm
} }
} }
} }
Log.Message("[夺舍] 技能合并完成。"); ArachnaeLog.Debug("[夺舍] 技能合并完成。");
} }
// 7. 将Hediff添加到最终身体上 // 7. 将Hediff添加到最终身体上
@@ -181,13 +181,13 @@ namespace ArachnaeSwarm
if (Props.hediffToApplyOnSuccess != null) if (Props.hediffToApplyOnSuccess != null)
{ {
targetPawn.health.AddHediff(Props.hediffToApplyOnSuccess, null, null); targetPawn.health.AddHediff(Props.hediffToApplyOnSuccess, null, null);
Log.Message($"[夺舍] 成功为 {targetPawn.LabelShort} 添加额外Hediff: {Props.hediffToApplyOnSuccess.defName}"); ArachnaeLog.Debug($"[夺舍] 成功为 {targetPawn.LabelShort} 添加额外Hediff: {Props.hediffToApplyOnSuccess.defName}");
} }
Log.Message($"[夺舍] {targetPawn.LabelShort} (原 {caster.LabelShort}) 夺舍完成。"); ArachnaeLog.Debug($"[夺舍] {targetPawn.LabelShort} (原 {caster.LabelShort}) 夺舍完成。");
} }
else else
{ {
Log.Error($"[夺舍] 无法将 {caster.LabelShort} 的副本存入Hediff。中止操作。"); ArachnaeLog.Debug($"[夺舍] 无法将 {caster.LabelShort} 的副本存入Hediff。中止操作。");
if(originalCaster != null && !originalCaster.Destroyed) originalCaster.Destroy(); if(originalCaster != null && !originalCaster.Destroyed) originalCaster.Destroy();
} }
} }
@@ -200,7 +200,7 @@ namespace ArachnaeSwarm
Verb bestMeleeVerb = caster.meleeVerbs.TryGetMeleeVerb(targetPawn); Verb bestMeleeVerb = caster.meleeVerbs.TryGetMeleeVerb(targetPawn);
if (bestMeleeVerb == null) if (bestMeleeVerb == null)
{ {
Log.Warning($"[Possess] Caster {caster.LabelShort} has no melee verb."); ArachnaeLog.Debug($"[Possess] Caster {caster.LabelShort} has no melee verb.");
return; return;
} }
@@ -210,23 +210,23 @@ namespace ArachnaeSwarm
var dinfo = new DamageInfo(damageDef, damageAmount, armorPenetration, -1, caster); var dinfo = new DamageInfo(damageDef, damageAmount, armorPenetration, -1, caster);
DamageWorker.DamageResult damageResult = targetPawn.TakeDamage(dinfo); DamageWorker.DamageResult damageResult = targetPawn.TakeDamage(dinfo);
Log.Message($"[Possess] Dealt {damageResult.totalDamageDealt} damage to {targetPawn.LabelShort} using {damageDef.defName}."); ArachnaeLog.Debug($"[Possess] Dealt {damageResult.totalDamageDealt} damage to {targetPawn.LabelShort} using {damageDef.defName}.");
if (damageResult.totalDamageDealt > 0) if (damageResult.totalDamageDealt > 0)
{ {
// 修改:使用新的成功率计算方法 // 修改:使用新的成功率计算方法
float finalChance = CalculateSuccessChance(targetPawn, damageResult.totalDamageDealt); float finalChance = CalculateSuccessChance(targetPawn, damageResult.totalDamageDealt);
Log.Message($"[Possess] Final chance: {finalChance:P0}"); ArachnaeLog.Debug($"[Possess] Final chance: {finalChance:P0}");
if (Rand.Chance(finalChance)) if (Rand.Chance(finalChance))
{ {
Log.Message($"[Possess] Success! Applying possession effect."); ArachnaeLog.Debug($"[Possess] Success! Applying possession effect.");
DoPossession(caster, targetPawn); DoPossession(caster, targetPawn);
} }
else else
{ {
Log.Message($"[Possess] Failed possession check."); ArachnaeLog.Debug($"[Possess] Failed possession check.");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -40,7 +40,7 @@ namespace ArachnaeSwarm
if (originalHostData != null) if (originalHostData != null)
{ {
Log.Message($"[夺舍结束] 正在将 {deadBody.LabelShort}'s 的灵魂恢复为原始宿主数据。"); ArachnaeLog.Debug($"[夺舍结束] 正在将 {deadBody.LabelShort}'s 的灵魂恢复为原始宿主数据。");
originalHostData.RestoreData(deadBody); originalHostData.RestoreData(deadBody);
// 恢复数据后移除可能存在的无人机Hediff // 恢复数据后移除可能存在的无人机Hediff
@@ -48,12 +48,12 @@ namespace ArachnaeSwarm
if (droneHediff != null) if (droneHediff != null)
{ {
deadBody.health.RemoveHediff(droneHediff); deadBody.health.RemoveHediff(droneHediff);
Log.Message($"[夺舍结束] 已从 {deadBody.LabelShort} 的尸体上移除 ARA_HiveMindDrone Hediff。"); ArachnaeLog.Debug($"[夺舍结束] 已从 {deadBody.LabelShort} 的尸体上移除 ARA_HiveMindDrone Hediff。");
} }
} }
else else
{ {
Log.Error("Possessed pawn died, but no original host data was found to restore."); ArachnaeLog.Debug("Possessed pawn died, but no original host data was found to restore.");
} }
if (storedCaster != null) if (storedCaster != null)
@@ -62,7 +62,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error("Possessed pawn died, but no caster soul was found inside."); ArachnaeLog.Debug("Possessed pawn died, but no caster soul was found inside.");
} }
} }
@@ -75,7 +75,7 @@ namespace ArachnaeSwarm
Map map = this.pawn.MapHeld ?? Find.AnyPlayerHomeMap; Map map = this.pawn.MapHeld ?? Find.AnyPlayerHomeMap;
if (map == null) if (map == null)
{ {
Log.Error("[夺舍] 无法找到一个有效的地图来重生抱脸虫。"); ArachnaeLog.Debug("[夺舍] 无法找到一个有效的地图来重生抱脸虫。");
return; return;
} }
@@ -85,7 +85,7 @@ namespace ArachnaeSwarm
cell = map.Center; cell = map.Center;
} }
Log.Message($"[夺舍] 准备在地图 {map.ToString()} 的位置 {cell.ToString()} 处重生 {StoredCasterPawn.LabelShort}。"); ArachnaeLog.Debug($"[夺舍] 准备在地图 {map.ToString()} 的位置 {cell.ToString()} 处重生 {StoredCasterPawn.LabelShort}。");
this.casterContainer.TryDropAll(cell, map, ThingPlaceMode.Near); this.casterContainer.TryDropAll(cell, map, ThingPlaceMode.Near);
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -11,14 +11,14 @@ namespace ArachnaeSwarm
{ {
if (soulSource == null || bodyTarget == null) if (soulSource == null || bodyTarget == null)
{ {
Log.Error("Cannot transfer soul: source or target is null."); ArachnaeLog.Debug("Cannot transfer soul: source or target is null.");
return; return;
} }
Log.Message($"Beginning soul transfer from {soulSource.LabelShort} to {bodyTarget.LabelShort}."); ArachnaeLog.Debug($"Beginning soul transfer from {soulSource.LabelShort} to {bodyTarget.LabelShort}.");
bool isPossessing = soulSource.def.defName == "ARA_HuggingFace"; bool isPossessing = soulSource.def.defName == "ARA_HuggingFace";
Log.Message(isPossessing ? "[夺舍] 模式:抱脸虫 -> 宿主" : "[回归] 模式:宿主 -> 抱脸虫"); ArachnaeLog.Debug(isPossessing ? "[夺舍] 模式:抱脸虫 -> 宿主" : "[回归] 模式:宿主 -> 抱脸虫");
// --- 1. Core Identity --- // --- 1. Core Identity ---
bodyTarget.Name = soulSource.Name; bodyTarget.Name = soulSource.Name;
@@ -160,7 +160,7 @@ namespace ArachnaeSwarm
// --- 5. Finalization --- // --- 5. Finalization ---
bodyTarget.Drawer.renderer.SetAllGraphicsDirty(); bodyTarget.Drawer.renderer.SetAllGraphicsDirty();
Log.Message("Soul transfer complete."); ArachnaeLog.Debug("Soul transfer complete.");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using RimWorld.Utility; using RimWorld.Utility;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -14,7 +14,7 @@ namespace ArachnaeSwarm
// 2. Capture the reliable target information early. // 2. Capture the reliable target information early.
public override bool TryStartCastOn(LocalTargetInfo castTarg, LocalTargetInfo destTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true, bool preventFriendlyFire = false, bool nonInterruptingSelfCast = false) public override bool TryStartCastOn(LocalTargetInfo castTarg, LocalTargetInfo destTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true, bool preventFriendlyFire = false, bool nonInterruptingSelfCast = false)
{ {
Log.Message($"[Verb_JumpAndCastOnLanding] TryStartCastOn: Capturing our dedicated target: {castTarg.Thing?.LabelShort ?? "null"}."); ArachnaeLog.Debug($"[Verb_JumpAndCastOnLanding] TryStartCastOn: Capturing our dedicated target: {castTarg.Thing?.LabelShort ?? "null"}.");
this.capturedTarget = castTarg; this.capturedTarget = castTarg;
return base.TryStartCastOn(castTarg, destTarg, surpriseAttack, canHitNonTargetPawns, preventFriendlyFire, nonInterruptingSelfCast); return base.TryStartCastOn(castTarg, destTarg, surpriseAttack, canHitNonTargetPawns, preventFriendlyFire, nonInterruptingSelfCast);
} }
@@ -50,11 +50,11 @@ namespace ArachnaeSwarm
if (logicalTargetForUs == null || !logicalTargetForUs.HasThing) if (logicalTargetForUs == null || !logicalTargetForUs.HasThing)
{ {
Log.Error($"[Verb_JumpAndCastOnLanding] TryCastShot: Our captured target is invalid!"); ArachnaeLog.Debug($"[Verb_JumpAndCastOnLanding] TryCastShot: Our captured target is invalid!");
return false; return false;
} }
Log.Message($"[Verb_JumpAndCastOnLanding] TryCastShot: Using our captured target '{logicalTargetForUs.Thing.LabelShort}' for logic, and letting game use '{physicalTarget.Cell}' for jump physics."); ArachnaeLog.Debug($"[Verb_JumpAndCastOnLanding] TryCastShot: Using our captured target '{logicalTargetForUs.Thing.LabelShort}' for logic, and letting game use '{physicalTarget.Cell}' for jump physics.");
bool jumpStarted = JumpUtility.DoJump( bool jumpStarted = JumpUtility.DoJump(
CasterPawn, CasterPawn,

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
@@ -76,7 +76,7 @@ namespace ArachnaeSwarm
if (Props.cocoonBuildingDef == null) if (Props.cocoonBuildingDef == null)
{ {
Log.Error("CompAbilityEffect_ShowInteractiveThing: cocoonBuildingDef is null"); ArachnaeLog.Debug("CompAbilityEffect_ShowInteractiveThing: cocoonBuildingDef is null");
return result; return result;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
@@ -67,7 +67,7 @@ namespace ArachnaeSwarm
{ {
if (Props.spawnBuildingDef == null) if (Props.spawnBuildingDef == null)
{ {
Log.Error("CompProperties_AbilityShowSpawnablePawns: spawnBuildingDef is null"); ArachnaeLog.Debug("CompProperties_AbilityShowSpawnablePawns: spawnBuildingDef is null");
return null; return null;
} }
@@ -80,7 +80,7 @@ namespace ArachnaeSwarm
} }
} }
Log.Warning($"CompProperties_AbilityShowSpawnablePawns: No spawn comp found on building {Props.spawnBuildingDef.defName}"); ArachnaeLog.Debug($"CompProperties_AbilityShowSpawnablePawns: No spawn comp found on building {Props.spawnBuildingDef.defName}");
return null; return null;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
@@ -137,7 +137,7 @@ namespace ArachnaeSwarm
{ {
if (Props.temperatureCheckBuilding == null) if (Props.temperatureCheckBuilding == null)
{ {
Log.Error("CompProperties_AbilityShowTemperatureRange: temperatureCheckBuilding is null"); ArachnaeLog.Debug("CompProperties_AbilityShowTemperatureRange: temperatureCheckBuilding is null");
return null; return null;
} }
@@ -150,7 +150,7 @@ namespace ArachnaeSwarm
} }
} }
Log.Warning($"CompProperties_AbilityShowTemperatureRange: No temperature comp found on building {Props.temperatureCheckBuilding.defName}"); ArachnaeLog.Debug($"CompProperties_AbilityShowTemperatureRange: No temperature comp found on building {Props.temperatureCheckBuilding.defName}");
return null; return null;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
using System.Reflection; using System.Reflection;
@@ -65,7 +65,7 @@ namespace ArachnaeSwarm
if (pawn.Spawned) pawn.DeSpawn(DestroyMode.WillReplace); if (pawn.Spawned) pawn.DeSpawn(DestroyMode.WillReplace);
if (!innerContainer.TryAdd(pawn)) if (!innerContainer.TryAdd(pawn))
{ {
Log.Error("Could not add pawn to tracking flyer."); ArachnaeLog.Debug("Could not add pawn to tracking flyer.");
pawn.Destroy(); pawn.Destroy();
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Linq; using System.Linq;
@@ -11,13 +11,13 @@ namespace ArachnaeSwarm
var props = this.ability.def.comps?.OfType<CompProperties_TrackingCharge>().FirstOrDefault(); var props = this.ability.def.comps?.OfType<CompProperties_TrackingCharge>().FirstOrDefault();
if (props == null) if (props == null)
{ {
Log.Error("Verb_CastAbilityTrackingCharge requires CompProperties_TrackingCharge on the ability def."); ArachnaeLog.Debug("Verb_CastAbilityTrackingCharge requires CompProperties_TrackingCharge on the ability def.");
return false; return false;
} }
if (props.flyerDef == null) if (props.flyerDef == null)
{ {
Log.Error("CompProperties_TrackingCharge requires a flyerDef."); ArachnaeLog.Debug("CompProperties_TrackingCharge requires a flyerDef.");
return false; return false;
} }
@@ -27,7 +27,7 @@ namespace ArachnaeSwarm
Map map = this.Caster.Map; Map map = this.Caster.Map;
if (map == null) if (map == null)
{ {
Log.Error($"Verb_CastAbilityTrackingCharge: Caster {this.Caster.LabelCap} has a null map. Cannot cast."); ArachnaeLog.Debug($"Verb_CastAbilityTrackingCharge: Caster {this.Caster.LabelCap} has a null map. Cannot cast.");
return false; return false;
} }

View File

@@ -0,0 +1,22 @@
using Verse;
namespace ArachnaeSwarm
{
/// <summary>
/// Centralized debug logging controlled by mod settings.
/// Only shows when mod option is enabled, independent of DevMode.
/// </summary>
public static class ArachnaeLog
{
private static bool DebugEnabled =>
ArachnaeSwarmMod.settings?.enableDebugLogs ?? false;
public static void Debug(string message)
{
if (DebugEnabled)
{
Log.Message(message);
}
}
}
}

View File

@@ -259,7 +259,9 @@
<Compile Include="Stat\StatWorker_IncubationInfo.cs" /> <Compile Include="Stat\StatWorker_IncubationInfo.cs" />
<Compile Include="Thing_Comps\ARA_ThingComp_GuardianPsyField\ThingComp_GuardianPsyField.cs" /> <Compile Include="Thing_Comps\ARA_ThingComp_GuardianPsyField\ThingComp_GuardianPsyField.cs" />
<Compile Include="Thing_Comps\ARA_ThingComp_GuardianPsyField\Harmony_ProjectileInterceptor.cs" /> <Compile Include="Thing_Comps\ARA_ThingComp_GuardianPsyField\Harmony_ProjectileInterceptor.cs" />
<Compile Include="MainHarmony.cs" /> <Compile Include="ArachnaeLog.cs" />
<Compile Include="ArachnaeSwarmMod.cs" />
<Compile Include="ArachnaeSwarmSettings.cs" />
<Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompExtraIncubationInfo.cs" /> <Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompExtraIncubationInfo.cs" />
<Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompProperties_ExtraIncubationInfo.cs" /> <Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompProperties_ExtraIncubationInfo.cs" />
<Compile Include="Thing_Comps\CompAndPatch_GiveHediffOnShot.cs" /> <Compile Include="Thing_Comps\CompAndPatch_GiveHediffOnShot.cs" />

View File

@@ -0,0 +1,40 @@
using HarmonyLib;
using System.Reflection;
using UnityEngine;
using Verse;
namespace ArachnaeSwarm
{
[StaticConstructorOnStartup]
public class ArachnaeSwarmMod : Mod
{
public static ArachnaeSwarmSettings settings;
public ArachnaeSwarmMod(ModContentPack content) : base(content)
{
settings = GetSettings<ArachnaeSwarmSettings>();
// 初始化Harmony
var harmony = new Harmony("com.kalospacer.arachnaeswarm");
harmony.PatchAll(Assembly.GetExecutingAssembly());
ArachnaeLog.Debug("[ArachnaeSwarm] Harmony patches applied.");
}
public override void DoSettingsWindowContents(Rect inRect)
{
Listing_Standard listingStandard = new Listing_Standard();
listingStandard.Begin(inRect);
listingStandard.CheckboxLabeled("Enable Debug Logs".Translate(), ref settings.enableDebugLogs, "Enable detailed debug logging (independent of DevMode)".Translate());
listingStandard.End();
base.DoSettingsWindowContents(inRect);
}
public override string SettingsCategory()
{
return "Arachnae Swarm";
}
}
}

View File

@@ -0,0 +1,15 @@
using Verse;
namespace ArachnaeSwarm
{
public class ArachnaeSwarmSettings : ModSettings
{
public bool enableDebugLogs = false;
public override void ExposeData()
{
Scribe_Values.Look(ref enableDebugLogs, "enableDebugLogs", false);
base.ExposeData();
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -163,7 +163,7 @@ namespace ArachnaeSwarm
{ {
if (selectedPawn != null && innerContainer.Contains(selectedPawn)) if (selectedPawn != null && innerContainer.Contains(selectedPawn))
{ {
Log.Warning($"RefuelingVat despawned with pawn inside, forcing ejection."); ArachnaeLog.Debug($"RefuelingVat despawned with pawn inside, forcing ejection.");
Finish(); // 使用修改后的Finish方法 Finish(); // 使用修改后的Finish方法
} }
} }
@@ -207,7 +207,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error applying acid damage to {pawn}: {ex.Message}"); ArachnaeLog.Debug($"Error applying acid damage to {pawn}: {ex.Message}");
} }
} }
@@ -222,7 +222,7 @@ namespace ArachnaeSwarm
// 检查是否是被建筑杀死的 // 检查是否是被建筑杀死的
if (pawnsKilledByVat.Contains(pawn)) if (pawnsKilledByVat.Contains(pawn))
{ {
Log.Message($"Pawn {pawn.Label} killed by RefuelingVat, destroying corpse."); ArachnaeLog.Debug($"Pawn {pawn.Label} killed by RefuelingVat, destroying corpse.");
// 从容器中移除pawn // 从容器中移除pawn
if (innerContainer.Contains(pawn)) if (innerContainer.Contains(pawn))
@@ -251,7 +251,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error handling pawn death for {pawn}: {ex}"); ArachnaeLog.Debug($"Error handling pawn death for {pawn}: {ex}");
} }
} }
@@ -426,7 +426,7 @@ namespace ArachnaeSwarm
// 方法3强制移除仅对活着的pawn // 方法3强制移除仅对活着的pawn
if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead) if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead)
{ {
Log.Warning($"Forcing removal of pawn {selectedPawn} from RefuelingVat"); ArachnaeLog.Debug($"Forcing removal of pawn {selectedPawn} from RefuelingVat");
innerContainer.Remove(selectedPawn); innerContainer.Remove(selectedPawn);
GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near); GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near);
ejected = true; ejected = true;
@@ -435,16 +435,16 @@ namespace ArachnaeSwarm
if (ejected) if (ejected)
{ {
Log.Message($"Successfully ejected {selectedPawn} using method: {ejectionMethod}"); ArachnaeLog.Debug($"Successfully ejected {selectedPawn} using method: {ejectionMethod}");
} }
else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错 else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错
{ {
Log.Error($"Failed to eject {selectedPawn} from RefuelingVat"); ArachnaeLog.Debug($"Failed to eject {selectedPawn} from RefuelingVat");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error during Finish() for {selectedPawn}: {ex}"); ArachnaeLog.Debug($"Error during Finish() for {selectedPawn}: {ex}");
} }
finally finally
{ {
@@ -463,7 +463,7 @@ namespace ArachnaeSwarm
// 确保pawn不在容器中除非是被建筑杀死的 // 确保pawn不在容器中除非是被建筑杀死的
if (innerContainer.Contains(selectedPawn) && !(selectedPawn.Dead && pawnsKilledByVat.Contains(selectedPawn))) if (innerContainer.Contains(selectedPawn) && !(selectedPawn.Dead && pawnsKilledByVat.Contains(selectedPawn)))
{ {
Log.Warning($"Pawn {selectedPawn} still in container during OnStop, forcing removal."); ArachnaeLog.Debug($"Pawn {selectedPawn} still in container during OnStop, forcing removal.");
innerContainer.Remove(selectedPawn); innerContainer.Remove(selectedPawn);
} }
} }
@@ -668,7 +668,7 @@ namespace ArachnaeSwarm
JobDef carryJobDef = DefDatabase<JobDef>.GetNamed("ARA_CarryPrisonerToRefuelingVat"); JobDef carryJobDef = DefDatabase<JobDef>.GetNamed("ARA_CarryPrisonerToRefuelingVat");
if (carryJobDef == null) if (carryJobDef == null)
{ {
Log.Error("ARA_CarryPrisonerToRefuelingVat JobDef not found!"); ArachnaeLog.Debug("ARA_CarryPrisonerToRefuelingVat JobDef not found!");
return null; return null;
} }
Job job = JobMaker.MakeJob(carryJobDef, prisoner, this); Job job = JobMaker.MakeJob(carryJobDef, prisoner, this);

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using RimWorld; using RimWorld;
@@ -110,7 +110,7 @@ namespace ArachnaeSwarm
{ {
if (!InProduction || _selectedProcess == null) if (!InProduction || _selectedProcess == null)
{ {
Log.Warning($"Attempted to fix negative time but no process is selected. Resetting production."); ArachnaeLog.Debug($"Attempted to fix negative time but no process is selected. Resetting production.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -118,7 +118,7 @@ namespace ArachnaeSwarm
int currentTicks = Find.TickManager.TicksGame; int currentTicks = Find.TickManager.TicksGame;
int remainingTicks = productionUntilTick - currentTicks; int remainingTicks = productionUntilTick - currentTicks;
Log.Warning($"Detected negative production time for {parent.Label}. " + ArachnaeLog.Debug($"Detected negative production time for {parent.Label}. " +
$"Current: {currentTicks}, Target: {productionUntilTick}, Remaining: {remainingTicks}. " + $"Current: {currentTicks}, Target: {productionUntilTick}, Remaining: {remainingTicks}. " +
$"Process: {_selectedProcess.thingDef?.defName ?? "Unknown"}, Expected Duration: {_selectedProcess.productionTicks}"); $"Process: {_selectedProcess.thingDef?.defName ?? "Unknown"}, Expected Duration: {_selectedProcess.productionTicks}");
@@ -128,7 +128,7 @@ namespace ArachnaeSwarm
// 如果偏差太大,直接完成生产 // 如果偏差太大,直接完成生产
if (remainingTicks < -_selectedProcess.productionTicks) if (remainingTicks < -_selectedProcess.productionTicks)
{ {
Log.Warning($"Negative time too large ({remainingTicks} ticks). Forcing production completion."); ArachnaeLog.Debug($"Negative time too large ({remainingTicks} ticks). Forcing production completion.");
FinishProduction(); FinishProduction();
return; return;
} }
@@ -137,7 +137,7 @@ namespace ArachnaeSwarm
productionUntilTick = correctEndTick; productionUntilTick = correctEndTick;
hasFixedNegativeTime = true; hasFixedNegativeTime = true;
Log.Message($"Fixed negative production time for {parent.Label}. " + ArachnaeLog.Debug($"Fixed negative production time for {parent.Label}. " +
$"New target: {productionUntilTick}, New remaining: {_selectedProcess.productionTicks} ticks"); $"New target: {productionUntilTick}, New remaining: {_selectedProcess.productionTicks} ticks");
// 发送消息通知(开发模式) // 发送消息通知(开发模式)
@@ -180,7 +180,7 @@ namespace ArachnaeSwarm
// 新增:立即检查一次负时间问题 // 新增:立即检查一次负时间问题
if (InProduction && HasNegativeTimeProblem) if (InProduction && HasNegativeTimeProblem)
{ {
Log.Warning($"Detected negative production time on spawn for {parent.Label}"); ArachnaeLog.Debug($"Detected negative production time on spawn for {parent.Label}");
FixNegativeTimeProblem(); FixNegativeTimeProblem();
} }
} }
@@ -215,7 +215,7 @@ namespace ArachnaeSwarm
// 如果找不到对应的 ProcessDef重置生产状态 // 如果找不到对应的 ProcessDef重置生产状态
if (_selectedProcess == null) if (_selectedProcess == null)
{ {
Log.Warning($"Could not find ProcessDef for {selectedProcessThingDef.defName} after loading. Resetting production."); ArachnaeLog.Debug($"Could not find ProcessDef for {selectedProcessThingDef.defName} after loading. Resetting production.");
ResetProduction(); ResetProduction();
} }
// 关键修复:检查时间戳是否有效 // 关键修复:检查时间戳是否有效
@@ -224,19 +224,19 @@ namespace ArachnaeSwarm
// 如果生产结束时间已经过去,立即完成生产 // 如果生产结束时间已经过去,立即完成生产
if (Find.TickManager.TicksGame >= productionUntilTick) if (Find.TickManager.TicksGame >= productionUntilTick)
{ {
Log.Warning($"Production time already passed for {selectedProcessThingDef.defName}. Finishing immediately."); ArachnaeLog.Debug($"Production time already passed for {selectedProcessThingDef.defName}. Finishing immediately.");
FinishProduction(); FinishProduction();
} }
// 如果时间戳异常(比如超过游戏当前时间太多),重新计算 // 如果时间戳异常(比如超过游戏当前时间太多),重新计算
else if (productionUntilTick - Find.TickManager.TicksGame > _selectedProcess.productionTicks * 10) else if (productionUntilTick - Find.TickManager.TicksGame > _selectedProcess.productionTicks * 10)
{ {
Log.Warning($"Abnormal production time detected for {selectedProcessThingDef.defName}. Recalculating."); ArachnaeLog.Debug($"Abnormal production time detected for {selectedProcessThingDef.defName}. Recalculating.");
productionUntilTick = Find.TickManager.TicksGame + _selectedProcess.productionTicks; productionUntilTick = Find.TickManager.TicksGame + _selectedProcess.productionTicks;
} }
// 新增:检查负时间问题 // 新增:检查负时间问题
else if (HasNegativeTimeProblem) else if (HasNegativeTimeProblem)
{ {
Log.Warning($"Negative production time detected on load for {selectedProcessThingDef.defName}. Fixing."); ArachnaeLog.Debug($"Negative production time detected on load for {selectedProcessThingDef.defName}. Fixing.");
FixNegativeTimeProblem(); FixNegativeTimeProblem();
} }
} }
@@ -351,7 +351,7 @@ namespace ArachnaeSwarm
// 关键修复:添加时间戳有效性检查 // 关键修复:添加时间戳有效性检查
if (productionUntilTick <= 0) if (productionUntilTick <= 0)
{ {
Log.Error($"Invalid productionUntilTick: {productionUntilTick}. Resetting production."); ArachnaeLog.Debug($"Invalid productionUntilTick: {productionUntilTick}. Resetting production.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -443,7 +443,7 @@ namespace ArachnaeSwarm
// 新增:冷却期内不允许开始生产 // 新增:冷却期内不允许开始生产
if (InCooldown) if (InCooldown)
{ {
Log.Warning("Attempted to start production during cooldown period."); ArachnaeLog.Debug("Attempted to start production during cooldown period.");
return; return;
} }
@@ -489,7 +489,7 @@ namespace ArachnaeSwarm
{ {
if (_selectedProcess == null) if (_selectedProcess == null)
{ {
Log.Warning("FinishProduction called but _selectedProcess is null. Resetting."); ArachnaeLog.Debug("FinishProduction called but _selectedProcess is null. Resetting.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -520,7 +520,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in FinishProduction: {ex.Message}"); ArachnaeLog.Debug($"Error in FinishProduction: {ex.Message}");
} }
finally finally
{ {
@@ -557,7 +557,7 @@ namespace ArachnaeSwarm
ThingDef fuelDef = FuelComp.Props.fuelFilter.AnyAllowedDef; ThingDef fuelDef = FuelComp.Props.fuelFilter.AnyAllowedDef;
if (fuelDef == null) if (fuelDef == null)
{ {
Log.Warning("No fuel definition found for ejecting remaining fuel."); ArachnaeLog.Debug("No fuel definition found for ejecting remaining fuel.");
return; return;
} }
// 计算可以生成的物品数量1:1比例 // 计算可以生成的物品数量1:1比例

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -229,7 +229,7 @@ namespace ArachnaeSwarm
{ {
if (order.process == null) if (order.process == null)
{ {
Log.Warning("FinishProduction called but order.process is null. Skipping."); ArachnaeLog.Debug("FinishProduction called but order.process is null. Skipping.");
return; return;
} }
@@ -247,7 +247,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in FinishProduction for {order.process.thingDef.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in FinishProduction for {order.process.thingDef.defName}: {ex.Message}");
} }
} }
@@ -330,7 +330,7 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(order.tempThingDefName)) if (string.IsNullOrEmpty(order.tempThingDefName))
{ {
Log.Warning($"CompQueuedInteractiveProducer: Found a queued order with no thingDefName after loading. Removing it."); ArachnaeLog.Debug($"CompQueuedInteractiveProducer: Found a queued order with no thingDefName after loading. Removing it.");
return true; return true;
} }
@@ -338,7 +338,7 @@ namespace ArachnaeSwarm
if (order.process == null) if (order.process == null)
{ {
Log.Warning($"CompQueuedInteractiveProducer: Could not find a matching ProcessDef for '{order.tempThingDefName}' after loading. The item may have been removed. Removing order."); ArachnaeLog.Debug($"CompQueuedInteractiveProducer: Could not find a matching ProcessDef for '{order.tempThingDefName}' after loading. The item may have been removed. Removing order.");
return true; return true;
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using RimWorld; using RimWorld;
@@ -108,7 +108,7 @@ namespace ArachnaeSwarm
{ {
if (!InProduction || _selectedProcess == null) if (!InProduction || _selectedProcess == null)
{ {
Log.Warning($"Attempted to fix negative time but no process is selected. Resetting production."); ArachnaeLog.Debug($"Attempted to fix negative time but no process is selected. Resetting production.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -116,7 +116,7 @@ namespace ArachnaeSwarm
int currentTicks = Find.TickManager.TicksGame; int currentTicks = Find.TickManager.TicksGame;
int remainingTicks = productionUntilTick - currentTicks; int remainingTicks = productionUntilTick - currentTicks;
Log.Warning($"Detected negative research production time for {parent.Label}. " + ArachnaeLog.Debug($"Detected negative research production time for {parent.Label}. " +
$"Current: {currentTicks}, Target: {productionUntilTick}, Remaining: {remainingTicks}. " + $"Current: {currentTicks}, Target: {productionUntilTick}, Remaining: {remainingTicks}. " +
$"Research: {_selectedProcess.researchDef?.defName ?? "Unknown"}, Expected Duration: {_selectedProcess.productionTicks}"); $"Research: {_selectedProcess.researchDef?.defName ?? "Unknown"}, Expected Duration: {_selectedProcess.productionTicks}");
@@ -126,7 +126,7 @@ namespace ArachnaeSwarm
// 如果偏差太大,直接完成生产 // 如果偏差太大,直接完成生产
if (remainingTicks < -_selectedProcess.productionTicks) if (remainingTicks < -_selectedProcess.productionTicks)
{ {
Log.Warning($"Negative time too large ({remainingTicks} ticks). Forcing production completion."); ArachnaeLog.Debug($"Negative time too large ({remainingTicks} ticks). Forcing production completion.");
FinishProduction(); FinishProduction();
return; return;
} }
@@ -135,7 +135,7 @@ namespace ArachnaeSwarm
productionUntilTick = correctEndTick; productionUntilTick = correctEndTick;
hasFixedNegativeTime = true; hasFixedNegativeTime = true;
Log.Message($"Fixed negative research production time for {parent.Label}. " + ArachnaeLog.Debug($"Fixed negative research production time for {parent.Label}. " +
$"New target: {productionUntilTick}, New remaining: {_selectedProcess.productionTicks} ticks"); $"New target: {productionUntilTick}, New remaining: {_selectedProcess.productionTicks} ticks");
// 发送消息通知(开发模式) // 发送消息通知(开发模式)
@@ -177,7 +177,7 @@ namespace ArachnaeSwarm
// 新增:立即检查一次负时间问题 // 新增:立即检查一次负时间问题
if (InProduction && HasNegativeTimeProblem) if (InProduction && HasNegativeTimeProblem)
{ {
Log.Warning($"Detected negative research production time on spawn for {parent.Label}"); ArachnaeLog.Debug($"Detected negative research production time on spawn for {parent.Label}");
FixNegativeTimeProblem(); FixNegativeTimeProblem();
} }
} }
@@ -207,25 +207,25 @@ namespace ArachnaeSwarm
if (_selectedProcess == null) if (_selectedProcess == null)
{ {
Log.Warning($"Could not find ResearchProcessDef for {selectedProcessResearchDef.defName} after loading. Resetting production."); ArachnaeLog.Debug($"Could not find ResearchProcessDef for {selectedProcessResearchDef.defName} after loading. Resetting production.");
ResetProduction(); ResetProduction();
} }
else if (productionUntilTick > 0) else if (productionUntilTick > 0)
{ {
if (Find.TickManager.TicksGame >= productionUntilTick) if (Find.TickManager.TicksGame >= productionUntilTick)
{ {
Log.Warning($"Production time already passed for {selectedProcessResearchDef.defName}. Finishing immediately."); ArachnaeLog.Debug($"Production time already passed for {selectedProcessResearchDef.defName}. Finishing immediately.");
FinishProduction(); FinishProduction();
} }
else if (productionUntilTick - Find.TickManager.TicksGame > _selectedProcess.productionTicks * 10) else if (productionUntilTick - Find.TickManager.TicksGame > _selectedProcess.productionTicks * 10)
{ {
Log.Warning($"Abnormal production time detected for {selectedProcessResearchDef.defName}. Recalculating."); ArachnaeLog.Debug($"Abnormal production time detected for {selectedProcessResearchDef.defName}. Recalculating.");
productionUntilTick = Find.TickManager.TicksGame + _selectedProcess.productionTicks; productionUntilTick = Find.TickManager.TicksGame + _selectedProcess.productionTicks;
} }
// 新增:检查负时间问题 // 新增:检查负时间问题
else if (HasNegativeTimeProblem) else if (HasNegativeTimeProblem)
{ {
Log.Warning($"Negative production time detected on load for {selectedProcessResearchDef.defName}. Fixing."); ArachnaeLog.Debug($"Negative production time detected on load for {selectedProcessResearchDef.defName}. Fixing.");
FixNegativeTimeProblem(); FixNegativeTimeProblem();
} }
} }
@@ -240,7 +240,7 @@ namespace ArachnaeSwarm
ResearchTabDef araResearchTab = DefDatabase<ResearchTabDef>.GetNamedSilentFail("ARA_ResearchTab"); ResearchTabDef araResearchTab = DefDatabase<ResearchTabDef>.GetNamedSilentFail("ARA_ResearchTab");
if (araResearchTab == null) if (araResearchTab == null)
{ {
Log.Warning("ARA_ResearchTab not found. No research processes will be available."); ArachnaeLog.Debug("ARA_ResearchTab not found. No research processes will be available.");
return; return;
} }
int totalScanned = 0; int totalScanned = 0;
@@ -286,7 +286,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Warning($"Techprint ThingDef not found for research project {researchDef.defName}. Expected defName: {techprintDefName}"); ArachnaeLog.Debug($"Techprint ThingDef not found for research project {researchDef.defName}. Expected defName: {techprintDefName}");
} }
} }
} }
@@ -294,7 +294,7 @@ namespace ArachnaeSwarm
// 按研究项目名称排序 // 按研究项目名称排序
_cachedProcesses.SortBy(p => p.researchDef.label); _cachedProcesses.SortBy(p => p.researchDef.label);
// 记录详细的扫描结果 // 记录详细的扫描结果
Log.Message($"Research production scanner: Scanned {totalScanned} research projects, " + ArachnaeLog.Debug($"Research production scanner: Scanned {totalScanned} research projects, " +
$"{araTabCount} in ARA_ResearchTab, " + $"{araTabCount} in ARA_ResearchTab, " +
$"{techprintCount} require techprints, " + $"{techprintCount} require techprints, " +
$"{prerequisitesMetCount} have prerequisites met, " + $"{prerequisitesMetCount} have prerequisites met, " +
@@ -339,7 +339,7 @@ namespace ArachnaeSwarm
{ {
if (productionUntilTick <= 0) if (productionUntilTick <= 0)
{ {
Log.Error($"Invalid productionUntilTick: {productionUntilTick}. Resetting production."); ArachnaeLog.Debug($"Invalid productionUntilTick: {productionUntilTick}. Resetting production.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -417,7 +417,7 @@ namespace ArachnaeSwarm
{ {
if (InCooldown) if (InCooldown)
{ {
Log.Warning("Attempted to start production during cooldown period."); ArachnaeLog.Debug("Attempted to start production during cooldown period.");
return; return;
} }
@@ -435,7 +435,7 @@ namespace ArachnaeSwarm
{ {
if (_selectedProcess == null) if (_selectedProcess == null)
{ {
Log.Warning("FinishProduction called but _selectedProcess is null. Resetting."); ArachnaeLog.Debug("FinishProduction called but _selectedProcess is null. Resetting.");
ResetProduction(); ResetProduction();
return; return;
} }
@@ -469,7 +469,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in FinishProduction: {ex.Message}"); ArachnaeLog.Debug($"Error in FinishProduction: {ex.Message}");
} }
finally finally
{ {
@@ -493,7 +493,7 @@ namespace ArachnaeSwarm
ThingDef fuelDef = FuelComp.Props.fuelFilter.AnyAllowedDef; ThingDef fuelDef = FuelComp.Props.fuelFilter.AnyAllowedDef;
if (fuelDef == null) if (fuelDef == null)
{ {
Log.Warning("No fuel definition found for ejecting remaining fuel."); ArachnaeLog.Debug("No fuel definition found for ejecting remaining fuel.");
return; return;
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
@@ -36,7 +36,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"CompResearchProducer not found on {Building.Label}"); ArachnaeLog.Debug($"CompResearchProducer not found on {Building.Label}");
} }
}; };
work.defaultCompleteMode = ToilCompleteMode.Instant; work.defaultCompleteMode = ToilCompleteMode.Instant;

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -107,7 +107,7 @@ namespace ArachnaeSwarm
{ {
if (selectedPawn != null && innerContainer.Contains(selectedPawn)) if (selectedPawn != null && innerContainer.Contains(selectedPawn))
{ {
Log.Warning($"NutrientVat despawned with pawn inside, forcing ejection."); ArachnaeLog.Debug($"NutrientVat despawned with pawn inside, forcing ejection.");
Finish(); // 使用修改后的Finish方法 Finish(); // 使用修改后的Finish方法
} }
} }
@@ -145,7 +145,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error applying acid damage to {pawn}: {ex.Message}"); ArachnaeLog.Debug($"Error applying acid damage to {pawn}: {ex.Message}");
} }
} }
@@ -157,7 +157,7 @@ namespace ArachnaeSwarm
// 检查是否是被建筑杀死的 // 检查是否是被建筑杀死的
if (pawnsKilledByVat.Contains(pawn)) if (pawnsKilledByVat.Contains(pawn))
{ {
Log.Message($"Pawn {pawn.Label} killed by NutrientVat, destroying corpse."); ArachnaeLog.Debug($"Pawn {pawn.Label} killed by NutrientVat, destroying corpse.");
// 从容器中移除pawn // 从容器中移除pawn
if (innerContainer.Contains(pawn)) if (innerContainer.Contains(pawn))
@@ -187,7 +187,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error handling pawn death for {pawn}: {ex}"); ArachnaeLog.Debug($"Error handling pawn death for {pawn}: {ex}");
} }
} }
@@ -382,7 +382,7 @@ namespace ArachnaeSwarm
// 方法3强制移除仅对活着的pawn // 方法3强制移除仅对活着的pawn
if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead) if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead)
{ {
Log.Warning($"Forcing removal of pawn {selectedPawn} from NutrientVat"); ArachnaeLog.Debug($"Forcing removal of pawn {selectedPawn} from NutrientVat");
innerContainer.Remove(selectedPawn); innerContainer.Remove(selectedPawn);
GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near); GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near);
ejected = true; ejected = true;
@@ -391,16 +391,16 @@ namespace ArachnaeSwarm
if (ejected) if (ejected)
{ {
Log.Message($"Successfully ejected {selectedPawn} using method: {ejectionMethod}"); ArachnaeLog.Debug($"Successfully ejected {selectedPawn} using method: {ejectionMethod}");
} }
else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错 else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错
{ {
Log.Error($"Failed to eject {selectedPawn} from NutrientVat"); ArachnaeLog.Debug($"Failed to eject {selectedPawn} from NutrientVat");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error during Finish() for {selectedPawn}: {ex}"); ArachnaeLog.Debug($"Error during Finish() for {selectedPawn}: {ex}");
} }
finally finally
{ {
@@ -449,7 +449,7 @@ namespace ArachnaeSwarm
// 方法3强制移除仅对活着的pawn // 方法3强制移除仅对活着的pawn
if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead) if (!ejected && innerContainer.Contains(selectedPawn) && !selectedPawn.Dead)
{ {
Log.Warning($"Forcing removal of failed pawn {selectedPawn} from NutrientVat"); ArachnaeLog.Debug($"Forcing removal of failed pawn {selectedPawn} from NutrientVat");
innerContainer.Remove(selectedPawn); innerContainer.Remove(selectedPawn);
GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near); GenPlace.TryPlaceThing(selectedPawn, this.Position, base.Map, ThingPlaceMode.Near);
ejected = true; ejected = true;
@@ -458,14 +458,14 @@ namespace ArachnaeSwarm
if (ejected) if (ejected)
{ {
Log.Message($"Successfully ejected failed pawn {selectedPawn} using method: {ejectionMethod}"); ArachnaeLog.Debug($"Successfully ejected failed pawn {selectedPawn} using method: {ejectionMethod}");
// 在成功弹出后杀死俘虏 // 在成功弹出后杀死俘虏
Hediff firstHediffOfDef = selectedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.BioStarvation); Hediff firstHediffOfDef = selectedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.BioStarvation);
selectedPawn.Kill(null, firstHediffOfDef); selectedPawn.Kill(null, firstHediffOfDef);
} }
else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错 else if (!selectedPawn.Dead) // 只有活着的pawn弹出失败才报错
{ {
Log.Error($"Failed to eject failed pawn {selectedPawn} from NutrientVat"); ArachnaeLog.Debug($"Failed to eject failed pawn {selectedPawn} from NutrientVat");
// 即使弹出失败也要杀死俘虏 // 即使弹出失败也要杀死俘虏
Hediff firstHediffOfDef = selectedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.BioStarvation); Hediff firstHediffOfDef = selectedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.BioStarvation);
selectedPawn.Kill(null, firstHediffOfDef); selectedPawn.Kill(null, firstHediffOfDef);
@@ -473,7 +473,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error during Fail() for {selectedPawn}: {ex}"); ArachnaeLog.Debug($"Error during Fail() for {selectedPawn}: {ex}");
} }
finally finally
{ {
@@ -493,7 +493,7 @@ namespace ArachnaeSwarm
// 确保pawn不在容器中除非是被建筑杀死的 // 确保pawn不在容器中除非是被建筑杀死的
if (innerContainer.Contains(selectedPawn) && !(selectedPawn.Dead && pawnsKilledByVat.Contains(selectedPawn))) if (innerContainer.Contains(selectedPawn) && !(selectedPawn.Dead && pawnsKilledByVat.Contains(selectedPawn)))
{ {
Log.Warning($"Pawn {selectedPawn} still in container during OnStop, forcing removal."); ArachnaeLog.Debug($"Pawn {selectedPawn} still in container during OnStop, forcing removal.");
innerContainer.Remove(selectedPawn); innerContainer.Remove(selectedPawn);
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -73,7 +73,7 @@ namespace ArachnaeSwarm
{ {
if (selectedEntry == null) if (selectedEntry == null)
{ {
Log.Error("Tried to add to queue but selectedEntry was null."); ArachnaeLog.Debug("Tried to add to queue but selectedEntry was null.");
return; return;
} }
productionOrders.Add(new QueuedProductionOrder { entry = selectedEntry }); productionOrders.Add(new QueuedProductionOrder { entry = selectedEntry });

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Verse; using Verse;
using RimWorld; using RimWorld;
@@ -24,7 +24,7 @@ namespace ArachnaeSwarm
{ {
yield break; yield break;
} }
// 修改这里:只有当 whitelist 不为空时才检查白名单 // <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>е<EFBFBD> whitelist <20><>Ϊ<EFBFBD><CEAA>ʱ<EFBFBD>ż<EFBFBD><C5BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (Props.whitelist != null && Props.whitelist.Count > 0 && !Props.whitelist.Contains(selPawn.kindDef)) if (Props.whitelist != null && Props.whitelist.Count > 0 && !Props.whitelist.Contains(selPawn.kindDef))
{ {
yield break; yield break;
@@ -75,13 +75,13 @@ namespace ArachnaeSwarm
{ {
if (pawnKind == null) if (pawnKind == null)
{ {
Log.Warning("CompSpawnPawnFromList: Tried to spawn pawn but pawnKind is null."); ArachnaeLog.Debug("CompSpawnPawnFromList: Tried to spawn pawn but pawnKind is null.");
return; return;
} }
if (!parent.Spawned || parent.Map == null) if (!parent.Spawned || parent.Map == null)
{ {
Log.Error($"CompSpawnPawnFromList: Cannot spawn pawn. Parent {parent} is not spawned or map is null."); ArachnaeLog.Debug($"CompSpawnPawnFromList: Cannot spawn pawn. Parent {parent} is not spawned or map is null.");
return; return;
} }
@@ -91,13 +91,13 @@ namespace ArachnaeSwarm
Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKind, parent.Faction)); Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(pawnKind, parent.Faction));
if (pawn == null) if (pawn == null)
{ {
Log.Error($"CompSpawnPawnFromList: Failed to generate pawn of kind {pawnKind.defName} for faction {parent.Faction?.Name ?? "null"}."); ArachnaeLog.Debug($"CompSpawnPawnFromList: Failed to generate pawn of kind {pawnKind.defName} for faction {parent.Faction?.Name ?? "null"}.");
continue; continue;
} }
if (GenSpawn.Spawn(pawn, parent.Position, parent.Map) == null) if (GenSpawn.Spawn(pawn, parent.Position, parent.Map) == null)
{ {
Log.Error($"CompSpawnPawnFromList: Failed to spawn pawn {pawn} at {parent.Position}."); ArachnaeLog.Debug($"CompSpawnPawnFromList: Failed to spawn pawn {pawn} at {parent.Position}.");
if (!pawn.Destroyed) if (!pawn.Destroyed)
{ {
pawn.Destroy(); pawn.Destroy();
@@ -115,7 +115,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Error($"CompSpawnPawnFromList: Error creating LordJob {Props.lordJob?.Name ?? "null"} or assigning pawn {pawn}. Exception: {e}"); ArachnaeLog.Debug($"CompSpawnPawnFromList: Error creating LordJob {Props.lordJob?.Name ?? "null"} or assigning pawn {pawn}. Exception: {e}");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Linq; using System.Linq;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -38,7 +38,7 @@ namespace ArachnaeSwarm
if (productStorageComp != null) if (productStorageComp != null)
{ {
isMonitoringProductStorage = true; isMonitoringProductStorage = true;
Log.Message($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} is monitoring CompProductStorage."); ArachnaeLog.Debug($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} is monitoring CompProductStorage.");
return; return;
} }
} }
@@ -49,12 +49,12 @@ namespace ArachnaeSwarm
if (refuelableComp != null) if (refuelableComp != null)
{ {
isMonitoringProductStorage = false; isMonitoringProductStorage = false;
Log.Message($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} is monitoring CompRefuelable."); ArachnaeLog.Debug($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} is monitoring CompRefuelable.");
return; return;
} }
} }
Log.Warning($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} could not find any compatible storage component to monitor."); ArachnaeLog.Debug($"[ArachnaeSwarm] CompAutoEjector on {parent.def.defName} could not find any compatible storage component to monitor.");
} }
public override void CompTick() public override void CompTick()
@@ -95,7 +95,7 @@ namespace ArachnaeSwarm
if (thingDef == null) if (thingDef == null)
{ {
Log.Warning($"[ArachnaeSwarm] No allowed thing def found in fuel filter for {parent.def.defName}"); ArachnaeLog.Debug($"[ArachnaeSwarm] No allowed thing def found in fuel filter for {parent.def.defName}");
return; return;
} }
@@ -125,7 +125,7 @@ namespace ArachnaeSwarm
} }
} }
Log.Message($"[ArachnaeSwarm] Ejected {actualAmount} {thingDef.label} from CompProductStorage."); ArachnaeLog.Debug($"[ArachnaeSwarm] Ejected {actualAmount} {thingDef.label} from CompProductStorage.");
} }
} }
@@ -139,7 +139,7 @@ namespace ArachnaeSwarm
if (thingDef == null) if (thingDef == null)
{ {
Log.Warning($"[ArachnaeSwarm] No allowed thing def found in fuel filter for {parent.def.defName}"); ArachnaeLog.Debug($"[ArachnaeSwarm] No allowed thing def found in fuel filter for {parent.def.defName}");
return; return;
} }
@@ -174,7 +174,7 @@ namespace ArachnaeSwarm
// 发送信号 // 发送信号
parent.BroadcastCompSignal("RanOutOfFuel"); parent.BroadcastCompSignal("RanOutOfFuel");
Log.Message($"[ArachnaeSwarm] Ejected {currentFuel} {thingDef.label} from CompRefuelable."); ArachnaeLog.Debug($"[ArachnaeSwarm] Ejected {currentFuel} {thingDef.label} from CompRefuelable.");
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -102,7 +102,7 @@ namespace ArachnaeSwarm
// 记录日志(可选) // 记录日志(可选)
if (Props.logRepairs) if (Props.logRepairs)
{ {
Log.Message($"[BreakdownDisabler] Automatically repaired {parent.Label} at {parent.Position}"); ArachnaeLog.Debug($"[BreakdownDisabler] Automatically repaired {parent.Label} at {parent.Position}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
@@ -35,11 +35,11 @@ namespace ArachnaeSwarm
if (nutritionComp == null) if (nutritionComp == null)
{ {
Log.Error($"[ArachnaeSwarm] {parent.def.defName} has CompNutritionToFuelConverter but no CompRefuelableNutrition."); ArachnaeLog.Debug($"[ArachnaeSwarm] {parent.def.defName} has CompNutritionToFuelConverter but no CompRefuelableNutrition.");
} }
if (productStorageComp == null) if (productStorageComp == null)
{ {
Log.Error($"[ArachnaeSwarm] {parent.def.defName} has CompNutritionToFuelConverter but no CompProductStorage."); ArachnaeLog.Debug($"[ArachnaeSwarm] {parent.def.defName} has CompNutritionToFuelConverter but no CompProductStorage.");
} }
} }
@@ -104,11 +104,11 @@ namespace ArachnaeSwarm
workProgress -= unitsToCraft * Props.workAmount; workProgress -= unitsToCraft * Props.workAmount;
// 记录日志用于调试 // 记录日志用于调试
Log.Message($"[NutritionToFuel] Added {fuelToAdd} fuel to storage. Remaining space: {productStorageComp.StorageSpaceRemaining}"); ArachnaeLog.Debug($"[NutritionToFuel] Added {fuelToAdd} fuel to storage. Remaining space: {productStorageComp.StorageSpaceRemaining}");
} }
else else
{ {
Log.Warning($"[NutritionToFuel] Failed to add fuel to storage. Requested: {fuelToAdd}, Space: {spaceInStorage}"); ArachnaeLog.Debug($"[NutritionToFuel] Failed to add fuel to storage. Requested: {fuelToAdd}, Space: {spaceInStorage}");
} }
} }
// If spaceInStorage is 0, do nothing and let progress build up. // If spaceInStorage is 0, do nothing and let progress build up.
@@ -155,7 +155,7 @@ namespace ArachnaeSwarm
$"Nutrition Comp: {(nutritionComp != null ? "Found" : "Missing")}\n" + $"Nutrition Comp: {(nutritionComp != null ? "Found" : "Missing")}\n" +
$"Product Storage Comp: {(productStorageComp != null ? "Found" : "Missing")}"; $"Product Storage Comp: {(productStorageComp != null ? "Found" : "Missing")}";
Messages.Message(status, MessageTypeDefOf.SilentInput); Messages.Message(status, MessageTypeDefOf.SilentInput);
Log.Message(status); ArachnaeLog.Debug(status);
} }
}; };

View File

@@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Linq; using System.Linq;
@@ -47,7 +47,7 @@ namespace ArachnaeSwarm
{ {
// We found one! Store it for the Postfix. // We found one! Store it for the Postfix.
foundCustomDispenser = bestDispenser; foundCustomDispenser = bestDispenser;
Log.Message($"[ArachnaeSwarm Prefix] Found a potential custom dispenser for {eater.LabelShort}: {bestDispenser.Label}"); ArachnaeLog.Debug($"[ArachnaeSwarm Prefix] Found a potential custom dispenser for {eater.LabelShort}: {bestDispenser.Label}");
} }
// ALWAYS let the original method run. // ALWAYS let the original method run.
@@ -71,14 +71,14 @@ namespace ArachnaeSwarm
var customDispenserMealDef = foundCustomDispenser.DispensableDef; var customDispenserMealDef = foundCustomDispenser.DispensableDef;
if (customDispenserMealDef == null) if (customDispenserMealDef == null)
{ {
Log.Warning($"[ArachnaeSwarm Postfix] Custom dispenser {foundCustomDispenser.Label} has a null DispensableDef."); ArachnaeLog.Debug($"[ArachnaeSwarm Postfix] Custom dispenser {foundCustomDispenser.Label} has a null DispensableDef.");
return; return;
} }
// If the original method found NO food, then our dispenser is the best (and only) choice. // If the original method found NO food, then our dispenser is the best (and only) choice.
if (__result == null) if (__result == null)
{ {
Log.Message($"[ArachnaeSwarm Postfix] Original method found no food. Using our custom dispenser: {foundCustomDispenser.Label}"); ArachnaeLog.Debug($"[ArachnaeSwarm Postfix] Original method found no food. Using our custom dispenser: {foundCustomDispenser.Label}");
__result = foundCustomDispenser; __result = foundCustomDispenser;
foodDef = customDispenserMealDef; foodDef = customDispenserMealDef;
return; return;
@@ -89,18 +89,18 @@ namespace ArachnaeSwarm
float ourScore = FoodUtility.FoodOptimality(eater, foundCustomDispenser, customDispenserMealDef, (getter.Position - foundCustomDispenser.Position).LengthManhattan); float ourScore = FoodUtility.FoodOptimality(eater, foundCustomDispenser, customDispenserMealDef, (getter.Position - foundCustomDispenser.Position).LengthManhattan);
float theirScore = FoodUtility.FoodOptimality(eater, __result, foodDef, (getter.Position - __result.Position).LengthManhattan); float theirScore = FoodUtility.FoodOptimality(eater, __result, foodDef, (getter.Position - __result.Position).LengthManhattan);
Log.Message($"[ArachnaeSwarm Postfix] Comparing food sources: Our Dispenser (Score: {ourScore:F2}) vs Original Result '{__result.Label}' (Score: {theirScore:F2})."); ArachnaeLog.Debug($"[ArachnaeSwarm Postfix] Comparing food sources: Our Dispenser (Score: {ourScore:F2}) vs Original Result '{__result.Label}' (Score: {theirScore:F2}).");
// If our dispenser is a better choice, override the result. // If our dispenser is a better choice, override the result.
if (ourScore > theirScore) if (ourScore > theirScore)
{ {
Log.Message($"[ArachnaeSwarm Postfix] Our dispenser is better. Overriding result."); ArachnaeLog.Debug($"[ArachnaeSwarm Postfix] Our dispenser is better. Overriding result.");
__result = foundCustomDispenser; __result = foundCustomDispenser;
foodDef = customDispenserMealDef; foodDef = customDispenserMealDef;
} }
else else
{ {
Log.Message($"[ArachnaeSwarm Postfix] Original result is better or equal. Keeping it."); ArachnaeLog.Debug($"[ArachnaeSwarm Postfix] Original result is better or equal. Keeping it.");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld.Planet; using RimWorld.Planet;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
using RimWorld; using RimWorld;
@@ -45,7 +45,7 @@ namespace ArachnaeSwarm
// Safety check: if the destination is invalid, log an error and remove the missile. // Safety check: if the destination is invalid, log an error and remove the missile.
if (this.destinationTile < 0) if (this.destinationTile < 0)
{ {
Log.Error("CatastropheMissile spawned with an invalid destination tile. Removing."); ArachnaeLog.Debug("CatastropheMissile spawned with an invalid destination tile. Removing.");
Find.WorldObjects.Remove(this); Find.WorldObjects.Remove(this);
return; return;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
@@ -180,7 +180,7 @@ namespace ArachnaeSwarm
// 验证幼虫种族 // 验证幼虫种族
if (larva.def.defName != "ArachnaeBase_Race_Larva") if (larva.def.defName != "ArachnaeBase_Race_Larva")
{ {
Log.Warning($"Invalid larva arrived: {larva.def.defName}"); ArachnaeLog.Debug($"Invalid larva arrived: {larva.def.defName}");
return; return;
} }
@@ -198,14 +198,14 @@ namespace ArachnaeSwarm
// 验证是当前分配的幼虫 // 验证是当前分配的幼虫
if (larva != assignedLarva) if (larva != assignedLarva)
{ {
Log.Warning("Larva operation complete called with wrong larva."); ArachnaeLog.Debug("Larva operation complete called with wrong larva.");
return; return;
} }
var config = IncubatorData?.SelectedConfig; var config = IncubatorData?.SelectedConfig;
if (config == null) if (config == null)
{ {
Log.Error("No incubation config selected when larva completed operation."); ArachnaeLog.Debug("No incubation config selected when larva completed operation.");
return; return;
} }

View File

@@ -324,7 +324,7 @@ namespace ArachnaeSwarm
// 检查是否有攻击动词 // 检查是否有攻击动词
if (currentEffectiveVerb == null) if (currentEffectiveVerb == null)
{ {
Log.Error("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb."); ArachnaeLog.Debug("BestShootTargetFromCurrentPosition with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
return null; return null;
} }
@@ -376,7 +376,7 @@ namespace ArachnaeSwarm
// 验证攻击动词是否存在 // 验证攻击动词是否存在
if (verb == null) if (verb == null)
{ {
Log.Error("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb."); ArachnaeLog.Debug("BestAttackTarget with " + searcher.ToStringSafe<IAttackTargetSearcher>() + " who has no attack verb.");
return null; return null;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using RimWorld.Planet; using RimWorld.Planet;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
@@ -99,7 +99,7 @@ namespace ArachnaeSwarm
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
{ {
Log.Message($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) is despawning. Notifying and destroying Portal B ({linkedPortalB?.GetUniqueLoadID() ?? "null"})."); ArachnaeLog.Debug($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) is despawning. Notifying and destroying Portal B ({linkedPortalB?.GetUniqueLoadID() ?? "null"}).");
if (linkedPortalB != null && !linkedPortalB.Destroyed) if (linkedPortalB != null && !linkedPortalB.Destroyed)
{ {
linkedPortalB.Notify_A_Destroyed(); linkedPortalB.Notify_A_Destroyed();
@@ -115,7 +115,7 @@ namespace ArachnaeSwarm
Notify_B_Destroyed(); Notify_B_Destroyed();
return; return;
} }
Log.Message($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) is linking to Portal B ({portalB?.GetUniqueLoadID() ?? "null"})."); ArachnaeLog.Debug($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) is linking to Portal B ({portalB?.GetUniqueLoadID() ?? "null"}).");
linkedPortalB = portalB; linkedPortalB = portalB;
status = WormholePortalStatus.Linked; status = WormholePortalStatus.Linked;
Messages.Message("WormholePortalLinked".Translate(this.Label, portalB.Map.Parent.LabelCap), this, MessageTypeDefOf.PositiveEvent); Messages.Message("WormholePortalLinked".Translate(this.Label, portalB.Map.Parent.LabelCap), this, MessageTypeDefOf.PositiveEvent);
@@ -123,7 +123,7 @@ namespace ArachnaeSwarm
public void Notify_B_Destroyed() public void Notify_B_Destroyed()
{ {
Log.Warning($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) received notification that Portal B was destroyed. Resetting status to Idle."); ArachnaeLog.Debug($"[ArachnaeSwarm] Portal A ({this.GetUniqueLoadID()}) received notification that Portal B was destroyed. Resetting status to Idle.");
linkedPortalB = null; linkedPortalB = null;
status = WormholePortalStatus.Idle; status = WormholePortalStatus.Idle;
Messages.Message("WormholePortalB_Destroyed".Translate(this.Label), this, MessageTypeDefOf.NegativeEvent); Messages.Message("WormholePortalB_Destroyed".Translate(this.Label), this, MessageTypeDefOf.NegativeEvent);

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using RimWorld.Planet; using RimWorld.Planet;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
@@ -20,7 +20,7 @@ namespace ArachnaeSwarm
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish)
{ {
// 如果B被摧毁通知A // 如果B被摧毁通知A
Log.Warning($"[ArachnaeSwarm] Portal B ({this.GetUniqueLoadID()}) is despawning. Notifying Portal A ({linkedPortalA?.GetUniqueLoadID() ?? "null"})."); ArachnaeLog.Debug($"[ArachnaeSwarm] Portal B ({this.GetUniqueLoadID()}) is despawning. Notifying Portal A ({linkedPortalA?.GetUniqueLoadID() ?? "null"}).");
if (linkedPortalA != null && !linkedPortalA.Destroyed) if (linkedPortalA != null && !linkedPortalA.Destroyed)
{ {
linkedPortalA.Notify_B_Destroyed(); linkedPortalA.Notify_B_Destroyed();
@@ -36,7 +36,7 @@ namespace ArachnaeSwarm
public void SetLinkedPortal(Building_WormholePortal_A portalA) public void SetLinkedPortal(Building_WormholePortal_A portalA)
{ {
Log.Message($"[ArachnaeSwarm] Portal B ({this.GetUniqueLoadID()}) is linking to Portal A ({portalA?.GetUniqueLoadID() ?? "null"})."); ArachnaeLog.Debug($"[ArachnaeSwarm] Portal B ({this.GetUniqueLoadID()}) is linking to Portal A ({portalA?.GetUniqueLoadID() ?? "null"}).");
linkedPortalA = portalA; linkedPortalA = portalA;
} }

View File

@@ -1,4 +1,4 @@
using System; // Required for Activator using System; // Required for Activator
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
@@ -51,7 +51,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'."); ArachnaeLog.Debug($"[CompOpenCustomUI] Could not find EventDef named '{Props.uiDefName}'.");
} }
}); });

View File

@@ -1,4 +1,4 @@
using Verse; using Verse;
using RimWorld; using RimWorld;
namespace ArachnaeSwarm namespace ArachnaeSwarm
@@ -58,7 +58,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Warning($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}"); ArachnaeLog.Debug($"[EventSystem] Condition_VariableEquals: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
reason = "Type mismatch or parsing error during comparison."; reason = "Type mismatch or parsing error during comparison.";
return false; return false;
} }
@@ -89,7 +89,7 @@ namespace ArachnaeSwarm
var eventVarManager = Find.World.GetComponent<EventVariableManager>(); var eventVarManager = Find.World.GetComponent<EventVariableManager>();
if (!eventVarManager.HasVariable(name)) if (!eventVarManager.HasVariable(name))
{ {
Log.Message($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f."); ArachnaeLog.Debug($"[EventSystem] {GetType().Name}: Variable '{name}' not found, defaulting to 0f.");
eventVarManager.SetVariable(name, 0f); eventVarManager.SetVariable(name, 0f);
} }
@@ -102,13 +102,13 @@ namespace ArachnaeSwarm
if (float.IsNaN(compareValue)) if (float.IsNaN(compareValue))
{ {
reason = $"Comparison variable '{valueVariableName}' not set or not a number."; reason = $"Comparison variable '{valueVariableName}' not set or not a number.";
Log.Warning($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}"); ArachnaeLog.Debug($"[EventSystem] {GetType().Name} check for '{name}' failed: {reason}");
return false; return false;
} }
} }
bool met = Compare(variable, compareValue); bool met = Compare(variable, compareValue);
Log.Message($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}"); ArachnaeLog.Debug($"[EventSystem] {GetType().Name} check: Name='{name}', CurrentValue='{variable}', CompareValue='{compareValue}', Met={met}");
if (!met) if (!met)
{ {
reason = $"Requires {name} {GetOperatorString()} {compareValue} (Current: {variable})"; reason = $"Requires {name} {GetOperatorString()} {compareValue} (Current: {variable})";
@@ -195,12 +195,12 @@ namespace ArachnaeSwarm
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Warning($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}"); ArachnaeLog.Debug($"[EventSystem] Condition_VariableNotEqual: Could not compare '{variable}' and '{compareValueStr}'. Error: {e.Message}");
reason = "Type mismatch or parsing error during comparison."; reason = "Type mismatch or parsing error during comparison.";
return false; return false;
} }
Log.Message($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}"); ArachnaeLog.Debug($"[EventSystem] Condition_VariableNotEqual check: Name='{name}', Type='{variable?.GetType().Name ?? "null"}', CurrentValue='{variable}', CompareValue='{compareValueStr}', Met={met}");
if (!met) if (!met)
{ {
reason = $"Requires {name} != {compareValueStr} (Current: {variable})"; reason = $"Requires {name} != {compareValueStr} (Current: {variable})";

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using RimWorld.Planet; using RimWorld.Planet;
@@ -60,7 +60,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}"); ArachnaeLog.Debug($"[WulaFallenEmpire] Error executing delayed action for event '{delayedAction.eventDefName}': {ex}");
} }
actions.RemoveAt(i); actions.RemoveAt(i);
} }
@@ -78,7 +78,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'"); ArachnaeLog.Debug($"[WulaFallenEmpire] DelayedActionManager could not find EventDef named '{defName}'");
} }
} }

View File

@@ -1,4 +1,4 @@
using System; // Required for Activator using System; // Required for Activator
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@@ -29,7 +29,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening."); ArachnaeLog.Debug("[WulaFallenEmpire] DelayedActionManager not found. Cannot schedule delayed UI opening.");
} }
} }
else else
@@ -64,7 +64,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'"); ArachnaeLog.Debug($"[WulaFallenEmpire] Effect_OpenCustomUI could not find EventDef named '{defName}'");
} }
} }
@@ -119,7 +119,7 @@ namespace ArachnaeSwarm
{ {
if (incident == null) if (incident == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_FireIncident has a null incident Def."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_FireIncident has a null incident Def.");
return; return;
} }
@@ -131,7 +131,7 @@ namespace ArachnaeSwarm
if (!incident.Worker.TryExecute(parms)) if (!incident.Worker.TryExecute(parms))
{ {
Log.Error($"[WulaFallenEmpire] Could not fire incident {incident.defName}"); ArachnaeLog.Debug($"[WulaFallenEmpire] Could not fire incident {incident.defName}");
} }
} }
} }
@@ -145,14 +145,14 @@ namespace ArachnaeSwarm
{ {
if (faction == null) if (faction == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation has a null faction Def.");
return; return;
} }
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction); Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
if (targetFaction == null) if (targetFaction == null)
{ {
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'."); ArachnaeLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
return; return;
} }
@@ -204,14 +204,14 @@ namespace ArachnaeSwarm
{ {
if (faction == null) if (faction == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_ChangeFactionRelation_FromVariable has a null faction Def.");
return; return;
} }
Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction); Faction targetFaction = Find.FactionManager.FirstFactionOfDef(faction);
if (targetFaction == null) if (targetFaction == null)
{ {
Log.Warning($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'."); ArachnaeLog.Debug($"[WulaFallenEmpire] Could not find an active faction for FactionDef '{faction.defName}'.");
return; return;
} }
@@ -230,12 +230,12 @@ namespace ArachnaeSwarm
{ {
if (kindDef == null) if (kindDef == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore has a null kindDef.");
return; return;
} }
if (storeAs.NullOrEmpty()) if (storeAs.NullOrEmpty())
{ {
Log.Error("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_SpawnPawnAndStore needs a 'storeAs' variable name.");
return; return;
} }
@@ -269,14 +269,14 @@ namespace ArachnaeSwarm
{ {
if (thingDef == null) if (thingDef == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_GiveThing has a null thingDef."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_GiveThing has a null thingDef.");
return; return;
} }
Map currentMap = Find.CurrentMap; Map currentMap = Find.CurrentMap;
if (currentMap == null) if (currentMap == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_GiveThing cannot execute without a current map.");
return; return;
} }
@@ -303,14 +303,14 @@ namespace ArachnaeSwarm
{ {
if (kindDef == null) if (kindDef == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn has a null kindDef.");
return; return;
} }
Map map = Find.CurrentMap; Map map = Find.CurrentMap;
if (map == null) if (map == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_SpawnPawn cannot execute without a current map.");
return; return;
} }
@@ -361,7 +361,7 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
Log.Error("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_ModifyVariable has a null or empty name.");
return; return;
} }
@@ -374,7 +374,7 @@ namespace ArachnaeSwarm
valueStr = eventVarManager.GetVariable<object>(valueVariableName)?.ToString(); valueStr = eventVarManager.GetVariable<object>(valueVariableName)?.ToString();
if (valueStr == null) if (valueStr == null)
{ {
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found."); ArachnaeLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: valueVariableName '{valueVariableName}' not found.");
return; return;
} }
} }
@@ -383,7 +383,7 @@ namespace ArachnaeSwarm
object variable = eventVarManager.GetVariable<object>(name); object variable = eventVarManager.GetVariable<object>(name);
if (variable == null) if (variable == null)
{ {
Log.Message($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0."); ArachnaeLog.Debug($"[EventSystem] Effect_ModifyVariable: Variable '{name}' not found, initializing to 0.");
variable = 0; variable = 0;
} }
@@ -406,12 +406,12 @@ namespace ArachnaeSwarm
newValue = Modify(currentVal, modVal, operation); newValue = Modify(currentVal, modVal, operation);
} }
Log.Message($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}"); ArachnaeLog.Debug($"[EventSystem] Modifying variable '{name}'. Operation: {operation}. Value: {valueStr}. From: {originalValue} To: {newValue}");
eventVarManager.SetVariable(name, newValue); eventVarManager.SetVariable(name, newValue);
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}"); ArachnaeLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable: Could not parse or operate on value '{valueStr}' for variable '{name}'. Error: {e.Message}");
} }
} }
@@ -424,7 +424,7 @@ namespace ArachnaeSwarm
case VariableOperation.Multiply: return current * modifier; case VariableOperation.Multiply: return current * modifier;
case VariableOperation.Divide: case VariableOperation.Divide:
if (modifier != 0) return current / modifier; if (modifier != 0) return current / modifier;
Log.Error($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero."); ArachnaeLog.Debug($"[WulaFallenEmpire] Effect_ModifyVariable tried to divide by zero.");
return current; return current;
default: return current; default: return current;
} }
@@ -439,7 +439,7 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
Log.Error("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_ClearVariable has a null or empty name.");
return; return;
} }
Find.World.GetComponent<EventVariableManager>().ClearVariable(name); Find.World.GetComponent<EventVariableManager>().ClearVariable(name);
@@ -454,7 +454,7 @@ namespace ArachnaeSwarm
{ {
if (quest == null) if (quest == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_AddQuest has a null quest Def."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_AddQuest has a null quest Def.");
return; return;
} }
@@ -473,7 +473,7 @@ namespace ArachnaeSwarm
{ {
if (research == null) if (research == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_FinishResearch has a null research Def."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_FinishResearch has a null research Def.");
return; return;
} }
@@ -496,14 +496,14 @@ namespace ArachnaeSwarm
Map map = Find.CurrentMap; Map map = Find.CurrentMap;
if (map == null) if (map == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid cannot execute without a current map.");
return; return;
} }
Faction factionInst = Find.FactionManager.FirstFactionOfDef(this.faction); Faction factionInst = Find.FactionManager.FirstFactionOfDef(this.faction);
if (factionInst == null) if (factionInst == null)
{ {
Log.Error($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'."); ArachnaeLog.Debug($"[WulaFallenEmpire] Effect_TriggerRaid could not find an active faction for FactionDef '{this.faction?.defName}'.");
return; return;
} }
@@ -520,7 +520,7 @@ namespace ArachnaeSwarm
if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile)) if (!RCellFinder.TryFindRandomPawnEntryCell(out parms.spawnCenter, map, CellFinder.EdgeRoadChance_Hostile))
{ {
Log.Error("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_TriggerRaid could not find a valid spawn center.");
return; return;
} }
@@ -568,7 +568,7 @@ namespace ArachnaeSwarm
{ {
if (factionDef == null || string.IsNullOrEmpty(variableName)) if (factionDef == null || string.IsNullOrEmpty(variableName))
{ {
Log.Error("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_CheckFactionGoodwill is not configured correctly.");
return; return;
} }
@@ -578,12 +578,12 @@ namespace ArachnaeSwarm
if (faction != null) if (faction != null)
{ {
int goodwill = faction.GoodwillWith(Faction.OfPlayer); int goodwill = faction.GoodwillWith(Faction.OfPlayer);
Log.Message($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'."); ArachnaeLog.Debug($"[EventSystem] Storing goodwill for faction '{faction.Name}' ({goodwill}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, goodwill); eventVarManager.SetVariable(variableName, goodwill);
} }
else else
{ {
Log.Warning($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'."); ArachnaeLog.Debug($"[EventSystem] Effect_CheckFactionGoodwill: Faction '{factionDef.defName}' not found. Storing 0 in variable '{variableName}'.");
eventVarManager.SetVariable(variableName, 0); eventVarManager.SetVariable(variableName, 0);
} }
} }
@@ -597,13 +597,13 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(variableName)) if (string.IsNullOrEmpty(variableName))
{ {
Log.Error("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName)."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_StoreRealPlayTime is not configured correctly (missing variableName).");
return; return;
} }
var eventVarManager = Find.World.GetComponent<EventVariableManager>(); var eventVarManager = Find.World.GetComponent<EventVariableManager>();
float realPlayTime = Find.GameInfo.RealPlayTimeInteracting; float realPlayTime = Find.GameInfo.RealPlayTimeInteracting;
Log.Message($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'."); ArachnaeLog.Debug($"[EventSystem] Storing real play time ({realPlayTime}s) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, realPlayTime); eventVarManager.SetVariable(variableName, realPlayTime);
} }
} }
@@ -616,13 +616,13 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(variableName)) if (string.IsNullOrEmpty(variableName))
{ {
Log.Error("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName)."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_StoreDaysPassed is not configured correctly (missing variableName).");
return; return;
} }
var eventVarManager = Find.World.GetComponent<EventVariableManager>(); var eventVarManager = Find.World.GetComponent<EventVariableManager>();
int daysPassed = GenDate.DaysPassed; int daysPassed = GenDate.DaysPassed;
Log.Message($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'."); ArachnaeLog.Debug($"[EventSystem] Storing days passed ({daysPassed}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, daysPassed); eventVarManager.SetVariable(variableName, daysPassed);
} }
} }
@@ -635,20 +635,20 @@ namespace ArachnaeSwarm
{ {
if (string.IsNullOrEmpty(variableName)) if (string.IsNullOrEmpty(variableName))
{ {
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName)."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth is not configured correctly (missing variableName).");
return; return;
} }
Map currentMap = Find.CurrentMap; Map currentMap = Find.CurrentMap;
if (currentMap == null) if (currentMap == null)
{ {
Log.Error("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map."); ArachnaeLog.Debug("[WulaFallenEmpire] Effect_StoreColonyWealth cannot execute without a current map.");
return; return;
} }
var eventVarManager = Find.World.GetComponent<EventVariableManager>(); var eventVarManager = Find.World.GetComponent<EventVariableManager>();
float wealth = currentMap.wealthWatcher.WealthTotal; float wealth = currentMap.wealthWatcher.WealthTotal;
Log.Message($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'."); ArachnaeLog.Debug($"[EventSystem] Storing colony wealth ({wealth}) into variable '{variableName}'.");
eventVarManager.SetVariable(variableName, wealth); eventVarManager.SetVariable(variableName, wealth);
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
using RimWorld; using RimWorld;
using RimWorld.Planet; using RimWorld.Planet;
@@ -49,7 +49,7 @@ namespace ArachnaeSwarm
if (string.IsNullOrEmpty(name)) return; if (string.IsNullOrEmpty(name)) return;
// Log the variable change // Log the variable change
Log.Message($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}."); ArachnaeLog.Debug($"[EventSystem] Setting variable '{name}' to value '{value}' of type {value?.GetType().Name ?? "null"}.");
// Clear any existing variable with the same name to prevent type confusion // Clear any existing variable with the same name to prevent type confusion
ClearVariable(name); ClearVariable(name);
@@ -77,7 +77,7 @@ namespace ArachnaeSwarm
else if (value != null) else if (value != null)
{ {
stringVars[name] = value.ToString(); stringVars[name] = value.ToString();
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior."); ArachnaeLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} was converted to string for storage. This may lead to unexpected behavior.");
} }
} }
@@ -124,7 +124,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception e) catch (System.Exception e)
{ {
Log.Warning($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}"); ArachnaeLog.Debug($"[WulaFallenEmpire] EventVariableManager: Variable '{name}' of type {value.GetType()} could not be converted to {typeof(T)}. Error: {e.Message}");
return defaultValue; return defaultValue;
} }
} }
@@ -145,7 +145,7 @@ namespace ArachnaeSwarm
{ {
if (HasVariable(name)) if (HasVariable(name))
{ {
Log.Message($"[EventSystem] Clearing variable '{name}'."); ArachnaeLog.Debug($"[EventSystem] Clearing variable '{name}'.");
} }
intVars.Remove(name); intVars.Remove(name);
floatVars.Remove(name); floatVars.Remove(name);

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -19,7 +19,7 @@ namespace ArachnaeSwarm
// 检查 Nals.FacialAnimation 是否被加载 // 检查 Nals.FacialAnimation 是否被加载
if (!LoadedModManager.RunningMods.Any(m => m.PackageId == "Nals.FacialAnimation")) if (!LoadedModManager.RunningMods.Any(m => m.PackageId == "Nals.FacialAnimation"))
{ {
Log.Message("[Arachnae Swarm] Facial Animation mod not found. Skipping animation file generation."); ArachnaeLog.Debug("[Arachnae Swarm] Facial Animation mod not found. Skipping animation file generation.");
return; // 如果未加载,则直接退出,不执行任何操作 return; // 如果未加载,则直接退出,不执行任何操作
} }
@@ -34,7 +34,7 @@ namespace ArachnaeSwarm
string modRootDir = GetModRootDirectory(); string modRootDir = GetModRootDirectory();
if (string.IsNullOrEmpty(modRootDir)) if (string.IsNullOrEmpty(modRootDir))
{ {
Log.Error("Cannot find mod root directory"); ArachnaeLog.Debug("Cannot find mod root directory");
return; return;
} }
@@ -93,7 +93,7 @@ namespace ArachnaeSwarm
// 检查种族是否存在 // 检查种族是否存在
if (DefDatabase<ThingDef>.GetNamedSilentFail(raceDefName) == null) if (DefDatabase<ThingDef>.GetNamedSilentFail(raceDefName) == null)
{ {
Log.Warning($"Race {raceDefName} not found, skipping face animation generation"); ArachnaeLog.Debug($"Race {raceDefName} not found, skipping face animation generation");
continue; continue;
} }
@@ -104,11 +104,11 @@ namespace ArachnaeSwarm
} }
} }
Log.Message($"Generated {totalFilesGenerated} face animation files in {fullOutputDir}"); ArachnaeLog.Debug($"Generated {totalFilesGenerated} face animation files in {fullOutputDir}");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in FaceAnimationFileGenerator: {ex}"); ArachnaeLog.Debug($"Error in FaceAnimationFileGenerator: {ex}");
} }
} }
@@ -146,12 +146,12 @@ namespace ArachnaeSwarm
} }
} }
Log.Error("Cannot determine mod root directory"); ArachnaeLog.Debug("Cannot determine mod root directory");
return null; return null;
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error getting mod root directory: {ex}"); ArachnaeLog.Debug($"Error getting mod root directory: {ex}");
return null; return null;
} }
} }
@@ -165,7 +165,7 @@ namespace ArachnaeSwarm
// 检查源文件是否存在 // 检查源文件是否存在
if (!File.Exists(sourcePath)) if (!File.Exists(sourcePath))
{ {
Log.Warning($"Source animation file not found: {sourcePath}"); ArachnaeLog.Debug($"Source animation file not found: {sourcePath}");
return 0; return 0;
} }
@@ -176,7 +176,7 @@ namespace ArachnaeSwarm
if (abstractDefNodes == null || abstractDefNodes.Count == 0) if (abstractDefNodes == null || abstractDefNodes.Count == 0)
{ {
Log.Message($"No abstract FaceAnimationDef found in: {sourcePath}"); ArachnaeLog.Debug($"No abstract FaceAnimationDef found in: {sourcePath}");
return 0; return 0;
} }
@@ -201,11 +201,11 @@ namespace ArachnaeSwarm
writer.WriteLine("</Defs>"); writer.WriteLine("</Defs>");
} }
Log.Message($"Generated {filesGenerated} animations for {raceDefName} in {outputFile}"); ArachnaeLog.Debug($"Generated {filesGenerated} animations for {raceDefName} in {outputFile}");
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error generating animation files for race {raceDefName}: {ex}"); ArachnaeLog.Debug($"Error generating animation files for race {raceDefName}: {ex}");
} }
return filesGenerated; return filesGenerated;
@@ -218,7 +218,7 @@ namespace ArachnaeSwarm
string abstractName = abstractNode.Attributes?["Name"]?.Value; string abstractName = abstractNode.Attributes?["Name"]?.Value;
if (string.IsNullOrEmpty(abstractName)) if (string.IsNullOrEmpty(abstractName))
{ {
Log.Warning("Abstract FaceAnimationDef has no Name attribute"); ArachnaeLog.Debug("Abstract FaceAnimationDef has no Name attribute");
return null; return null;
} }
@@ -236,7 +236,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error generating XML for {raceDefName}: {ex}"); ArachnaeLog.Debug($"Error generating XML for {raceDefName}: {ex}");
return null; return null;
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using RimWorld.Planet; using RimWorld.Planet;
using System.Collections.Generic; using System.Collections.Generic;
@@ -31,7 +31,7 @@ namespace ArachnaeSwarm
if (aircraftManager == null) if (aircraftManager == null)
{ {
Log.Error("AircraftManagerNotFound".Translate()); ArachnaeLog.Debug("AircraftManagerNotFound".Translate());
return; return;
} }
@@ -40,12 +40,12 @@ namespace ArachnaeSwarm
{ {
// 成功消耗战机,发送消息 // 成功消耗战机,发送消息
Messages.Message("AircraftStrikeInitiated".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.PositiveEvent); Messages.Message("AircraftStrikeInitiated".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.PositiveEvent);
Log.Message("AircraftStrikeSuccess".Translate(Props.aircraftsPerUse, Props.requiredAircraftType.LabelCap)); ArachnaeLog.Debug("AircraftStrikeSuccess".Translate(Props.aircraftsPerUse, Props.requiredAircraftType.LabelCap));
} }
else else
{ {
Messages.Message("NoAvailableAircraft".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.NegativeEvent); Messages.Message("NoAvailableAircraft".Translate(Props.requiredAircraftType.LabelCap), MessageTypeDefOf.NegativeEvent);
Log.Warning("AircraftStrikeFailed".Translate(Props.requiredAircraftType.LabelCap, parent.pawn.Faction?.Name ?? "UnknownFaction".Translate())); ArachnaeLog.Debug("AircraftStrikeFailed".Translate(Props.requiredAircraftType.LabelCap, parent.pawn.Faction?.Name ?? "UnknownFaction".Translate()));
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld.Planet; using RimWorld.Planet;
@@ -53,7 +53,7 @@ namespace ArachnaeSwarm
if (aircraftManager == null) if (aircraftManager == null)
{ {
Log.Error("AircraftManagerNotFound".Translate()); ArachnaeLog.Debug("AircraftManagerNotFound".Translate());
return; return;
} }
@@ -92,21 +92,21 @@ namespace ArachnaeSwarm
// 检查地图是否有效 // 检查地图是否有效
if (parent.Map == null) if (parent.Map == null)
{ {
Log.Error("TakeoffEffectMapNull".Translate()); ArachnaeLog.Debug("TakeoffEffectMapNull".Translate());
return; return;
} }
// 生成 Skyfaller // 生成 Skyfaller
GenSpawn.Spawn(skyfaller, takeoffPos, parent.Map); GenSpawn.Spawn(skyfaller, takeoffPos, parent.Map);
Log.Message("TakeoffSkyfallerCreated".Translate(takeoffPos)); ArachnaeLog.Debug("TakeoffSkyfallerCreated".Translate(takeoffPos));
// 销毁原建筑 // 销毁原建筑
parent.Destroy(DestroyMode.Vanish); parent.Destroy(DestroyMode.Vanish);
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error("TakeoffEffectError".Translate(ex.Message)); ArachnaeLog.Debug("TakeoffEffectError".Translate(ex.Message));
// 如果Skyfaller创建失败直接销毁建筑 // 如果Skyfaller创建失败直接销毁建筑
parent.Destroy(DestroyMode.Vanish); parent.Destroy(DestroyMode.Vanish);
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld.Planet; using RimWorld.Planet;
@@ -65,11 +65,11 @@ namespace ArachnaeSwarm
// 调试日志 // 调试日志
if (Scribe.mode == LoadSaveMode.Saving) if (Scribe.mode == LoadSaveMode.Saving)
{ {
Log.Message($"Saving aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events"); ArachnaeLog.Debug($"Saving aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
} }
else if (Scribe.mode == LoadSaveMode.PostLoadInit) else if (Scribe.mode == LoadSaveMode.PostLoadInit)
{ {
Log.Message($"Loaded aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events"); ArachnaeLog.Debug($"Loaded aircraft data: {allFactionAircraftData.Count} faction entries, {cooldownEvents.Count} cooldown events");
} }
} }
@@ -120,7 +120,7 @@ namespace ArachnaeSwarm
{ {
if (faction == null) if (faction == null)
{ {
Log.Error("AddAircraftNullFaction".Translate()); ArachnaeLog.Debug("AddAircraftNullFaction".Translate());
return; return;
} }
@@ -128,7 +128,7 @@ namespace ArachnaeSwarm
data.totalCount += count; data.totalCount += count;
data.availableCount += count; data.availableCount += count;
Log.Message($"Added {count} {aircraftDef.LabelCap} to {faction.Name}. Total: {data.totalCount}, Available: {data.availableCount}"); ArachnaeLog.Debug($"Added {count} {aircraftDef.LabelCap} to {faction.Name}. Total: {data.totalCount}, Available: {data.availableCount}");
} }
// 尝试使用战机 // 尝试使用战机
@@ -150,7 +150,7 @@ namespace ArachnaeSwarm
cooldownEvents.Add(cooldownEvent); cooldownEvents.Add(cooldownEvent);
Log.Message($"Used {count} {aircraftDef.LabelCap} from {faction.Name}. Available now: {data.availableCount}, Cooldown until: {cooldownEvent.endTick}"); ArachnaeLog.Debug($"Used {count} {aircraftDef.LabelCap} from {faction.Name}. Available now: {data.availableCount}, Cooldown until: {cooldownEvent.endTick}");
return true; return true;
} }
@@ -187,7 +187,7 @@ namespace ArachnaeSwarm
if (cooldownEvent.aircraftDef != null) if (cooldownEvent.aircraftDef != null)
{ {
Messages.Message("AircraftCooldownEnded".Translate(cooldownEvent.aircraftDef.LabelCap), MessageTypeDefOf.PositiveEvent); Messages.Message("AircraftCooldownEnded".Translate(cooldownEvent.aircraftDef.LabelCap), MessageTypeDefOf.PositiveEvent);
Log.Message($"Cooldown ended for {cooldownEvent.aircraftCount} {cooldownEvent.aircraftDef.LabelCap}. Available now: {data.availableCount}"); ArachnaeLog.Debug($"Cooldown ended for {cooldownEvent.aircraftCount} {cooldownEvent.aircraftDef.LabelCap}. Available now: {data.availableCount}");
} }
} }
} }
@@ -203,22 +203,22 @@ namespace ArachnaeSwarm
// 调试方法:显示当前状态 // 调试方法:显示当前状态
public void DebugLogStatus() public void DebugLogStatus()
{ {
Log.Message("=== Aircraft Manager Status ==="); ArachnaeLog.Debug("=== Aircraft Manager Status ===");
Log.Message($"Total faction entries: {allFactionAircraftData.Count}"); ArachnaeLog.Debug($"Total faction entries: {allFactionAircraftData.Count}");
var factions = allFactionAircraftData.Select(x => x.faction).Distinct(); var factions = allFactionAircraftData.Select(x => x.faction).Distinct();
foreach (var faction in factions) foreach (var faction in factions)
{ {
Log.Message($"Faction: {faction?.Name ?? "Unknown"}"); ArachnaeLog.Debug($"Faction: {faction?.Name ?? "Unknown"}");
var factionData = allFactionAircraftData.Where(x => x.faction == faction); var factionData = allFactionAircraftData.Where(x => x.faction == faction);
foreach (var data in factionData) foreach (var data in factionData)
{ {
Log.Message($" {data.aircraftDef.LabelCap}: {data.availableCount}/{data.totalCount} available"); ArachnaeLog.Debug($" {data.aircraftDef.LabelCap}: {data.availableCount}/{data.totalCount} available");
} }
} }
Log.Message($"Active cooldown events: {cooldownEvents.Count}"); ArachnaeLog.Debug($"Active cooldown events: {cooldownEvents.Count}");
Log.Message("==============================="); ArachnaeLog.Debug("===============================");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
@@ -127,14 +127,14 @@ namespace ArachnaeSwarm
if (Props.useCyclicDrops) if (Props.useCyclicDrops)
{ {
ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f); // 1小时 = 2500 ticks ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f); // 1小时 = 2500 ticks
Log.Message($"Cyclic drops initialized: {Props.cyclicDropIntervalHours} hours interval"); ArachnaeLog.Debug($"Cyclic drops initialized: {Props.cyclicDropIntervalHours} hours interval");
} }
// 初始化信号等待状态 // 初始化信号等待状态
if (Props.waitForExternalSignal) if (Props.waitForExternalSignal)
{ {
waitingForSignal = true; waitingForSignal = true;
Log.Message($"Waiting for external signal: {Props.externalSignalTag}"); ArachnaeLog.Debug($"Waiting for external signal: {Props.externalSignalTag}");
} }
} }
@@ -151,7 +151,7 @@ namespace ArachnaeSwarm
if (pawn != null) if (pawn != null)
{ {
pawns.Add(pawn); pawns.Add(pawn);
Log.Message($"Generated pawn: {pawn.Label} ({pawnKindCount.pawnKindDef.defName})"); ArachnaeLog.Debug($"Generated pawn: {pawn.Label} ({pawnKindCount.pawnKindDef.defName})");
} }
} }
} }
@@ -162,7 +162,7 @@ namespace ArachnaeSwarm
{ {
if (pawnKindDef == null) if (pawnKindDef == null)
{ {
Log.Error("Attempted to generate pawn with null PawnKindDef"); ArachnaeLog.Debug("Attempted to generate pawn with null PawnKindDef");
return null; return null;
} }
@@ -213,12 +213,12 @@ namespace ArachnaeSwarm
pawn.mindState.SetupLastHumanMeatTick(); pawn.mindState.SetupLastHumanMeatTick();
} }
Log.Message($"Successfully generated pawn: {pawn.LabelCap} from {pawnKindDef.defName}"); ArachnaeLog.Debug($"Successfully generated pawn: {pawn.LabelCap} from {pawnKindDef.defName}");
return pawn; return pawn;
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Failed to generate pawn from {pawnKindDef.defName}: {ex}"); ArachnaeLog.Debug($"Failed to generate pawn from {pawnKindDef.defName}: {ex}");
return null; return null;
} }
} }
@@ -282,7 +282,7 @@ namespace ArachnaeSwarm
// 重置计时器 // 重置计时器
ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f); ticksUntilNextDrop = (int)(Props.cyclicDropIntervalHours * 2500f);
Log.Message($"Cyclic drop completed, next drop in {Props.cyclicDropIntervalHours} hours"); ArachnaeLog.Debug($"Cyclic drop completed, next drop in {Props.cyclicDropIntervalHours} hours");
} }
} }
@@ -291,7 +291,7 @@ namespace ArachnaeSwarm
{ {
if (parent is FlyOver flyOver && waitingForSignal) if (parent is FlyOver flyOver && waitingForSignal)
{ {
Log.Message($"External signal received, triggering drop pods"); ArachnaeLog.Debug($"External signal received, triggering drop pods");
DropPods(flyOver); DropPods(flyOver);
waitingForSignal = false; waitingForSignal = false;
} }
@@ -313,12 +313,12 @@ namespace ArachnaeSwarm
Map map = flyOver.Map; Map map = flyOver.Map;
if (map == null) if (map == null)
{ {
Log.Error("FlyOver DropPods: Map is null"); ArachnaeLog.Debug("FlyOver DropPods: Map is null");
return; return;
} }
IntVec3 dropCenter = GetDropCenter(flyOver); IntVec3 dropCenter = GetDropCenter(flyOver);
Log.Message($"DropPods triggered at progress {flyOver.currentProgress}, center: {dropCenter}"); ArachnaeLog.Debug($"DropPods triggered at progress {flyOver.currentProgress}, center: {dropCenter}");
// 如果在投掷时生成 Pawn现在生成 // 如果在投掷时生成 Pawn现在生成
if (Props.generatePawnsOnDrop && Props.pawnKinds != null) if (Props.generatePawnsOnDrop && Props.pawnKinds != null)
@@ -351,7 +351,7 @@ namespace ArachnaeSwarm
if (!thingsToDrop.Any()) if (!thingsToDrop.Any())
{ {
Log.Warning("No items to drop from FlyOver drop pods"); ArachnaeLog.Debug("No items to drop from FlyOver drop pods");
return; return;
} }
@@ -377,7 +377,7 @@ namespace ArachnaeSwarm
SendDropLetter(thingsToDrop, dropCenter, map); SendDropLetter(thingsToDrop, dropCenter, map);
} }
Log.Message($"Drop pods completed: {thingsToDrop.Count} items dropped, including {pawns.Count} pawns"); ArachnaeLog.Debug($"Drop pods completed: {thingsToDrop.Count} items dropped, including {pawns.Count} pawns");
// 清空已投掷的物品列表,避免重复投掷 // 清空已投掷的物品列表,避免重复投掷
items.Clear(); items.Clear();
@@ -464,7 +464,7 @@ namespace ArachnaeSwarm
// 创建 Lord // 创建 Lord
Lord lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap, factionPawns); Lord lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap, factionPawns);
Log.Message($"Assigned assault lord job to {factionPawns.Count} pawns of faction {faction.Name}"); ArachnaeLog.Debug($"Assigned assault lord job to {factionPawns.Count} pawns of faction {faction.Name}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -30,8 +30,8 @@ namespace ArachnaeSwarm
ticksUntilNextSpawn = Props.spawnIntervalTicks; ticksUntilNextSpawn = Props.spawnIntervalTicks;
} }
Log.Message($"FlyOver Escort initialized: {Props.spawnIntervalTicks} ticks interval, max {Props.maxEscorts} escorts"); ArachnaeLog.Debug($"FlyOver Escort initialized: {Props.spawnIntervalTicks} ticks interval, max {Props.maxEscorts} escorts");
Log.Message($"Safe distances - From Main: {Props.minSafeDistanceFromMain}, Between Escorts: {Props.minSafeDistanceBetweenEscorts}"); ArachnaeLog.Debug($"Safe distances - From Main: {Props.minSafeDistanceFromMain}, Between Escorts: {Props.minSafeDistanceBetweenEscorts}");
} }
public override void CompTick() public override void CompTick()
@@ -45,7 +45,7 @@ namespace ArachnaeSwarm
if (!hasInitialized && mainFlyOver.hasStarted) if (!hasInitialized && mainFlyOver.hasStarted)
{ {
hasInitialized = true; hasInitialized = true;
Log.Message($"FlyOver Escort: Main FlyOver started at {mainFlyOver.startPosition}"); ArachnaeLog.Debug($"FlyOver Escort: Main FlyOver started at {mainFlyOver.startPosition}");
} }
// 清理已销毁的伴飞 // 清理已销毁的伴飞
@@ -116,13 +116,13 @@ namespace ArachnaeSwarm
escortVisualData[escort] = visualData; escortVisualData[escort] = visualData;
successfulSpawns++; successfulSpawns++;
Log.Message($"Spawned escort #{successfulSpawns} for FlyOver at {mainFlyOver.DrawPos}, scale: {visualData.scale:F2}, maskAlpha: {visualData.heightMaskAlpha:F2}"); ArachnaeLog.Debug($"Spawned escort #{successfulSpawns} for FlyOver at {mainFlyOver.DrawPos}, scale: {visualData.scale:F2}, maskAlpha: {visualData.heightMaskAlpha:F2}");
} }
else else
{ {
// 不安全,销毁这个伴飞 // 不安全,销毁这个伴飞
escort.Destroy(); escort.Destroy();
Log.Message($"Escort spawn attempt {attempt + 1}: Position too close to existing escort, trying again"); ArachnaeLog.Debug($"Escort spawn attempt {attempt + 1}: Position too close to existing escort, trying again");
} }
} }
@@ -133,7 +133,7 @@ namespace ArachnaeSwarm
if (successfulSpawns < escortsToSpawn) if (successfulSpawns < escortsToSpawn)
{ {
Log.Message($"Spawned {successfulSpawns}/{escortsToSpawn} escorts (some positions were too close to existing escorts)"); ArachnaeLog.Debug($"Spawned {successfulSpawns}/{escortsToSpawn} escorts (some positions were too close to existing escorts)");
} }
} }
@@ -148,7 +148,7 @@ namespace ArachnaeSwarm
float distToMain = Vector3.Distance(newPos, mainFlyOver.DrawPos); float distToMain = Vector3.Distance(newPos, mainFlyOver.DrawPos);
if (distToMain < Props.minSafeDistanceFromMain) if (distToMain < Props.minSafeDistanceFromMain)
{ {
Log.Message($"Escort too close to main FlyOver: {distToMain:F1} < {Props.minSafeDistanceFromMain}"); ArachnaeLog.Debug($"Escort too close to main FlyOver: {distToMain:F1} < {Props.minSafeDistanceFromMain}");
return false; return false;
} }
} }
@@ -164,7 +164,7 @@ namespace ArachnaeSwarm
float distToEscort = Vector3.Distance(newPos, existingEscort.DrawPos); float distToEscort = Vector3.Distance(newPos, existingEscort.DrawPos);
if (distToEscort < Props.minSafeDistanceBetweenEscorts) if (distToEscort < Props.minSafeDistanceBetweenEscorts)
{ {
Log.Message($"Escort too close to existing escort: {distToEscort:F1} < {Props.minSafeDistanceBetweenEscorts}"); ArachnaeLog.Debug($"Escort too close to existing escort: {distToEscort:F1} < {Props.minSafeDistanceBetweenEscorts}");
return false; return false;
} }
} }
@@ -198,7 +198,7 @@ namespace ArachnaeSwarm
ThingDef escortDef = SelectEscortDef(); ThingDef escortDef = SelectEscortDef();
if (escortDef == null) if (escortDef == null)
{ {
Log.Error("FlyOver Escort: No valid escort def found"); ArachnaeLog.Debug("FlyOver Escort: No valid escort def found");
return null; return null;
} }
@@ -208,7 +208,7 @@ namespace ArachnaeSwarm
if (!escortStart.InBounds(mainFlyOver.Map) || !escortEnd.InBounds(mainFlyOver.Map)) if (!escortStart.InBounds(mainFlyOver.Map) || !escortEnd.InBounds(mainFlyOver.Map))
{ {
Log.Warning("FlyOver Escort: Escort start or end position out of bounds"); ArachnaeLog.Debug("FlyOver Escort: Escort start or end position out of bounds");
return null; return null;
} }
@@ -231,13 +231,13 @@ namespace ArachnaeSwarm
// 设置伴飞属性 - 现在传入 visualData // 设置伴飞属性 - 现在传入 visualData
SetupEscortProperties(escort, mainFlyOver, visualData); SetupEscortProperties(escort, mainFlyOver, visualData);
Log.Message($"Created escort: {escortStart} -> {escortEnd}, speed: {escortSpeed}, altitude: {escortAltitude}"); ArachnaeLog.Debug($"Created escort: {escortStart} -> {escortEnd}, speed: {escortSpeed}, altitude: {escortAltitude}");
return escort; return escort;
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error creating FlyOver escort: {ex}"); ArachnaeLog.Debug($"Error creating FlyOver escort: {ex}");
return null; return null;
} }
} }
@@ -351,7 +351,7 @@ namespace ArachnaeSwarm
escort.playFlyOverSound = false; escort.playFlyOverSound = false;
} }
Log.Message($"Set escort properties: scale={visualData.scale:F2}, isEscort={escort.isEscort}"); ArachnaeLog.Debug($"Set escort properties: scale={visualData.scale:F2}, isEscort={escort.isEscort}");
} }
private void UpdateEscortPositions(FlyOver mainFlyOver) private void UpdateEscortPositions(FlyOver mainFlyOver)

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -33,7 +33,7 @@ namespace ArachnaeSwarm
currentLongitudinalOffset = Props.longitudinalInitialOffset; currentLongitudinalOffset = Props.longitudinalInitialOffset;
} }
Log.Message($"GroundStrafing: Initialized with {confirmedTargetCells.Count} targets, " + ArachnaeLog.Debug($"GroundStrafing: Initialized with {confirmedTargetCells.Count} targets, " +
$"Lateral Offset: {currentLateralOffsetAngle:F1}°, " + $"Lateral Offset: {currentLateralOffsetAngle:F1}°, " +
$"Longitudinal Offset: {currentLongitudinalOffset:F1}"); $"Longitudinal Offset: {currentLongitudinalOffset:F1}");
} }
@@ -52,7 +52,7 @@ namespace ArachnaeSwarm
// 定期状态输出 // 定期状态输出
if (Find.TickManager.TicksGame % 120 == 0 && confirmedTargetCells.Count > 0) if (Find.TickManager.TicksGame % 120 == 0 && confirmedTargetCells.Count > 0)
{ {
Log.Message($"GroundStrafing: {firedCells.Count}/{confirmedTargetCells.Count + firedCells.Count} targets fired, " + ArachnaeLog.Debug($"GroundStrafing: {firedCells.Count}/{confirmedTargetCells.Count + firedCells.Count} targets fired, " +
$"Lateral: {currentLateralOffsetAngle:F1}°, Longitudinal: {currentLongitudinalOffset:F1}"); $"Lateral: {currentLateralOffsetAngle:F1}°, Longitudinal: {currentLongitudinalOffset:F1}");
} }
} }
@@ -84,7 +84,7 @@ namespace ArachnaeSwarm
if (firedCells.Count == 1) if (firedCells.Count == 1)
{ {
Log.Message($"First strafing shot at {targetCell}, " + ArachnaeLog.Debug($"First strafing shot at {targetCell}, " +
$"Lateral offset: {currentLateralOffsetAngle:F1}°, " + $"Lateral offset: {currentLateralOffsetAngle:F1}°, " +
$"Longitudinal offset: {currentLongitudinalOffset:F1}"); $"Longitudinal offset: {currentLongitudinalOffset:F1}");
} }
@@ -235,7 +235,7 @@ namespace ArachnaeSwarm
{ {
if (Props.projectileDef == null) if (Props.projectileDef == null)
{ {
Log.Error("No projectile defined for ground strafing"); ArachnaeLog.Debug("No projectile defined for ground strafing");
return false; return false;
} }
@@ -279,7 +279,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error launching ground strafing projectile: {ex}"); ArachnaeLog.Debug($"Error launching ground strafing projectile: {ex}");
} }
return false; return false;
@@ -320,13 +320,13 @@ namespace ArachnaeSwarm
confirmedTargetCells.AddRange(targets); confirmedTargetCells.AddRange(targets);
Log.Message($"GroundStrafing: Set {confirmedTargetCells.Count} targets, " + ArachnaeLog.Debug($"GroundStrafing: Set {confirmedTargetCells.Count} targets, " +
$"Lateral Mode: {Props.lateralOffsetMode}, " + $"Lateral Mode: {Props.lateralOffsetMode}, " +
$"Longitudinal Mode: {Props.longitudinalOffsetMode}"); $"Longitudinal Mode: {Props.longitudinalOffsetMode}");
if (confirmedTargetCells.Count > 0) if (confirmedTargetCells.Count > 0)
{ {
Log.Message($"First target: {confirmedTargetCells[0]}, Last target: {confirmedTargetCells[confirmedTargetCells.Count - 1]}"); ArachnaeLog.Debug($"First target: {confirmedTargetCells[0]}, Last target: {confirmedTargetCells[confirmedTargetCells.Count - 1]}");
} }
} }
@@ -345,10 +345,10 @@ namespace ArachnaeSwarm
// 修改:调试方法 // 修改:调试方法
public void DebugOffsetStatus() public void DebugOffsetStatus()
{ {
Log.Message($"GroundStrafing Offset Status:"); ArachnaeLog.Debug($"GroundStrafing Offset Status:");
Log.Message($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}"); ArachnaeLog.Debug($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
Log.Message($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}"); ArachnaeLog.Debug($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
Log.Message($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}"); ArachnaeLog.Debug($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -52,23 +52,23 @@ namespace ArachnaeSwarm
currentLongitudinalOffset = Props.longitudinalInitialOffset; currentLongitudinalOffset = Props.longitudinalInitialOffset;
} }
Log.Message($"SectorSurveillance: Initialized - Angle: {Props.sectorAngle}°, Range: {Props.sectorRange}, Shots: {Props.shotCount}, Interval: {Props.shotInterval}s"); ArachnaeLog.Debug($"SectorSurveillance: Initialized - Angle: {Props.sectorAngle}°, Range: {Props.sectorRange}, Shots: {Props.shotCount}, Interval: {Props.shotInterval}s");
Log.Message($"SectorSurveillance: ProjectileDef = {Props.projectileDef?.defName ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: ProjectileDef = {Props.projectileDef?.defName ?? "NULL"}");
Log.Message($"SectorSurveillance: Parent = {parent?.def?.defName ?? "NULL"} at {parent?.Position.ToString() ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Parent = {parent?.def?.defName ?? "NULL"} at {parent?.Position.ToString() ?? "NULL"}");
Log.Message($"SectorSurveillance: Max Projectiles = {Props.maxProjectiles}, Remaining = {remainingProjectiles}"); ArachnaeLog.Debug($"SectorSurveillance: Max Projectiles = {Props.maxProjectiles}, Remaining = {remainingProjectiles}");
Log.Message($"SectorSurveillance: Lateral Mode: {Props.lateralOffsetMode}, Longitudinal Mode: {Props.longitudinalOffsetMode}"); ArachnaeLog.Debug($"SectorSurveillance: Lateral Mode: {Props.lateralOffsetMode}, Longitudinal Mode: {Props.longitudinalOffsetMode}");
InitializeFactionCache(); InitializeFactionCache();
} }
private void InitializeFactionCache() private void InitializeFactionCache()
{ {
Log.Message($"SectorSurveillance: Initializing faction cache..."); ArachnaeLog.Debug($"SectorSurveillance: Initializing faction cache...");
if (parent.Faction != null) if (parent.Faction != null)
{ {
cachedFaction = parent.Faction; cachedFaction = parent.Faction;
Log.Message($"SectorSurveillance: Using parent.Faction: {cachedFaction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Using parent.Faction: {cachedFaction?.Name ?? "NULL"}");
} }
else else
{ {
@@ -76,21 +76,21 @@ namespace ArachnaeSwarm
if (flyOver?.caster != null && flyOver.caster.Faction != null) if (flyOver?.caster != null && flyOver.caster.Faction != null)
{ {
cachedFaction = flyOver.caster.Faction; cachedFaction = flyOver.caster.Faction;
Log.Message($"SectorSurveillance: Using caster.Faction: {cachedFaction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Using caster.Faction: {cachedFaction?.Name ?? "NULL"}");
} }
else if (flyOver?.faction != null) else if (flyOver?.faction != null)
{ {
cachedFaction = flyOver.faction; cachedFaction = flyOver.faction;
Log.Message($"SectorSurveillance: Using flyOver.faction: {cachedFaction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Using flyOver.faction: {cachedFaction?.Name ?? "NULL"}");
} }
else else
{ {
Log.Error($"SectorSurveillance: CRITICAL - No faction found!"); ArachnaeLog.Debug($"SectorSurveillance: CRITICAL - No faction found!");
} }
} }
factionInitialized = true; factionInitialized = true;
Log.Message($"SectorSurveillance: Faction cache initialized: {cachedFaction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Faction cache initialized: {cachedFaction?.Name ?? "NULL"}");
} }
private Faction GetEffectiveFaction() private Faction GetEffectiveFaction()
@@ -102,7 +102,7 @@ namespace ArachnaeSwarm
if (cachedFaction == null) if (cachedFaction == null)
{ {
Log.Warning("SectorSurveillance: Cached faction is null, reinitializing..."); ArachnaeLog.Debug("SectorSurveillance: Cached faction is null, reinitializing...");
InitializeFactionCache(); InitializeFactionCache();
} }
@@ -118,8 +118,8 @@ namespace ArachnaeSwarm
if (Find.TickManager.TicksGame % 60 == 0) if (Find.TickManager.TicksGame % 60 == 0)
{ {
Faction currentFaction = GetEffectiveFaction(); Faction currentFaction = GetEffectiveFaction();
Log.Message($"SectorSurveillance Status: Frames={totalFramesProcessed}, TargetsFound={totalTargetsFound}, ShotsFired={totalShotsFired}, ActiveTargets={activeTargets.Count}, Cooldowns={shotCooldowns.Count}, Faction={currentFaction?.Name ?? "NULL"}, RemainingProjectiles={remainingProjectiles}, AmmoExhausted={ammoExhausted}"); ArachnaeLog.Debug($"SectorSurveillance Status: Frames={totalFramesProcessed}, TargetsFound={totalTargetsFound}, ShotsFired={totalShotsFired}, ActiveTargets={activeTargets.Count}, Cooldowns={shotCooldowns.Count}, Faction={currentFaction?.Name ?? "NULL"}, RemainingProjectiles={remainingProjectiles}, AmmoExhausted={ammoExhausted}");
Log.Message($"SectorSurveillance Offsets: Lateral={currentLateralOffsetAngle:F1}°, Longitudinal={currentLongitudinalOffset:F1}, TotalShots={shotsFired}"); ArachnaeLog.Debug($"SectorSurveillance Offsets: Lateral={currentLateralOffsetAngle:F1}°, Longitudinal={currentLongitudinalOffset:F1}, TotalShots={shotsFired}");
} }
UpdateShotCooldowns(); UpdateShotCooldowns();
@@ -165,7 +165,7 @@ namespace ArachnaeSwarm
foreach (Pawn pawn in toRemove) foreach (Pawn pawn in toRemove)
{ {
shotCooldowns.Remove(pawn); shotCooldowns.Remove(pawn);
Log.Message($"SectorSurveillance: Cooldown finished for {pawn?.Label ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: Cooldown finished for {pawn?.Label ?? "NULL"}");
} }
} }
@@ -178,11 +178,11 @@ namespace ArachnaeSwarm
} }
List<Pawn> enemiesInSector = GetEnemiesInSector(); List<Pawn> enemiesInSector = GetEnemiesInSector();
Log.Message($"SectorSurveillance: Found {enemiesInSector.Count} enemies in sector"); ArachnaeLog.Debug($"SectorSurveillance: Found {enemiesInSector.Count} enemies in sector");
if (enemiesInSector.Count > 0) if (enemiesInSector.Count > 0)
{ {
Log.Message($"SectorSurveillance: Enemies in sector: {string.Join(", ", enemiesInSector.ConvertAll(p => p.Label))}"); ArachnaeLog.Debug($"SectorSurveillance: Enemies in sector: {string.Join(", ", enemiesInSector.ConvertAll(p => p.Label))}");
} }
foreach (Pawn enemy in enemiesInSector) foreach (Pawn enemy in enemiesInSector)
@@ -194,7 +194,7 @@ namespace ArachnaeSwarm
!shotCooldowns.ContainsKey(enemy)) !shotCooldowns.ContainsKey(enemy))
{ {
activeTargets[enemy] = Props.shotCount; activeTargets[enemy] = Props.shotCount;
Log.Message($"SectorSurveillance: Starting attack sequence on {enemy.Label} at {enemy.Position} - {Props.shotCount} shots"); ArachnaeLog.Debug($"SectorSurveillance: Starting attack sequence on {enemy.Label} at {enemy.Position} - {Props.shotCount} shots");
} }
} }
} }
@@ -231,26 +231,26 @@ namespace ArachnaeSwarm
if (!IsInSector(enemy.Position)) if (!IsInSector(enemy.Position))
{ {
Log.Message($"SectorSurveillance: Target {enemy.Label} left sector, cancelling attack"); ArachnaeLog.Debug($"SectorSurveillance: Target {enemy.Label} left sector, cancelling attack");
completedTargets.Add(enemy); completedTargets.Add(enemy);
continue; continue;
} }
if (shotCooldowns.ContainsKey(enemy)) if (shotCooldowns.ContainsKey(enemy))
{ {
Log.Message($"SectorSurveillance: Target {enemy.Label} in cooldown, skipping this frame"); ArachnaeLog.Debug($"SectorSurveillance: Target {enemy.Label} in cooldown, skipping this frame");
continue; continue;
} }
// 检查剩余射弹数量 // 检查剩余射弹数量
if (remainingProjectiles == 0) if (remainingProjectiles == 0)
{ {
Log.Message($"SectorSurveillance: Ammo exhausted, cannot fire at {enemy.Label}"); ArachnaeLog.Debug($"SectorSurveillance: Ammo exhausted, cannot fire at {enemy.Label}");
ammoExhausted = true; ammoExhausted = true;
break; // 跳出循环,不再发射任何射弹 break; // 跳出循环,不再发射任何射弹
} }
Log.Message($"SectorSurveillance: Attempting to fire at {enemy.Label}, remaining shots: {remainingShots}, remaining projectiles: {remainingProjectiles}"); ArachnaeLog.Debug($"SectorSurveillance: Attempting to fire at {enemy.Label}, remaining shots: {remainingShots}, remaining projectiles: {remainingProjectiles}");
if (LaunchProjectileAt(enemy)) if (LaunchProjectileAt(enemy))
{ {
totalShotsFired++; totalShotsFired++;
@@ -261,13 +261,13 @@ namespace ArachnaeSwarm
if (remainingProjectiles > 0) if (remainingProjectiles > 0)
{ {
remainingProjectiles--; remainingProjectiles--;
Log.Message($"SectorSurveillance: Remaining projectiles: {remainingProjectiles}"); ArachnaeLog.Debug($"SectorSurveillance: Remaining projectiles: {remainingProjectiles}");
// 检查是否耗尽弹药 // 检查是否耗尽弹药
if (remainingProjectiles == 0) if (remainingProjectiles == 0)
{ {
ammoExhausted = true; ammoExhausted = true;
Log.Message($"SectorSurveillance: AMMO EXHAUSTED - No more projectiles available"); ArachnaeLog.Debug($"SectorSurveillance: AMMO EXHAUSTED - No more projectiles available");
} }
} }
@@ -277,18 +277,18 @@ namespace ArachnaeSwarm
int cooldownTicks = Mathf.RoundToInt(Props.shotInterval * 60f); int cooldownTicks = Mathf.RoundToInt(Props.shotInterval * 60f);
shotCooldowns[enemy] = cooldownTicks; shotCooldowns[enemy] = cooldownTicks;
Log.Message($"SectorSurveillance: Successfully fired at {enemy.Label}, {remainingShots} shots remaining, cooldown: {cooldownTicks} ticks"); ArachnaeLog.Debug($"SectorSurveillance: Successfully fired at {enemy.Label}, {remainingShots} shots remaining, cooldown: {cooldownTicks} ticks");
if (remainingShots <= 0) if (remainingShots <= 0)
{ {
attackedPawns.Add(enemy); attackedPawns.Add(enemy);
completedTargets.Add(enemy); completedTargets.Add(enemy);
Log.Message($"SectorSurveillance: Completed attack sequence on {enemy.Label}"); ArachnaeLog.Debug($"SectorSurveillance: Completed attack sequence on {enemy.Label}");
} }
} }
else else
{ {
Log.Error($"SectorSurveillance: Failed to fire projectile at {enemy.Label}"); ArachnaeLog.Debug($"SectorSurveillance: Failed to fire projectile at {enemy.Label}");
} }
} }
@@ -299,13 +299,13 @@ namespace ArachnaeSwarm
if (enemy != null) if (enemy != null)
{ {
activeTargets.Remove(enemy); activeTargets.Remove(enemy);
Log.Message($"SectorSurveillance: Removed {enemy.Label} from active targets"); ArachnaeLog.Debug($"SectorSurveillance: Removed {enemy.Label} from active targets");
} }
else else
{ {
// 如果目标已不存在,直接从字典中移除对应的键 // 如果目标已不存在,直接从字典中移除对应的键
activeTargets.Remove(enemy); activeTargets.Remove(enemy);
Log.Message($"SectorSurveillance: Removed null target from active targets"); ArachnaeLog.Debug($"SectorSurveillance: Removed null target from active targets");
} }
} }
} }
@@ -448,14 +448,14 @@ namespace ArachnaeSwarm
if (map == null) if (map == null)
{ {
Log.Error("SectorSurveillance: Map is null!"); ArachnaeLog.Debug("SectorSurveillance: Map is null!");
return enemies; return enemies;
} }
FlyOver flyOver = parent as FlyOver; FlyOver flyOver = parent as FlyOver;
if (flyOver == null) if (flyOver == null)
{ {
Log.Error("SectorSurveillance: Parent is not a FlyOver!"); ArachnaeLog.Debug("SectorSurveillance: Parent is not a FlyOver!");
return enemies; return enemies;
} }
@@ -464,7 +464,7 @@ namespace ArachnaeSwarm
float range = Props.sectorRange; float range = Props.sectorRange;
float halfAngle = Props.sectorAngle * 0.5f; float halfAngle = Props.sectorAngle * 0.5f;
Log.Message($"SectorSurveillance: Checking sector - Center: {center}, Direction: {flightDirection}, Range: {range}, HalfAngle: {halfAngle}"); ArachnaeLog.Debug($"SectorSurveillance: Checking sector - Center: {center}, Direction: {flightDirection}, Range: {range}, HalfAngle: {halfAngle}");
int totalEnemiesChecked = 0; int totalEnemiesChecked = 0;
@@ -480,12 +480,12 @@ namespace ArachnaeSwarm
if (inSector) if (inSector)
{ {
enemies.Add(pawn); enemies.Add(pawn);
Log.Message($"SectorSurveillance: Valid target found - {pawn.Label} at {pawn.Position}, in sector: {inSector}"); ArachnaeLog.Debug($"SectorSurveillance: Valid target found - {pawn.Label} at {pawn.Position}, in sector: {inSector}");
} }
} }
} }
Log.Message($"SectorSurveillance: Checked {totalEnemiesChecked} pawns, found {enemies.Count} valid targets in sector"); ArachnaeLog.Debug($"SectorSurveillance: Checked {totalEnemiesChecked} pawns, found {enemies.Count} valid targets in sector");
return enemies; return enemies;
} }
@@ -493,32 +493,32 @@ namespace ArachnaeSwarm
{ {
if (pawn == null) if (pawn == null)
{ {
Log.Message("SectorSurveillance: IsValidTarget - pawn is null"); ArachnaeLog.Debug("SectorSurveillance: IsValidTarget - pawn is null");
return false; return false;
} }
// 关键修复检查pawn是否已被销毁或死亡 // 关键修复检查pawn是否已被销毁或死亡
if (pawn.Destroyed || pawn.Dead || !pawn.Spawned) if (pawn.Destroyed || pawn.Dead || !pawn.Spawned)
{ {
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} is destroyed/dead/unspawned"); ArachnaeLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} is destroyed/dead/unspawned");
return false; return false;
} }
if (pawn.Downed) if (pawn.Downed)
{ {
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} is downed"); ArachnaeLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} is downed");
return false; return false;
} }
Faction effectiveFaction = GetEffectiveFaction(); Faction effectiveFaction = GetEffectiveFaction();
if (effectiveFaction == null) if (effectiveFaction == null)
{ {
Log.Error($"SectorSurveillance: IsValidTarget - No effective faction found for {pawn.Label}"); ArachnaeLog.Debug($"SectorSurveillance: IsValidTarget - No effective faction found for {pawn.Label}");
return false; return false;
} }
bool hostile = pawn.HostileTo(effectiveFaction); bool hostile = pawn.HostileTo(effectiveFaction);
Log.Message($"SectorSurveillance: IsValidTarget - {pawn.Label} from {pawn.Faction?.Name ?? "NULL"} is hostile to {effectiveFaction.Name}: {hostile}"); ArachnaeLog.Debug($"SectorSurveillance: IsValidTarget - {pawn.Label} from {pawn.Faction?.Name ?? "NULL"} is hostile to {effectiveFaction.Name}: {hostile}");
return hostile; return hostile;
} }
@@ -528,7 +528,7 @@ namespace ArachnaeSwarm
FlyOver flyOver = parent as FlyOver; FlyOver flyOver = parent as FlyOver;
if (flyOver == null) if (flyOver == null)
{ {
Log.Error("SectorSurveillance: IsInSector - Parent is not a FlyOver!"); ArachnaeLog.Debug("SectorSurveillance: IsInSector - Parent is not a FlyOver!");
return false; return false;
} }
@@ -539,7 +539,7 @@ namespace ArachnaeSwarm
float distance = targetVector.magnitude; float distance = targetVector.magnitude;
if (distance > Props.sectorRange) if (distance > Props.sectorRange)
{ {
Log.Message($"SectorSurveillance: IsInSector - Target at {targetPos} is out of range: {distance:F1} > {Props.sectorRange}"); ArachnaeLog.Debug($"SectorSurveillance: IsInSector - Target at {targetPos} is out of range: {distance:F1} > {Props.sectorRange}");
return false; return false;
} }
@@ -548,7 +548,7 @@ namespace ArachnaeSwarm
bool inAngle = angle <= Props.sectorAngle * 0.5f; bool inAngle = angle <= Props.sectorAngle * 0.5f;
Log.Message($"SectorSurveillance: IsInSector - Target at {targetPos}, distance: {distance:F1}, angle: {angle:F1}°, inAngle: {inAngle}"); ArachnaeLog.Debug($"SectorSurveillance: IsInSector - Target at {targetPos}, distance: {distance:F1}, angle: {angle:F1}°, inAngle: {inAngle}");
return inAngle; return inAngle;
} }
@@ -557,11 +557,11 @@ namespace ArachnaeSwarm
{ {
if (Props.projectileDef == null) if (Props.projectileDef == null)
{ {
Log.Error("SectorSurveillance: No projectile defined for sector surveillance"); ArachnaeLog.Debug("SectorSurveillance: No projectile defined for sector surveillance");
return false; return false;
} }
Log.Message($"SectorSurveillance: LaunchProjectileAt - Starting launch for target {target?.Label ?? "NULL"}"); ArachnaeLog.Debug($"SectorSurveillance: LaunchProjectileAt - Starting launch for target {target?.Label ?? "NULL"}");
try try
{ {
@@ -574,33 +574,33 @@ namespace ArachnaeSwarm
IntVec3 spawnCell = offsetSpawnPos.ToIntVec3(); IntVec3 spawnCell = offsetSpawnPos.ToIntVec3();
Log.Message($"SectorSurveillance: Spawn position - World: {offsetSpawnPos}, Cell: {spawnCell}, Lateral Offset: {currentLateralOffsetAngle:F1}°, Longitudinal Offset: {currentLongitudinalOffset:F1}"); ArachnaeLog.Debug($"SectorSurveillance: Spawn position - World: {offsetSpawnPos}, Cell: {spawnCell}, Lateral Offset: {currentLateralOffsetAngle:F1}°, Longitudinal Offset: {currentLongitudinalOffset:F1}");
if (parent.Map == null) if (parent.Map == null)
{ {
Log.Error("SectorSurveillance: Map is null during projectile launch"); ArachnaeLog.Debug("SectorSurveillance: Map is null during projectile launch");
return false; return false;
} }
if (!spawnCell.InBounds(parent.Map)) if (!spawnCell.InBounds(parent.Map))
{ {
Log.Error($"SectorSurveillance: Spawn cell {spawnCell} is out of bounds"); ArachnaeLog.Debug($"SectorSurveillance: Spawn cell {spawnCell} is out of bounds");
return false; return false;
} }
Log.Message($"SectorSurveillance: Attempting to spawn projectile: {Props.projectileDef.defName}"); ArachnaeLog.Debug($"SectorSurveillance: Attempting to spawn projectile: {Props.projectileDef.defName}");
Projectile projectile = (Projectile)GenSpawn.Spawn(Props.projectileDef, spawnCell, parent.Map); Projectile projectile = (Projectile)GenSpawn.Spawn(Props.projectileDef, spawnCell, parent.Map);
if (projectile != null) if (projectile != null)
{ {
Log.Message($"SectorSurveillance: Projectile spawned successfully: {projectile}"); ArachnaeLog.Debug($"SectorSurveillance: Projectile spawned successfully: {projectile}");
Thing launcher = GetLauncher(); Thing launcher = GetLauncher();
Vector3 launchPos = offsetSpawnPos; Vector3 launchPos = offsetSpawnPos;
LocalTargetInfo targetInfo = new LocalTargetInfo(target); LocalTargetInfo targetInfo = new LocalTargetInfo(target);
Log.Message($"SectorSurveillance: Launching projectile - Launcher: {launcher?.def?.defName ?? "NULL"}, LaunchPos: {launchPos}, Target: {targetInfo.Cell}"); ArachnaeLog.Debug($"SectorSurveillance: Launching projectile - Launcher: {launcher?.def?.defName ?? "NULL"}, LaunchPos: {launchPos}, Target: {targetInfo.Cell}");
projectile.Launch( projectile.Launch(
launcher, launcher,
@@ -617,19 +617,19 @@ namespace ArachnaeSwarm
CreateOffsetEffect(offsetSpawnPos, directionToTarget); CreateOffsetEffect(offsetSpawnPos, directionToTarget);
} }
Log.Message($"SectorSurveillance: Projectile launched successfully"); ArachnaeLog.Debug($"SectorSurveillance: Projectile launched successfully");
return true; return true;
} }
else else
{ {
Log.Error("SectorSurveillance: Failed to spawn projectile - GenSpawn.Spawn returned null"); ArachnaeLog.Debug("SectorSurveillance: Failed to spawn projectile - GenSpawn.Spawn returned null");
return false; return false;
} }
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"SectorSurveillance: Exception launching projectile: {ex}"); ArachnaeLog.Debug($"SectorSurveillance: Exception launching projectile: {ex}");
Log.Error($"SectorSurveillance: Stack trace: {ex.StackTrace}"); ArachnaeLog.Debug($"SectorSurveillance: Stack trace: {ex.StackTrace}");
return false; return false;
} }
} }
@@ -653,11 +653,11 @@ namespace ArachnaeSwarm
FlyOver flyOver = parent as FlyOver; FlyOver flyOver = parent as FlyOver;
if (flyOver != null && flyOver.caster != null) if (flyOver != null && flyOver.caster != null)
{ {
Log.Message($"SectorSurveillance: Using caster as launcher: {flyOver.caster.Label}"); ArachnaeLog.Debug($"SectorSurveillance: Using caster as launcher: {flyOver.caster.Label}");
return flyOver.caster; return flyOver.caster;
} }
Log.Message($"SectorSurveillance: Using parent as launcher: {parent.Label}"); ArachnaeLog.Debug($"SectorSurveillance: Using parent as launcher: {parent.Label}");
return parent; return parent;
} }
@@ -732,10 +732,10 @@ namespace ArachnaeSwarm
// 新增:调试方法 // 新增:调试方法
public void DebugOffsetStatus() public void DebugOffsetStatus()
{ {
Log.Message($"SectorSurveillance Offset Status:"); ArachnaeLog.Debug($"SectorSurveillance Offset Status:");
Log.Message($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}"); ArachnaeLog.Debug($" Lateral - Angle: {currentLateralOffsetAngle:F1}°, Mode: {Props.lateralOffsetMode}");
Log.Message($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}"); ArachnaeLog.Debug($" Longitudinal - Offset: {currentLongitudinalOffset:F1}, Mode: {Props.longitudinalOffsetMode}");
Log.Message($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}"); ArachnaeLog.Debug($" Shots Fired: {shotsFired}, Forward Phase: {isForwardPhase}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
namespace ArachnaeSwarm namespace ArachnaeSwarm
@@ -43,7 +43,7 @@ namespace ArachnaeSwarm
// 检查是否有有效的信件内容 // 检查是否有有效的信件内容
if (Props.letterLabel.NullOrEmpty() && Props.letterText.NullOrEmpty()) if (Props.letterLabel.NullOrEmpty() && Props.letterText.NullOrEmpty())
{ {
Log.Warning($"CompSendLetterAfterTicks: No letter content defined for {parent.def.defName}"); ArachnaeLog.Debug($"CompSendLetterAfterTicks: No letter content defined for {parent.def.defName}");
return; return;
} }
@@ -63,11 +63,11 @@ namespace ArachnaeSwarm
letterSent = true; letterSent = true;
Log.Message($"Letter sent from {parent.def.defName} after {ticksPassed} ticks"); ArachnaeLog.Debug($"Letter sent from {parent.def.defName} after {ticksPassed} ticks");
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error sending letter from {parent.def.defName}: {ex}"); ArachnaeLog.Debug($"Error sending letter from {parent.def.defName}: {ex}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@@ -30,7 +30,7 @@ namespace ArachnaeSwarm
ticksUntilNextAttack = Props.ticksBetweenAttacks; ticksUntilNextAttack = Props.ticksBetweenAttacks;
Log.Message($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius"); ArachnaeLog.Debug($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius");
} }
public override void CompTick() public override void CompTick()
@@ -75,12 +75,12 @@ namespace ArachnaeSwarm
if (!currentTarget.IsValid || !currentTarget.InBounds(flyOver.Map)) if (!currentTarget.IsValid || !currentTarget.InBounds(flyOver.Map))
{ {
Log.Warning("Ship Artillery: Invalid target selected, skipping attack"); ArachnaeLog.Debug("Ship Artillery: Invalid target selected, skipping attack");
ticksUntilNextAttack = Props.ticksBetweenAttacks; ticksUntilNextAttack = Props.ticksBetweenAttacks;
return; return;
} }
Log.Message($"Ship Artillery starting attack on target area: {currentTarget} (attack radius: {Props.attackRadius})"); ArachnaeLog.Debug($"Ship Artillery starting attack on target area: {currentTarget} (attack radius: {Props.attackRadius})");
// 开始预热 // 开始预热
isWarmingUp = true; isWarmingUp = true;
@@ -133,7 +133,7 @@ namespace ArachnaeSwarm
attackEffecter = Props.attackEffect.Spawn(); attackEffecter = Props.attackEffect.Spawn();
} }
Log.Message($"Ship Artillery started firing at area {currentTarget}"); ArachnaeLog.Debug($"Ship Artillery started firing at area {currentTarget}");
// 发送攻击通知 // 发送攻击通知
if (Props.sendAttackLetter) if (Props.sendAttackLetter)
@@ -191,7 +191,7 @@ namespace ArachnaeSwarm
ThingDef shellDef = SelectShellDef(); ThingDef shellDef = SelectShellDef();
if (shellDef == null) if (shellDef == null)
{ {
Log.Error("Ship Artillery: No valid shell def found"); ArachnaeLog.Debug("Ship Artillery: No valid shell def found");
return; return;
} }
@@ -202,7 +202,7 @@ namespace ArachnaeSwarm
SkyfallerMaker.SpawnSkyfaller(shellDef, shellTarget, flyOver.Map); SkyfallerMaker.SpawnSkyfaller(shellDef, shellTarget, flyOver.Map);
float distanceFromCenter = shellTarget.DistanceTo(currentTarget); float distanceFromCenter = shellTarget.DistanceTo(currentTarget);
Log.Message($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})"); ArachnaeLog.Debug($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})");
// 播放音效 // 播放音效
if (Props.attackSound != null) if (Props.attackSound != null)
@@ -212,7 +212,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error firing ship artillery shell: {ex}"); ArachnaeLog.Debug($"Error firing ship artillery shell: {ex}");
} }
} }
@@ -260,7 +260,7 @@ namespace ArachnaeSwarm
IntVec3 flyOverPos = GetFlyOverPosition(flyOver); IntVec3 flyOverPos = GetFlyOverPosition(flyOver);
IntVec3 center = flyOverPos + Props.targetOffset; IntVec3 center = flyOverPos + Props.targetOffset;
Log.Message($"FlyOver position: {flyOverPos}, Center for targeting: {center}"); ArachnaeLog.Debug($"FlyOver position: {flyOverPos}, Center for targeting: {center}");
// 在攻击半径内选择随机目标 // 在攻击半径内选择随机目标
return FindRandomTargetInRadius(center, flyOver.Map, Props.attackRadius); return FindRandomTargetInRadius(center, flyOver.Map, Props.attackRadius);
@@ -289,7 +289,7 @@ namespace ArachnaeSwarm
// 目标查找逻辑 - 基于攻击半径 // 目标查找逻辑 - 基于攻击半径
private IntVec3 FindRandomTargetInRadius(IntVec3 center, Map map, float radius) private IntVec3 FindRandomTargetInRadius(IntVec3 center, Map map, float radius)
{ {
Log.Message($"Finding target around {center} with radius {radius}"); ArachnaeLog.Debug($"Finding target around {center} with radius {radius}");
// 如果半径为0直接返回中心 // 如果半径为0直接返回中心
if (radius <= 0) if (radius <= 0)
@@ -318,11 +318,11 @@ namespace ArachnaeSwarm
previousTargets.Add(potentialTarget); previousTargets.Add(potentialTarget);
float actualDistance = potentialTarget.DistanceTo(center); float actualDistance = potentialTarget.DistanceTo(center);
Log.Message($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})"); ArachnaeLog.Debug($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})");
if (ignoreProtectionForThisTarget) if (ignoreProtectionForThisTarget)
{ {
Log.Warning($"Protection ignored for target selection! May target player assets."); ArachnaeLog.Debug($"Protection ignored for target selection! May target player assets.");
} }
return potentialTarget; return potentialTarget;
@@ -331,7 +331,7 @@ namespace ArachnaeSwarm
} }
// 回退:使用地图随机位置 // 回退:使用地图随机位置
Log.Warning("Could not find valid target in radius, using fallback"); ArachnaeLog.Debug("Could not find valid target in radius, using fallback");
CellRect mapRect = CellRect.WholeMap(map); CellRect mapRect = CellRect.WholeMap(map);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
@@ -437,7 +437,7 @@ namespace ArachnaeSwarm
ticksUntilNextAttack = Props.ticksBetweenAttacks; ticksUntilNextAttack = Props.ticksBetweenAttacks;
} }
Log.Message($"Ship Artillery attack ended"); ArachnaeLog.Debug($"Ship Artillery attack ended");
} }
private void SendAttackLetter(FlyOver flyOver) private void SendAttackLetter(FlyOver flyOver)
@@ -456,7 +456,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error sending ship artillery letter: {ex}"); ArachnaeLog.Debug($"Error sending ship artillery letter: {ex}");
} }
} }
@@ -502,8 +502,8 @@ namespace ArachnaeSwarm
if (parent is FlyOver flyOver) if (parent is FlyOver flyOver)
{ {
IntVec3 flyOverPos = GetFlyOverPosition(flyOver); IntVec3 flyOverPos = GetFlyOverPosition(flyOver);
Log.Message($"FlyOver - DrawPos: {flyOver.DrawPos}, Position: {flyOver.Position}, Calculated: {flyOverPos}"); ArachnaeLog.Debug($"FlyOver - DrawPos: {flyOver.DrawPos}, Position: {flyOver.Position}, Calculated: {flyOverPos}");
Log.Message($"Current Target: {currentTarget}, Distance: {flyOverPos.DistanceTo(currentTarget):F1}"); ArachnaeLog.Debug($"Current Target: {currentTarget}, Distance: {flyOverPos.DistanceTo(currentTarget):F1}");
} }
} }
}; };

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@@ -19,8 +19,8 @@ namespace ArachnaeSwarm
try try
{ {
Log.Message($"FlyOver skill activated by {parent.pawn.Label} at position {parent.pawn.Position}"); ArachnaeLog.Debug($"FlyOver skill activated by {parent.pawn.Label} at position {parent.pawn.Position}");
Log.Message($"Target cell: {target.Cell}, Dest: {dest.Cell}"); ArachnaeLog.Debug($"Target cell: {target.Cell}, Dest: {dest.Cell}");
// 计算起始和结束位置 // 计算起始和结束位置
IntVec3 startPos, endPos; IntVec3 startPos, endPos;
@@ -40,25 +40,25 @@ namespace ArachnaeSwarm
startPos = GetSafeMapPosition(startPos, parent.pawn.Map); startPos = GetSafeMapPosition(startPos, parent.pawn.Map);
endPos = GetSafeMapPosition(endPos, parent.pawn.Map); endPos = GetSafeMapPosition(endPos, parent.pawn.Map);
Log.Message($"Final positions - Start: {startPos}, End: {endPos}"); ArachnaeLog.Debug($"Final positions - Start: {startPos}, End: {endPos}");
// 验证位置是否有效 // 验证位置是否有效
if (!startPos.InBounds(parent.pawn.Map)) if (!startPos.InBounds(parent.pawn.Map))
{ {
Log.Warning($"Start position {startPos} is out of bounds, adjusting to map center"); ArachnaeLog.Debug($"Start position {startPos} is out of bounds, adjusting to map center");
startPos = parent.pawn.Map.Center; startPos = parent.pawn.Map.Center;
} }
if (!endPos.InBounds(parent.pawn.Map)) if (!endPos.InBounds(parent.pawn.Map))
{ {
Log.Warning($"End position {endPos} is out of bounds, adjusting to map center"); ArachnaeLog.Debug($"End position {endPos} is out of bounds, adjusting to map center");
endPos = parent.pawn.Map.Center; endPos = parent.pawn.Map.Center;
} }
// 确保起点和终点不同 // 确保起点和终点不同
if (startPos == endPos) if (startPos == endPos)
{ {
Log.Warning($"FlyOver start and end positions are the same: {startPos}. Adjusting end position."); ArachnaeLog.Debug($"FlyOver start and end positions are the same: {startPos}. Adjusting end position.");
IntVec3 randomOffset = new IntVec3(Rand.Range(-10, 11), 0, Rand.Range(-10, 11)); IntVec3 randomOffset = new IntVec3(Rand.Range(-10, 11), 0, Rand.Range(-10, 11));
endPos += randomOffset; endPos += randomOffset;
endPos = GetSafeMapPosition(endPos, parent.pawn.Map); endPos = GetSafeMapPosition(endPos, parent.pawn.Map);
@@ -81,7 +81,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error spawning fly over: {ex}"); ArachnaeLog.Debug($"Error spawning fly over: {ex}");
} }
} }
@@ -240,7 +240,7 @@ namespace ArachnaeSwarm
} }
} }
Log.Message($"Strafing Area: Calculated {cells.Count} impact cells centered at {targetCell}"); ArachnaeLog.Debug($"Strafing Area: Calculated {cells.Count} impact cells centered at {targetCell}");
return cells; return cells;
} }
@@ -422,7 +422,7 @@ namespace ArachnaeSwarm
} }
} }
Log.Message($"Strafing Preprocess: {confirmedTargets.Count}/{potentialTargets.Count} cells confirmed after min/max adjustment."); ArachnaeLog.Debug($"Strafing Preprocess: {confirmedTargets.Count}/{potentialTargets.Count} cells confirmed after min/max adjustment.");
return confirmedTargets; return confirmedTargets;
} }
@@ -432,7 +432,7 @@ namespace ArachnaeSwarm
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette"); ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette");
if (flyOverDef == null) if (flyOverDef == null)
{ {
Log.Warning("No fly over def specified for ground strafing fly over"); ArachnaeLog.Debug("No fly over def specified for ground strafing fly over");
return; return;
} }
@@ -472,17 +472,17 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Warning("No confirmed target cells after preprocessing!"); ArachnaeLog.Debug("No confirmed target cells after preprocessing!");
} }
} }
else else
{ {
Log.Error("No potential target cells calculated for ground strafing!"); ArachnaeLog.Debug("No potential target cells calculated for ground strafing!");
} }
} }
else else
{ {
Log.Error("FlyOver def does not have CompGroundStrafing component!"); ArachnaeLog.Debug("FlyOver def does not have CompGroundStrafing component!");
} }
} }
@@ -492,7 +492,7 @@ namespace ArachnaeSwarm
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette"); ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveCorvette");
if (flyOverDef == null) if (flyOverDef == null)
{ {
Log.Warning("No fly over def specified for sector surveillance fly over"); ArachnaeLog.Debug("No fly over def specified for sector surveillance fly over");
return; return;
} }
@@ -510,7 +510,7 @@ namespace ArachnaeSwarm
flyOver.spawnContentsOnImpact = Props.dropContentsOnImpact; flyOver.spawnContentsOnImpact = Props.dropContentsOnImpact;
flyOver.playFlyOverSound = Props.playFlyOverSound; flyOver.playFlyOverSound = Props.playFlyOverSound;
Log.Message($"SectorSurveillance FlyOver created: {flyOver} from {startPos} to {endPos}"); ArachnaeLog.Debug($"SectorSurveillance FlyOver created: {flyOver} from {startPos} to {endPos}");
} }
// 计算垂直线进场路径 // 计算垂直线进场路径
@@ -520,7 +520,7 @@ namespace ArachnaeSwarm
IntVec3 casterPos = parent.pawn.Position; IntVec3 casterPos = parent.pawn.Position;
IntVec3 targetPos = target.Cell; IntVec3 targetPos = target.Cell;
Log.Message($"Calculating perpendicular path: Caster={casterPos}, Target={targetPos}"); ArachnaeLog.Debug($"Calculating perpendicular path: Caster={casterPos}, Target={targetPos}");
// 计算施法者到目标的方向向量 // 计算施法者到目标的方向向量
Vector3 directionToTarget = (targetPos.ToVector3() - casterPos.ToVector3()).normalized; Vector3 directionToTarget = (targetPos.ToVector3() - casterPos.ToVector3()).normalized;
@@ -529,13 +529,13 @@ namespace ArachnaeSwarm
if (directionToTarget == Vector3.zero) if (directionToTarget == Vector3.zero)
{ {
directionToTarget = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized; directionToTarget = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized;
Log.Message($"Using random direction: {directionToTarget}"); ArachnaeLog.Debug($"Using random direction: {directionToTarget}");
} }
// 计算垂直于施法者-目标连线的方向旋转90度 // 计算垂直于施法者-目标连线的方向旋转90度
Vector3 perpendicularDirection = new Vector3(-directionToTarget.z, 0, directionToTarget.x).normalized; Vector3 perpendicularDirection = new Vector3(-directionToTarget.z, 0, directionToTarget.x).normalized;
Log.Message($"Perpendicular direction: {perpendicularDirection}"); ArachnaeLog.Debug($"Perpendicular direction: {perpendicularDirection}");
// 从目标点出发,向垂直方向的两侧延伸找到地图边缘 // 从目标点出发,向垂直方向的两侧延伸找到地图边缘
IntVec3 edge1 = FindMapEdgeInDirection(map, targetPos, perpendicularDirection); IntVec3 edge1 = FindMapEdgeInDirection(map, targetPos, perpendicularDirection);
@@ -553,7 +553,7 @@ namespace ArachnaeSwarm
endPos = edge1; endPos = edge1;
} }
Log.Message($"Perpendicular path: {startPos} -> {targetPos} -> {endPos}"); ArachnaeLog.Debug($"Perpendicular path: {startPos} -> {targetPos} -> {endPos}");
} }
// 在指定方向上找到地图边缘 // 在指定方向上找到地图边缘
@@ -660,7 +660,7 @@ namespace ArachnaeSwarm
} }
// 如果没找到合适的边界点,使用随机边缘位置 // 如果没找到合适的边界点,使用随机边缘位置
Log.Warning($"Could not find map edge in direction {direction}, using random edge"); ArachnaeLog.Debug($"Could not find map edge in direction {direction}, using random edge");
return GetRandomMapEdgePosition(map); return GetRandomMapEdgePosition(map);
} }
@@ -713,7 +713,7 @@ namespace ArachnaeSwarm
case EndPosition.RandomMapEdge: case EndPosition.RandomMapEdge:
endPos = GetRandomMapEdgePosition(map); endPos = GetRandomMapEdgePosition(map);
Log.Message($"Random map edge selected as end position: {endPos}"); ArachnaeLog.Debug($"Random map edge selected as end position: {endPos}");
break; break;
default: default:
@@ -733,13 +733,13 @@ namespace ArachnaeSwarm
if (toCenter == Vector3.zero) if (toCenter == Vector3.zero)
{ {
toCenter = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized; toCenter = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized;
Log.Message($"Using random direction to center: {toCenter}"); ArachnaeLog.Debug($"Using random direction to center: {toCenter}");
} }
Vector3 fromCenter = toCenter; Vector3 fromCenter = toCenter;
IntVec3 oppositeEdge = GetMapEdgePositionFromCenter(map, fromCenter); IntVec3 oppositeEdge = GetMapEdgePositionFromCenter(map, fromCenter);
Log.Message($"Found opposite edge through center: {oppositeEdge}"); ArachnaeLog.Debug($"Found opposite edge through center: {oppositeEdge}");
return oppositeEdge; return oppositeEdge;
} }
@@ -758,12 +758,12 @@ namespace ArachnaeSwarm
if (!testPos.InBounds(map)) if (!testPos.InBounds(map))
{ {
IntVec3 edgePos = FindClosestValidPosition(testPos, map); IntVec3 edgePos = FindClosestValidPosition(testPos, map);
Log.Message($"Found map edge from center: {edgePos} (direction: {direction}, distance: {i})"); ArachnaeLog.Debug($"Found map edge from center: {edgePos} (direction: {direction}, distance: {i})");
return edgePos; return edgePos;
} }
} }
Log.Warning("Could not find map edge from center, using random edge"); ArachnaeLog.Debug("Could not find map edge from center, using random edge");
return GetRandomMapEdgePosition(map); return GetRandomMapEdgePosition(map);
} }
@@ -772,7 +772,7 @@ namespace ArachnaeSwarm
if (direction == Vector3.zero) if (direction == Vector3.zero)
{ {
direction = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized; direction = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized;
Log.Message($"Using random direction: {direction}"); ArachnaeLog.Debug($"Using random direction: {direction}");
} }
IntVec3 center = map.Center; IntVec3 center = map.Center;
@@ -788,12 +788,12 @@ namespace ArachnaeSwarm
if (!testPos.InBounds(map)) if (!testPos.InBounds(map))
{ {
IntVec3 edgePos = FindClosestValidPosition(testPos, map); IntVec3 edgePos = FindClosestValidPosition(testPos, map);
Log.Message($"Found map edge position: {edgePos} (direction: {direction}, distance: {i})"); ArachnaeLog.Debug($"Found map edge position: {edgePos} (direction: {direction}, distance: {i})");
return edgePos; return edgePos;
} }
} }
Log.Warning("Could not find map edge in direction, using random edge"); ArachnaeLog.Debug("Could not find map edge in direction, using random edge");
return GetRandomMapEdgePosition(map); return GetRandomMapEdgePosition(map);
} }
@@ -841,7 +841,7 @@ namespace ArachnaeSwarm
} }
IntVec3 edgePos = new IntVec3(x, 0, z); IntVec3 edgePos = new IntVec3(x, 0, z);
Log.Message($"Random map edge position: {edgePos}"); ArachnaeLog.Debug($"Random map edge position: {edgePos}");
return edgePos; return edgePos;
} }
@@ -853,7 +853,7 @@ namespace ArachnaeSwarm
0, 0,
(int)(direction.z * Props.flyOverDistance)); (int)(direction.z * Props.flyOverDistance));
Log.Message($"Fixed distance position: {endPos} (from {startPos}, distance: {Props.flyOverDistance})"); ArachnaeLog.Debug($"Fixed distance position: {endPos} (from {startPos}, distance: {Props.flyOverDistance})");
return endPos; return endPos;
} }
@@ -864,7 +864,7 @@ namespace ArachnaeSwarm
if (direction == Vector3.zero) if (direction == Vector3.zero)
{ {
direction = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized; direction = new Vector3(Rand.Range(-1f, 1f), 0, Rand.Range(-1f, 1f)).normalized;
Log.Message($"Using random direction: {direction}"); ArachnaeLog.Debug($"Using random direction: {direction}");
} }
return direction; return direction;
@@ -875,7 +875,7 @@ namespace ArachnaeSwarm
ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveShip"); ThingDef flyOverDef = Props.flyOverDef ?? DefDatabase<ThingDef>.GetNamedSilentFail("ARA_HiveShip");
if (flyOverDef == null) if (flyOverDef == null)
{ {
Log.Warning("No fly over def specified for standard fly over"); ArachnaeLog.Debug("No fly over def specified for standard fly over");
return; return;
} }
@@ -896,7 +896,7 @@ namespace ArachnaeSwarm
// 自定义音效逻辑 // 自定义音效逻辑
} }
Log.Message($"Standard FlyOver created: {flyOver} from {startPos} to {endPos}"); ArachnaeLog.Debug($"Standard FlyOver created: {flyOver} from {startPos} to {endPos}");
} }
// 更新技能提示信息 // 更新技能提示信息

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -286,10 +286,10 @@ namespace ArachnaeSwarm
{ {
base.SpawnSetup(map, respawningAfterLoad); base.SpawnSetup(map, respawningAfterLoad);
Log.Message($"FlyOver Spawned - Start: {startPosition}, End: {endPosition}, Speed: {flightSpeed}, Altitude: {altitude}"); ArachnaeLog.Debug($"FlyOver Spawned - Start: {startPosition}, End: {endPosition}, Speed: {flightSpeed}, Altitude: {altitude}");
if (!respawningAfterLoad) if (!respawningAfterLoad)
{ {
Log.Message($"FlyOver Direction - Vector: {MovementDirection}, Rotation: {ExactRotation.eulerAngles}"); ArachnaeLog.Debug($"FlyOver Direction - Vector: {MovementDirection}, Rotation: {ExactRotation.eulerAngles}");
// 设置初始位置 // 设置初始位置
base.Position = startPosition; base.Position = startPosition;
@@ -318,14 +318,14 @@ namespace ArachnaeSwarm
approachOffsetDistance = extension.approachOffsetDistance; approachOffsetDistance = extension.approachOffsetDistance;
} }
Log.Message($"FlyOver approach animation: {useApproachAnimation}, duration: {approachDuration}s, offset: {approachOffsetDistance}"); ArachnaeLog.Debug($"FlyOver approach animation: {useApproachAnimation}, duration: {approachDuration}s, offset: {approachOffsetDistance}");
// 开始飞行音效 // 开始飞行音效
if (playFlyOverSound && def.skyfaller?.floatingSound != null) if (playFlyOverSound && def.skyfaller?.floatingSound != null)
{ {
flightSoundPlaying = def.skyfaller.floatingSound.TrySpawnSustainer( flightSoundPlaying = def.skyfaller.floatingSound.TrySpawnSustainer(
SoundInfo.InMap(new TargetInfo(startPosition, map), MaintenanceType.PerTick)); SoundInfo.InMap(new TargetInfo(startPosition, map), MaintenanceType.PerTick));
Log.Message("FlyOver sound started"); ArachnaeLog.Debug("FlyOver sound started");
} }
} }
} }
@@ -345,7 +345,7 @@ namespace ArachnaeSwarm
{ {
approachCompleted = true; approachCompleted = true;
currentApproachTime = approachDuration; currentApproachTime = approachDuration;
Log.Message("FlyOver approach animation completed"); ArachnaeLog.Debug("FlyOver approach animation completed");
} }
} }
@@ -377,7 +377,7 @@ namespace ArachnaeSwarm
{ {
fadeOutCompleted = true; fadeOutCompleted = true;
currentFadeOutTime = fadeOutDuration; currentFadeOutTime = fadeOutDuration;
Log.Message("FlyOver fade out completed"); ArachnaeLog.Debug("FlyOver fade out completed");
} }
} }
@@ -405,7 +405,7 @@ namespace ArachnaeSwarm
// 基于剩余距离动态计算淡出持续时间 // 基于剩余距离动态计算淡出持续时间
fadeOutDuration = CalculateDynamicFadeOutDuration(); fadeOutDuration = CalculateDynamicFadeOutDuration();
Log.Message($"FlyOver started fade out at progress {currentProgress:F2}, duration: {fadeOutDuration:F2}s, remaining time: {RemainingFlightTime:F2}s"); ArachnaeLog.Debug($"FlyOver started fade out at progress {currentProgress:F2}, duration: {fadeOutDuration:F2}s, remaining time: {RemainingFlightTime:F2}s");
} }
private void UpdatePosition() private void UpdatePosition()
@@ -450,7 +450,7 @@ namespace ArachnaeSwarm
SoundInfo.InMap(new TargetInfo(endPosition, base.Map))); SoundInfo.InMap(new TargetInfo(endPosition, base.Map)));
} }
Log.Message($"FlyOver completed at {endPosition}"); ArachnaeLog.Debug($"FlyOver completed at {endPosition}");
// 销毁自身 // 销毁自身
Destroy(); Destroy();
@@ -464,7 +464,7 @@ namespace ArachnaeSwarm
// 如果还没有开始淡出,使用默认淡出时间 // 如果还没有开始淡出,使用默认淡出时间
fadeOutStarted = true; fadeOutStarted = true;
fadeOutDuration = defaultFadeOutDuration; fadeOutDuration = defaultFadeOutDuration;
Log.Message($"FlyOver emergency destroy with default fade out: {defaultFadeOutDuration}s"); ArachnaeLog.Debug($"FlyOver emergency destroy with default fade out: {defaultFadeOutDuration}s");
} }
// 设置标记,下一帧会处理淡出 // 设置标记,下一帧会处理淡出
@@ -652,11 +652,11 @@ namespace ArachnaeSwarm
if (casterPawn != null && casterPawn.Faction != null) if (casterPawn != null && casterPawn.Faction != null)
{ {
flyOver.faction = casterPawn.Faction; flyOver.faction = casterPawn.Faction;
Log.Message($"FlyOver faction set to: {casterPawn.Faction.Name}"); ArachnaeLog.Debug($"FlyOver faction set to: {casterPawn.Faction.Name}");
} }
else else
{ {
Log.Warning($"FlyOver: Cannot set faction - casterPawn: {casterPawn?.Label ?? "NULL"}, casterFaction: {casterPawn?.Faction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"FlyOver: Cannot set faction - casterPawn: {casterPawn?.Label ?? "NULL"}, casterFaction: {casterPawn?.Faction?.Name ?? "NULL"}");
} }
if (contents != null) if (contents != null)
@@ -666,7 +666,7 @@ namespace ArachnaeSwarm
GenSpawn.Spawn(flyOver, start, map); GenSpawn.Spawn(flyOver, start, map);
Log.Message($"FlyOver created: {flyOver} from {start} to {end} at altitude {height}, Faction: {flyOver.faction?.Name ?? "NULL"}"); ArachnaeLog.Debug($"FlyOver created: {flyOver} from {start} to {end} at altitude {height}, Faction: {flyOver.faction?.Name ?? "NULL"}");
return flyOver; return flyOver;
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -171,13 +171,13 @@ namespace ArachnaeSwarm
var compProps = PropsComp?.Props; var compProps = PropsComp?.Props;
if (compProps?.risingHediff == null) if (compProps?.risingHediff == null)
{ {
Log.Error($"[ConfigurableMutant] risingHediff is not defined in XML for {this.def.defName}"); ArachnaeLog.Debug($"[ConfigurableMutant] risingHediff is not defined in XML for {this.def.defName}");
return; return;
} }
if (!pawn.Dead && !pawn.Downed) if (!pawn.Dead && !pawn.Downed)
{ {
Log.Error("Tried to raise non dead/downed pawn as shambler"); ArachnaeLog.Debug("Tried to raise non dead/downed pawn as shambler");
if(pawn.mutant != null) pawn.mutant.Turn(clearLord: true); if(pawn.mutant != null) pawn.mutant.Turn(clearLord: true);
return; return;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using UnityEngine; using UnityEngine;
using System.Linq; using System.Linq;
@@ -44,7 +44,7 @@ namespace ArachnaeSwarm
var comp = PropsComp; var comp = PropsComp;
if (comp == null || comp.Props.mutantDef == null) if (comp == null || comp.Props.mutantDef == null)
{ {
Log.Error($"[NecroticVirus] HediffComp_NecroticTransformation or its mutantDef is not configured in XML for {this.def.defName}."); ArachnaeLog.Debug($"[NecroticVirus] HediffComp_NecroticTransformation or its mutantDef is not configured in XML for {this.def.defName}.");
return; return;
} }
@@ -67,7 +67,7 @@ namespace ArachnaeSwarm
// 使用我们自己的、更安全的检查方法 // 使用我们自己的、更安全的检查方法
if (!NecroticTransformationUtility.CanResurrect(pawn.Corpse)) if (!NecroticTransformationUtility.CanResurrect(pawn.Corpse))
{ {
Log.Warning($"[NecroticVirus] Pawn {pawn.LabelShort} does not meet conditions for resurrection."); ArachnaeLog.Debug($"[NecroticVirus] Pawn {pawn.LabelShort} does not meet conditions for resurrection.");
return; return;
} }
@@ -96,7 +96,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"[NecroticVirus] Error during transformation: {ex}"); ArachnaeLog.Debug($"[NecroticVirus] Error during transformation: {ex}");
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -31,7 +31,7 @@ namespace ArachnaeSwarm
{ {
if (this.props == null) if (this.props == null)
{ {
Log.Error("HediffComp_TopTurret: props is null"); ArachnaeLog.Debug("HediffComp_TopTurret: props is null");
return null; return null;
} }
return this.props as HediffCompProperties_TopTurret; return this.props as HediffCompProperties_TopTurret;
@@ -76,7 +76,7 @@ namespace ArachnaeSwarm
{ {
if (this.gun == null) if (this.gun == null)
{ {
Log.Warning("HediffComp_TopTurret: gun is null"); ArachnaeLog.Debug("HediffComp_TopTurret: gun is null");
return null; return null;
} }
return this.gun.TryGetComp<CompEquippable>(); return this.gun.TryGetComp<CompEquippable>();
@@ -90,7 +90,7 @@ namespace ArachnaeSwarm
var comp = this.GunCompEq; var comp = this.GunCompEq;
if (comp == null) if (comp == null)
{ {
Log.Warning("HediffComp_TopTurret: GunCompEq is null"); ArachnaeLog.Debug("HediffComp_TopTurret: GunCompEq is null");
return null; return null;
} }
return comp.PrimaryVerb; return comp.PrimaryVerb;
@@ -170,7 +170,7 @@ namespace ArachnaeSwarm
// 添加 null 检查 // 添加 null 检查
if (this.Props == null) if (this.Props == null)
{ {
Log.Error("HediffComp_TopTurret: Props is null in CompPostMake"); ArachnaeLog.Debug("HediffComp_TopTurret: Props is null in CompPostMake");
return; return;
} }
@@ -182,13 +182,13 @@ namespace ArachnaeSwarm
// 添加详细的 null 检查 // 添加详细的 null 检查
if (this.Props == null) if (this.Props == null)
{ {
Log.Error("HediffComp_TopTurret: Props is null in MakeGun"); ArachnaeLog.Debug("HediffComp_TopTurret: Props is null in MakeGun");
return; return;
} }
if (this.Props.turretDef == null) if (this.Props.turretDef == null)
{ {
Log.Error("HediffComp_TopTurret: Props.turretDef is null"); ArachnaeLog.Debug("HediffComp_TopTurret: Props.turretDef is null");
return; return;
} }
@@ -197,14 +197,14 @@ namespace ArachnaeSwarm
this.gun = ThingMaker.MakeThing(this.Props.turretDef, null); this.gun = ThingMaker.MakeThing(this.Props.turretDef, null);
if (this.gun == null) if (this.gun == null)
{ {
Log.Error($"HediffComp_TopTurret: Failed to create gun from turretDef '{this.Props.turretDef.defName}'"); ArachnaeLog.Debug($"HediffComp_TopTurret: Failed to create gun from turretDef '{this.Props.turretDef.defName}'");
return; return;
} }
this.UpdateGunVerbs(); this.UpdateGunVerbs();
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"HediffComp_TopTurret: Exception in MakeGun: {ex}"); ArachnaeLog.Debug($"HediffComp_TopTurret: Exception in MakeGun: {ex}");
} }
} }
@@ -212,14 +212,14 @@ namespace ArachnaeSwarm
{ {
if (this.gun == null) if (this.gun == null)
{ {
Log.Warning("HediffComp_TopTurret: gun is null in UpdateGunVerbs"); ArachnaeLog.Debug("HediffComp_TopTurret: gun is null in UpdateGunVerbs");
return; return;
} }
var comp = this.gun.TryGetComp<CompEquippable>(); var comp = this.gun.TryGetComp<CompEquippable>();
if (comp == null) if (comp == null)
{ {
Log.Warning("HediffComp_TopTurret: CompEquippable is null"); ArachnaeLog.Debug("HediffComp_TopTurret: CompEquippable is null");
return; return;
} }
@@ -305,7 +305,7 @@ namespace ArachnaeSwarm
{ {
if (this.gun == null) if (this.gun == null)
{ {
Log.Error("CompTurrentGun had null gun after loading. Recreating."); ArachnaeLog.Debug("CompTurrentGun had null gun after loading. Recreating.");
this.MakeGun(); this.MakeGun();
return; return;
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
namespace ArachnaeSwarm namespace ArachnaeSwarm
@@ -90,7 +90,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in CompHediffTerrainSpawn.DoTerrainSpawn: {ex}"); ArachnaeLog.Debug($"Error in CompHediffTerrainSpawn.DoTerrainSpawn: {ex}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Linq; // For LINQ operations using System.Linq; // For LINQ operations
@@ -40,7 +40,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"[ArachnaeSwarm] Master {masterPawn.LabelShort} tried to bind a drone but does not have Hediff_HiveMindMaster."); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {masterPawn.LabelShort} tried to bind a drone but does not have Hediff_HiveMindMaster.");
} }
} }
} }
@@ -54,7 +54,7 @@ namespace ArachnaeSwarm
if (dronePawn.Faction != masterPawn.Faction) if (dronePawn.Faction != masterPawn.Faction)
{ {
dronePawn.SetFaction(masterPawn.Faction, masterPawn); dronePawn.SetFaction(masterPawn.Faction, masterPawn);
Log.Message($"Converted {dronePawn.LabelShort} from {dronePawn.Faction?.Name ?? "null"} to {masterPawn.Faction?.Name}"); ArachnaeLog.Debug($"Converted {dronePawn.LabelShort} from {dronePawn.Faction?.Name ?? "null"} to {masterPawn.Faction?.Name}");
} }
// 2. 移除 ARA_NonPlayer_HiveMindDroneHediff // 2. 移除 ARA_NonPlayer_HiveMindDroneHediff
@@ -62,7 +62,7 @@ namespace ArachnaeSwarm
if (nonPlayerHediff != null) if (nonPlayerHediff != null)
{ {
dronePawn.health.RemoveHediff(nonPlayerHediff); dronePawn.health.RemoveHediff(nonPlayerHediff);
Log.Message($"Removed ARA_NonPlayer_HiveMindDroneHediff from {dronePawn.LabelShort}"); ArachnaeLog.Debug($"Removed ARA_NonPlayer_HiveMindDroneHediff from {dronePawn.LabelShort}");
} }
// 3. 添加 ARA_HiveMindDrone // 3. 添加 ARA_HiveMindDrone
@@ -70,7 +70,7 @@ namespace ArachnaeSwarm
if (hiveMindDroneDef != null && !dronePawn.health.hediffSet.HasHediff(hiveMindDroneDef)) if (hiveMindDroneDef != null && !dronePawn.health.hediffSet.HasHediff(hiveMindDroneDef))
{ {
dronePawn.health.AddHediff(hiveMindDroneDef); dronePawn.health.AddHediff(hiveMindDroneDef);
Log.Message($"Added ARA_HiveMindDrone to {dronePawn.LabelShort}"); ArachnaeLog.Debug($"Added ARA_HiveMindDrone to {dronePawn.LabelShort}");
} }
// 4. 尝试绑定到主节点 // 4. 尝试绑定到主节点
@@ -80,18 +80,18 @@ namespace ArachnaeSwarm
if (masterHediff.TryBindDrone(dronePawn)) if (masterHediff.TryBindDrone(dronePawn))
{ {
Messages.Message("ARA_BindDrone_ConversionSuccess".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.PositiveEvent, historical: false); Messages.Message("ARA_BindDrone_ConversionSuccess".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.PositiveEvent, historical: false);
Log.Message($"Successfully bound converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}"); ArachnaeLog.Debug($"Successfully bound converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}");
} }
else else
{ {
Messages.Message("ARA_BindDrone_ConversionFailure".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false); Messages.Message("ARA_BindDrone_ConversionFailure".Translate(dronePawn.LabelShort, masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false);
Log.Warning($"Failed to bind converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}"); ArachnaeLog.Debug($"Failed to bind converted drone {dronePawn.LabelShort} to master {masterPawn.LabelShort}");
} }
} }
else else
{ {
Messages.Message("ARA_BindDrone_NoMasterForConversion".Translate(masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false); Messages.Message("ARA_BindDrone_NoMasterForConversion".Translate(masterPawn.LabelShort), MessageTypeDefOf.NegativeEvent, historical: false);
Log.Error($"[ArachnaeSwarm] Master {masterPawn.LabelShort} tried to convert a non-player drone but does not have Hediff_HiveMindMaster."); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {masterPawn.LabelShort} tried to convert a non-player drone but does not have Hediff_HiveMindMaster.");
} }
} }

View File

@@ -1,4 +1,4 @@
using Verse; using Verse;
using RimWorld; using RimWorld;
namespace ArachnaeSwarm namespace ArachnaeSwarm
@@ -42,7 +42,7 @@ namespace ArachnaeSwarm
if (ticksUnlinked >= Props.unlinkedDieDelayTicks) if (ticksUnlinked >= Props.unlinkedDieDelayTicks)
{ {
Log.Message($"[ArachnaeSwarm] Drone {parent.pawn.LabelShort} was unlinked from master for too long and will die. Forcing death."); ArachnaeLog.Debug($"[ArachnaeSwarm] Drone {parent.pawn.LabelShort} was unlinked from master for too long and will die. Forcing death.");
// Ensure the pawn is killed only once and prevent further ticks // Ensure the pawn is killed only once and prevent further ticks
if (!parent.pawn.Dead && !parent.pawn.Destroyed) if (!parent.pawn.Dead && !parent.pawn.Destroyed)
{ {

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -51,26 +51,26 @@ namespace ArachnaeSwarm
{ {
if (drone == null || drone.Dead || !drone.Spawned || drone.Map != this.pawn.Map) if (drone == null || drone.Dead || !drone.Spawned || drone.Map != this.pawn.Map)
{ {
Log.Message($"[ArachnaeSwarm] Cannot bind drone {drone?.LabelShort ?? "null"}: Invalid pawn state."); ArachnaeLog.Debug($"[ArachnaeSwarm] Cannot bind drone {drone?.LabelShort ?? "null"}: Invalid pawn state.");
return false; return false;
} }
Hediff_HiveMindDrone droneHediff = drone.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindDrone")) as Hediff_HiveMindDrone; Hediff_HiveMindDrone droneHediff = drone.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindDrone")) as Hediff_HiveMindDrone;
if (droneHediff == null) if (droneHediff == null)
{ {
Log.Message($"[ArachnaeSwarm] Cannot bind drone {drone.LabelShort}: Does not have ARA_HiveMindDrone hediff."); ArachnaeLog.Debug($"[ArachnaeSwarm] Cannot bind drone {drone.LabelShort}: Does not have ARA_HiveMindDrone hediff.");
return false; return false;
} }
if (droneHediff.target != null && droneHediff.target != this.pawn) if (droneHediff.target != null && droneHediff.target != this.pawn)
{ {
Log.Message($"[ArachnaeSwarm] Cannot bind drone {drone.LabelShort}: Already bound to another master ({droneHediff.target.LabelShort})."); ArachnaeLog.Debug($"[ArachnaeSwarm] Cannot bind drone {drone.LabelShort}: Already bound to another master ({droneHediff.target.LabelShort}).");
return false; return false;
} }
if (drones.Contains(drone)) if (drones.Contains(drone))
{ {
Log.Message($"[ArachnaeSwarm] Drone {drone.LabelShort} is already bound to this master."); ArachnaeLog.Debug($"[ArachnaeSwarm] Drone {drone.LabelShort} is already bound to this master.");
return false; return false;
} }
@@ -80,7 +80,7 @@ namespace ArachnaeSwarm
droneHediff.target = this.pawn; // Set the drone's target to this master droneHediff.target = this.pawn; // Set the drone's target to this master
drones.Add(drone); drones.Add(drone);
UpdateSeverity(); UpdateSeverity();
Log.Message($"[ArachnaeSwarm] Master {this.pawn.LabelShort} successfully bound drone {drone.LabelShort}."); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {this.pawn.LabelShort} successfully bound drone {drone.LabelShort}.");
return true; return true;
} }
@@ -101,12 +101,12 @@ namespace ArachnaeSwarm
if (drone.Ideo != masterIdeo) if (drone.Ideo != masterIdeo)
{ {
drone.ideo.SetIdeo(masterIdeo); drone.ideo.SetIdeo(masterIdeo);
Log.Message($"[ArachnaeSwarm] Set drone {drone.LabelShort} ideology to master's ideology: {masterIdeo.name}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Set drone {drone.LabelShort} ideology to master's ideology: {masterIdeo.name}");
} }
} }
else else
{ {
Log.Warning($"[ArachnaeSwarm] Master {this.pawn.LabelShort} has no ideology to assign to drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {this.pawn.LabelShort} has no ideology to assign to drone {drone.LabelShort}");
} }
// 强制同步文化相关记忆和状态 // 强制同步文化相关记忆和状态
@@ -114,7 +114,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Message($"[ArachnaeSwarm] Ideology DLC not active, skipping cultural assignment for drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Ideology DLC not active, skipping cultural assignment for drone {drone.LabelShort}");
} }
} }
@@ -142,7 +142,7 @@ namespace ArachnaeSwarm
if (thoughtsToRemove.Count > 0) if (thoughtsToRemove.Count > 0)
{ {
Log.Message($"[ArachnaeSwarm] Removed {thoughtsToRemove.Count} cultural conflict thoughts from drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Removed {thoughtsToRemove.Count} cultural conflict thoughts from drone {drone.LabelShort}");
} }
// 添加蜂群文化适应的正面想法 // 添加蜂群文化适应的正面想法
@@ -154,11 +154,11 @@ namespace ArachnaeSwarm
} }
// 同步服装和文化偏好 // 同步服装和文化偏好
Log.Message($"[ArachnaeSwarm] Successfully synchronized cultural memories for drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Successfully synchronized cultural memories for drone {drone.LabelShort}");
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"[ArachnaeSwarm] Error synchronizing cultural memories for drone {drone.LabelShort}: {ex.Message}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Error synchronizing cultural memories for drone {drone.LabelShort}: {ex.Message}");
} }
} }
@@ -188,7 +188,7 @@ namespace ArachnaeSwarm
droneHediff.target = this.pawn; // Set the drone's target to this master droneHediff.target = this.pawn; // Set the drone's target to this master
drones.Add(drone); drones.Add(drone);
Log.Message($"[ArachnaeSwarm] Master {this.pawn.LabelShort} automatically bound drone {drone.LabelShort}."); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {this.pawn.LabelShort} automatically bound drone {drone.LabelShort}.");
boundCount++; boundCount++;
} }
} }
@@ -222,7 +222,7 @@ namespace ArachnaeSwarm
{ {
if (drone != null && !drone.Dead) if (drone != null && !drone.Dead)
{ {
Log.Message($"[ArachnaeSwarm] Master {pawn.LabelShort} died, killing drone {drone.LabelShort}."); ArachnaeLog.Debug($"[ArachnaeSwarm] Master {pawn.LabelShort} died, killing drone {drone.LabelShort}.");
drone.Kill(null, this); drone.Kill(null, this);
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -30,7 +30,7 @@ namespace ArachnaeSwarm
// 回退逻辑:如果配置的 DefName 无效,使用 AcidBurn // 回退逻辑:如果配置的 DefName 无效,使用 AcidBurn
if (_resolvedDamageDef == null) if (_resolvedDamageDef == null)
{ {
Log.Error($"[DragonianMix] 未找到 DamageDef: {damageDefName}, 已回退到 AcidBurn"); ArachnaeLog.Debug($"[DragonianMix] 未找到 DamageDef: {damageDefName}, 已回退到 AcidBurn");
_resolvedDamageDef = DamageDefOf.AcidBurn; _resolvedDamageDef = DamageDefOf.AcidBurn;
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -54,7 +54,7 @@ namespace ArachnaeSwarm
if (this.Pawn == null || this.Pawn.Map == null || Props.pawnKindDefs.NullOrEmpty()) if (this.Pawn == null || this.Pawn.Map == null || Props.pawnKindDefs.NullOrEmpty())
{ {
Log.Warning("ArachnaeSwarm: HediffComp_SpawnPawnOnRemoved tried to spawn a pawn but required data was missing (Pawn, Map, or pawnKindDefs)."); ArachnaeLog.Debug("ArachnaeSwarm: HediffComp_SpawnPawnOnRemoved tried to spawn a pawn but required data was missing (Pawn, Map, or pawnKindDefs).");
return; return;
} }
@@ -87,7 +87,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error($"ArachnaeSwarm: Failed to generate pawn of kind {selectedPawnKindDef.defName}."); ArachnaeLog.Debug($"ArachnaeSwarm: Failed to generate pawn of kind {selectedPawnKindDef.defName}.");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
@@ -12,7 +12,7 @@ namespace ArachnaeSwarm.MoharHediffs
{ {
if (parentHediff.pawn != null && parentHediff.def.defName != null && debug) if (parentHediff.pawn != null && parentHediff.def.defName != null && debug)
{ {
Log.Warning(parentHediff.pawn.Label + "'s Hediff: " + parentHediff.def.defName + " says goodbye."); ArachnaeLog.Debug(parentHediff.pawn.Label + "'s Hediff: " + parentHediff.def.defName + " says goodbye.");
} }
parentHediff.Severity = 0f; parentHediff.Severity = 0f;
} }
@@ -24,14 +24,14 @@ namespace ArachnaeSwarm.MoharHediffs
{ {
if (debug) if (debug)
{ {
Log.Warning("GetPawnAgeOverlifeExpectancyRatio pawn NOT OK"); ArachnaeLog.Debug("GetPawnAgeOverlifeExpectancyRatio pawn NOT OK");
} }
return result; return result;
} }
result = pawn.ageTracker.AgeBiologicalYearsFloat / pawn.RaceProps.lifeExpectancy; result = pawn.ageTracker.AgeBiologicalYearsFloat / pawn.RaceProps.lifeExpectancy;
if (debug) if (debug)
{ {
Log.Warning(string.Concat(new string[] ArachnaeLog.Debug(string.Concat(new string[]
{ {
pawn.Label, pawn.Label,
" Age: ", " Age: ",
@@ -51,7 +51,7 @@ namespace ArachnaeSwarm.MoharHediffs
{ {
if (debug) if (debug)
{ {
Log.Warning("pawn is null - wounded "); ArachnaeLog.Debug("pawn is null - wounded ");
} }
return false; return false;
} }
@@ -66,7 +66,7 @@ namespace ArachnaeSwarm.MoharHediffs
} }
if (debug && num > 0f) if (debug && num > 0f)
{ {
Log.Warning(pawn.Label + " is wounded "); ArachnaeLog.Debug(pawn.Label + " is wounded ");
} }
return num > 0f; return num > 0f;
} }
@@ -77,14 +77,14 @@ namespace ArachnaeSwarm.MoharHediffs
{ {
if (debug) if (debug)
{ {
Log.Warning("pawn is null - IsHungry "); ArachnaeLog.Debug("pawn is null - IsHungry ");
} }
return false; return false;
} }
bool flag = pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving; bool flag = pawn.needs.food != null && pawn.needs.food.CurCategory == HungerCategory.Starving;
if (debug && flag) if (debug && flag)
{ {
Log.Warning(pawn.Label + " is hungry "); ArachnaeLog.Debug(pawn.Label + " is hungry ");
} }
return flag; return flag;
} }
@@ -98,7 +98,7 @@ namespace ArachnaeSwarm.MoharHediffs
{ {
if (debug) if (debug)
{ {
Log.Warning(warning); ArachnaeLog.Debug(warning);
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using HarmonyLib; using HarmonyLib;
@@ -88,7 +88,7 @@ namespace ArachnaeSwarm
catch (Exception ex) catch (Exception ex)
{ {
isApplyingExtraDamage = false; isApplyingExtraDamage = false;
Log.Error($"[ArachnaeSwarm] Error in PostApplyDamage patch: {ex}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Error in PostApplyDamage patch: {ex}");
} }
} }
@@ -152,7 +152,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"[ArachnaeSwarm] Error in ApplyHediffEffect: {ex}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Error in ApplyHediffEffect: {ex}");
} }
} }
@@ -204,7 +204,7 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"[ArachnaeSwarm] Error in ApplyExtraDamage: {ex}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Error in ApplyExtraDamage: {ex}");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
@@ -72,7 +72,7 @@ namespace ArachnaeSwarm
if (actor.carryTracker.CarriedThing == null) if (actor.carryTracker.CarriedThing == null)
{ {
Log.Error(actor + " is not carrying anything to refuel with."); ArachnaeLog.Debug(actor + " is not carrying anything to refuel with.");
// The correct way to end the job from within a Toil's action. // The correct way to end the job from within a Toil's action.
actor.jobs.EndCurrentJob(JobCondition.Incompletable); actor.jobs.EndCurrentJob(JobCondition.Incompletable);
return; return;

View File

@@ -1,21 +0,0 @@
using Verse;
using HarmonyLib;
using System.Reflection;
namespace ArachnaeSwarm
{
// [StaticConstructorOnStartup] 属性确保这个类的静态构造函数在游戏启动时被调用
[StaticConstructorOnStartup]
public static class MainHarmony
{
static MainHarmony()
{
// 创建一个 Harmony 实例。ID 应该是唯一的,通常使用 "作者.Mod名称" 的格式。
var harmony = new Harmony("com.kalospacer.arachnaeswarm");
// Harmony 会自动扫描当前整个程序集(我们的 .dll 文件),
// 寻找所有带有 [HarmonyPatch] 属性的类,并应用它们。
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}
}

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Verse; using Verse;
@@ -61,7 +61,7 @@ namespace ArachnaeSwarm
var extension = def.GetModExtension<MentalStateDefExtension_HiveMindCascade>(); var extension = def.GetModExtension<MentalStateDefExtension_HiveMindCascade>();
if (extension?.mentalStatesToSpread == null || extension.mentalStatesToSpread.Count == 0) if (extension?.mentalStatesToSpread == null || extension.mentalStatesToSpread.Count == 0)
{ {
Log.Error($"[ArachnaeSwarm] MentalState_HiveMindCascade: No mentalStatesToSpread defined for {def.defName}"); ArachnaeLog.Debug($"[ArachnaeSwarm] MentalState_HiveMindCascade: No mentalStatesToSpread defined for {def.defName}");
hasCascaded = true; hasCascaded = true;
return; return;
} }
@@ -70,7 +70,7 @@ namespace ArachnaeSwarm
var masterHediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindMaster")) as Hediff_HiveMindMaster; var masterHediff = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("ARA_HiveMindMaster")) as Hediff_HiveMindMaster;
if (masterHediff == null) if (masterHediff == null)
{ {
Log.Warning($"[ArachnaeSwarm] MentalState_HiveMindCascade: Pawn {pawn.LabelShort} does not have ARA_HiveMindMaster hediff"); ArachnaeLog.Debug($"[ArachnaeSwarm] MentalState_HiveMindCascade: Pawn {pawn.LabelShort} does not have ARA_HiveMindMaster hediff");
hasCascaded = true; hasCascaded = true;
return; return;
} }
@@ -79,7 +79,7 @@ namespace ArachnaeSwarm
var drones = GetDronesFromMaster(masterHediff); var drones = GetDronesFromMaster(masterHediff);
if (drones == null || drones.Count == 0) if (drones == null || drones.Count == 0)
{ {
Log.Message($"[ArachnaeSwarm] MentalState_HiveMindCascade: No drones found for master {pawn.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] MentalState_HiveMindCascade: No drones found for master {pawn.LabelShort}");
hasCascaded = true; hasCascaded = true;
return; return;
} }
@@ -99,15 +99,15 @@ namespace ArachnaeSwarm
if (drone.mindState.mentalStateHandler.TryStartMentalState(randomMentalState, "HiveMindCascade", forced: true)) if (drone.mindState.mentalStateHandler.TryStartMentalState(randomMentalState, "HiveMindCascade", forced: true))
{ {
spreadCount++; spreadCount++;
Log.Message($"[ArachnaeSwarm] Cascaded {randomMentalState.defName} to drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Cascaded {randomMentalState.defName} to drone {drone.LabelShort}");
} }
else else
{ {
Log.Warning($"[ArachnaeSwarm] Failed to cascade {randomMentalState.defName} to drone {drone.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Failed to cascade {randomMentalState.defName} to drone {drone.LabelShort}");
} }
} }
Log.Message($"[ArachnaeSwarm] HiveMindCascade: Successfully spread {spreadCount} mental breaks to drones"); ArachnaeLog.Debug($"[ArachnaeSwarm] HiveMindCascade: Successfully spread {spreadCount} mental breaks to drones");
hasCascaded = true; hasCascaded = true;
// 显示级联完成的消息 // 显示级联完成的消息
@@ -138,11 +138,11 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"[ArachnaeSwarm] Failed to access drones field via reflection: {ex.Message}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Failed to access drones field via reflection: {ex.Message}");
} }
// 方法3: 如果以上都失败,尝试通过其他方式 // 方法3: 如果以上都失败,尝试通过其他方式
Log.Error($"[ArachnaeSwarm] Could not access drones list from HiveMindMaster"); ArachnaeLog.Debug($"[ArachnaeSwarm] Could not access drones list from HiveMindMaster");
return new List<Pawn>(); return new List<Pawn>();
} }
@@ -197,14 +197,14 @@ namespace ArachnaeSwarm
if (!hasHiveMindMaster) if (!hasHiveMindMaster)
{ {
Log.Message($"[ArachnaeSwarm] MentalBreakWorker_HiveMindCascade: Pawn {pawn.LabelShort} does not have ARA_HiveMindMaster, cannot start cascade"); ArachnaeLog.Debug($"[ArachnaeSwarm] MentalBreakWorker_HiveMindCascade: Pawn {pawn.LabelShort} does not have ARA_HiveMindMaster, cannot start cascade");
return false; return false;
} }
// 调用基类方法启动精神状态 // 调用基类方法启动精神状态
if (base.TryStart(pawn, reason, causedByMood)) if (base.TryStart(pawn, reason, causedByMood))
{ {
Log.Message($"[ArachnaeSwarm] Started HiveMindCascade mental state on {pawn.LabelShort}"); ArachnaeLog.Debug($"[ArachnaeSwarm] Started HiveMindCascade mental state on {pawn.LabelShort}");
return true; return true;
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
using RimWorld; using RimWorld;
@@ -63,7 +63,7 @@ namespace ArachnaeSwarm
{ {
AddHediffsToPawn(pawn); AddHediffsToPawn(pawn);
hediffsApplied = true; hediffsApplied = true;
Log.Message($"Debug: Applied hediffs to {pawn.Label}"); ArachnaeLog.Debug($"Debug: Applied hediffs to {pawn.Label}");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
using RimWorld; using RimWorld;
@@ -112,11 +112,11 @@ namespace ArachnaeSwarm
{ {
if (skillRecord.Level > originalLevel) if (skillRecord.Level > originalLevel)
{ {
Log.Message($"{pawn.LabelShort} gained {experienceToGive} experience in {skillExp.skillDef.label} (Level up: {originalLevel} -> {skillRecord.Level})"); ArachnaeLog.Debug($"{pawn.LabelShort} gained {experienceToGive} experience in {skillExp.skillDef.label} (Level up: {originalLevel} -> {skillRecord.Level})");
} }
else else
{ {
Log.Message($"{pawn.LabelShort} gained {experienceToGive} experience in {skillExp.skillDef.label} (Current level: {skillRecord.Level}, Progress: {skillRecord.xpSinceLastLevel}/{skillRecord.XpRequiredForLevelUp})"); ArachnaeLog.Debug($"{pawn.LabelShort} gained {experienceToGive} experience in {skillExp.skillDef.label} (Current level: {skillRecord.Level}, Progress: {skillRecord.xpSinceLastLevel}/{skillRecord.XpRequiredForLevelUp})");
} }
} }
} }
@@ -124,7 +124,7 @@ namespace ArachnaeSwarm
catch (Exception ex) catch (Exception ex)
{ {
// 记录错误但继续处理其他技能 // 记录错误但继续处理其他技能
Log.Warning($"Error giving experience to {pawn.LabelShort} for skill {skillExp.skillDef?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error giving experience to {pawn.LabelShort} for skill {skillExp.skillDef?.defName}: {ex.Message}");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -62,7 +62,7 @@ namespace ArachnaeSwarm
HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp<HediffComp_Disappears>(); HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp<HediffComp_Disappears>();
if (hediffComp_Disappears == null) if (hediffComp_Disappears == null)
{ {
Log.Error("HediffComp_GiveHediffsInRangeToRace has a hediff in props which does not have a HediffComp_Disappears"); ArachnaeLog.Debug("HediffComp_GiveHediffsInRangeToRace has a hediff in props which does not have a HediffComp_Disappears");
} }
else else
{ {

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -99,11 +99,11 @@ namespace ArachnaeSwarm
// 添加:如果有关闭 Hediff不处理缺失的寿命 Hediff // 添加:如果有关闭 Hediff不处理缺失的寿命 Hediff
if (HasShutdownHediff) if (HasShutdownHediff)
{ {
Log.Message($"Lifespan hediff missing for {pawn.Label}, but shutdown hediff is present. This is expected behavior."); ArachnaeLog.Debug($"Lifespan hediff missing for {pawn.Label}, but shutdown hediff is present. This is expected behavior.");
return; return;
} }
Log.Warning($"Lifespan hediff missing for {pawn.Label}. This should not happen. Forcing death."); ArachnaeLog.Debug($"Lifespan hediff missing for {pawn.Label}. This should not happen. Forcing death.");
// 立即处死pawn // 立即处死pawn
if (!pawn.Dead) if (!pawn.Dead)
@@ -138,7 +138,7 @@ namespace ArachnaeSwarm
var existingHediff = pawn.health.hediffSet.GetFirstHediffOfDef(Props.lifespanHediff); var existingHediff = pawn.health.hediffSet.GetFirstHediffOfDef(Props.lifespanHediff);
if (existingHediff != null) if (existingHediff != null)
{ {
Log.Message($"Shutdown hediff present for {pawn.Label}. Removing lifespan hediff."); ArachnaeLog.Debug($"Shutdown hediff present for {pawn.Label}. Removing lifespan hediff.");
pawn.health.RemoveHediff(existingHediff); pawn.health.RemoveHediff(existingHediff);
lifespanHediff = null; lifespanHediff = null;
} }
@@ -159,7 +159,7 @@ namespace ArachnaeSwarm
{ {
// 初始化Hediff的严重程度为当前剩余寿命比例 // 初始化Hediff的严重程度为当前剩余寿命比例
lifespanHediff.Severity = PercentFull; lifespanHediff.Severity = PercentFull;
Log.Message($"Created lifespan hediff for {pawn.Label} with severity {lifespanHediff.Severity:P2}"); ArachnaeLog.Debug($"Created lifespan hediff for {pawn.Label} with severity {lifespanHediff.Severity:P2}");
} }
} }
@@ -191,7 +191,7 @@ namespace ArachnaeSwarm
var hediff = GetOrCreateLifespanHediff(); var hediff = GetOrCreateLifespanHediff();
if (hediff == null) if (hediff == null)
{ {
Log.Warning($"Failed to get or create lifespan hediff for {pawn.Label}"); ArachnaeLog.Debug($"Failed to get or create lifespan hediff for {pawn.Label}");
return; return;
} }
@@ -205,7 +205,7 @@ namespace ArachnaeSwarm
// 以Hediff的数据为准 // 以Hediff的数据为准
if (Mathf.Abs(hediffTicksLeft - powerTicksLeft) > 1000) // 只在校正值较大时记录 if (Mathf.Abs(hediffTicksLeft - powerTicksLeft) > 1000) // 只在校正值较大时记录
{ {
Log.Message($"Lifespan sync: Component had {powerTicksLeft}, Hediff had {hediffTicksLeft}. Using Hediff value."); ArachnaeLog.Debug($"Lifespan sync: Component had {powerTicksLeft}, Hediff had {hediffTicksLeft}. Using Hediff value.");
} }
powerTicksLeft = hediffTicksLeft; powerTicksLeft = hediffTicksLeft;
} }
@@ -229,20 +229,20 @@ namespace ArachnaeSwarm
// 添加:如果有关闭 Hediff不写入数据 // 添加:如果有关闭 Hediff不写入数据
if (HasShutdownHediff) if (HasShutdownHediff)
{ {
Log.Message($"Cannot write comp data to hediff: Shutdown hediff is present for {pawn.Label}"); ArachnaeLog.Debug($"Cannot write comp data to hediff: Shutdown hediff is present for {pawn.Label}");
return; return;
} }
var hediff = GetOrCreateLifespanHediff(); var hediff = GetOrCreateLifespanHediff();
if (hediff == null) if (hediff == null)
{ {
Log.Warning($"Failed to get or create lifespan hediff for {pawn.Label}"); ArachnaeLog.Debug($"Failed to get or create lifespan hediff for {pawn.Label}");
return; return;
} }
// 直接将Comp的数据写入Hediff // 直接将Comp的数据写入Hediff
hediff.Severity = PercentFull; hediff.Severity = PercentFull;
Log.Message($"Debug: Wrote comp data to hediff - Severity: {hediff.Severity:P4}, TicksLeft: {powerTicksLeft}"); ArachnaeLog.Debug($"Debug: Wrote comp data to hediff - Severity: {hediff.Severity:P4}, TicksLeft: {powerTicksLeft}");
} }
// 新增定期校验Hediff状态 // 新增定期校验Hediff状态
@@ -263,7 +263,7 @@ namespace ArachnaeSwarm
{ {
pawn.health.RemoveHediff(existingHediff); pawn.health.RemoveHediff(existingHediff);
lifespanHediff = null; lifespanHediff = null;
Log.Message($"Removed lifespan hediff for {pawn.Label} due to shutdown hediff presence"); ArachnaeLog.Debug($"Removed lifespan hediff for {pawn.Label} due to shutdown hediff presence");
} }
return; return;
} }
@@ -335,7 +335,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Message($"Skipping lifespan hediff creation for {parent.Label} due to shutdown hediff"); ArachnaeLog.Debug($"Skipping lifespan hediff creation for {parent.Label} due to shutdown hediff");
} }
} }
} }
@@ -382,7 +382,7 @@ namespace ArachnaeSwarm
$"Shutdown Hediff Def: {Props.immuteHediff?.defName ?? "None"}\n" + $"Shutdown Hediff Def: {Props.immuteHediff?.defName ?? "None"}\n" +
$"实际存在: {(Props.immuteHediff != null ? pawn.health.hediffSet.HasHediff(Props.immuteHediff).ToString() : "N/A")}"; $"实际存在: {(Props.immuteHediff != null ? pawn.health.hediffSet.HasHediff(Props.immuteHediff).ToString() : "N/A")}";
Messages.Message(message, MessageTypeDefOf.SilentInput); Messages.Message(message, MessageTypeDefOf.SilentInput);
Log.Message(message); ArachnaeLog.Debug(message);
} }
} }
}; };
@@ -402,7 +402,7 @@ namespace ArachnaeSwarm
powerTicksLeft = (int)(Props.lifetimeDays * 60000); powerTicksLeft = (int)(Props.lifetimeDays * 60000);
WriteCompDataToHediff(); // 使用新的写入方法 WriteCompDataToHediff(); // 使用新的写入方法
Log.Message($"已补满寿命: {parent.Label} 剩余 {DaysLeft:F1} 天"); ArachnaeLog.Debug($"已补满寿命: {parent.Label} 剩余 {DaysLeft:F1} 天");
Messages.Message($"已补满寿命: {Props.lifetimeDays} 天", MessageTypeDefOf.SilentInput); Messages.Message($"已补满寿命: {Props.lifetimeDays} 天", MessageTypeDefOf.SilentInput);
} }
}; };
@@ -424,7 +424,7 @@ namespace ArachnaeSwarm
powerTicksLeft = (int)(totalTicks * 0.0001f); // 0.01% powerTicksLeft = (int)(totalTicks * 0.0001f); // 0.01%
WriteCompDataToHediff(); // 使用新的写入方法 WriteCompDataToHediff(); // 使用新的写入方法
float daysLeft = (float)powerTicksLeft / 60000f; float daysLeft = (float)powerTicksLeft / 60000f;
Log.Message($"已设置剩余0.01%寿命: {parent.Label} 剩余 {daysLeft:F4} 天 ({PercentFull:P2})"); ArachnaeLog.Debug($"已设置剩余0.01%寿命: {parent.Label} 剩余 {daysLeft:F4} 天 ({PercentFull:P2})");
Messages.Message($"设置剩余寿命为0.01%: {daysLeft:F4} 天", MessageTypeDefOf.SilentInput); Messages.Message($"设置剩余寿命为0.01%: {daysLeft:F4} 天", MessageTypeDefOf.SilentInput);
} }
}; };
@@ -444,7 +444,7 @@ namespace ArachnaeSwarm
powerTicksLeft = 0; powerTicksLeft = 0;
WriteCompDataToHediff(); // 使用新的写入方法 WriteCompDataToHediff(); // 使用新的写入方法
Log.Message($"已归零寿命: {parent.Label} 将立即死亡"); ArachnaeLog.Debug($"已归零寿命: {parent.Label} 将立即死亡");
Messages.Message("寿命已归零,即将死亡", MessageTypeDefOf.SilentInput); Messages.Message("寿命已归零,即将死亡", MessageTypeDefOf.SilentInput);
// 立即触发死亡逻辑 // 立即触发死亡逻辑
@@ -478,7 +478,7 @@ namespace ArachnaeSwarm
$"已耗尽: {depleted}\n" + $"已耗尽: {depleted}\n" +
$"关闭Hediff存在: {HasShutdownHediff}"; $"关闭Hediff存在: {HasShutdownHediff}";
Messages.Message(message, MessageTypeDefOf.SilentInput); Messages.Message(message, MessageTypeDefOf.SilentInput);
Log.Message(message); ArachnaeLog.Debug(message);
} }
else else
{ {
@@ -504,7 +504,7 @@ namespace ArachnaeSwarm
{ {
pawn.health.RemoveHediff(hediff); pawn.health.RemoveHediff(hediff);
lifespanHediff = null; lifespanHediff = null;
Log.Message($"已手动移除 {pawn.Label} 的寿命Hediff"); ArachnaeLog.Debug($"已手动移除 {pawn.Label} 的寿命Hediff");
Messages.Message("已手动移除寿命hediffpawn将立即死亡", MessageTypeDefOf.SilentInput); Messages.Message("已手动移除寿命hediffpawn将立即死亡", MessageTypeDefOf.SilentInput);
} }
else else
@@ -601,7 +601,7 @@ namespace ArachnaeSwarm
Pawn pawn = (Pawn)parent; Pawn pawn = (Pawn)parent;
// 记录日志 // 记录日志
Log.Message($"Killing pawn {pawn.Label} due to lifespan depletion"); ArachnaeLog.Debug($"Killing pawn {pawn.Label} due to lifespan depletion");
// 原有的处死逻辑 // 原有的处死逻辑
List<BodyPartRecord> allParts = pawn.def.race.body.AllParts; List<BodyPartRecord> allParts = pawn.def.race.body.AllParts;
@@ -663,7 +663,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Message($"Skipping lifespan hediff creation for {parent.Label} after load due to shutdown hediff"); ArachnaeLog.Debug($"Skipping lifespan hediff creation for {parent.Label} after load due to shutdown hediff");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using System; using System;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -45,14 +45,14 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in delayed unique pawn check: {ex}"); ArachnaeLog.Debug($"Error in delayed unique pawn check: {ex}");
_scheduledForCheck = false; _scheduledForCheck = false;
} }
}, "ArachnaeSwarm_UniquePawnCheck", false, null); }, "ArachnaeSwarm_UniquePawnCheck", false, null);
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in CompUniquePawn.PostSpawnSetup: {ex}"); ArachnaeLog.Debug($"Error in CompUniquePawn.PostSpawnSetup: {ex}");
_scheduledForCheck = false; _scheduledForCheck = false;
} }
} }
@@ -65,7 +65,7 @@ namespace ArachnaeSwarm
if (string.IsNullOrEmpty(variable)) if (string.IsNullOrEmpty(variable))
{ {
Log.Error("CompUniquePawn: globalVariable is null or empty"); ArachnaeLog.Debug("CompUniquePawn: globalVariable is null or empty");
return; return;
} }
@@ -82,13 +82,13 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"Added global variable '{variable}' for pawn {pawn.Label}"); ArachnaeLog.Debug($"Added global variable '{variable}' for pawn {pawn.Label}");
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in CheckAndHandleUniquePawn: {ex}"); ArachnaeLog.Debug($"Error in CheckAndHandleUniquePawn: {ex}");
} }
} }
@@ -108,7 +108,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"Killing pawn {pawn.Label} because global variable '{variable}' already exists"); ArachnaeLog.Debug($"Killing pawn {pawn.Label} because global variable '{variable}' already exists");
} }
// 使用更安全的延迟执行 // 使用更安全的延迟执行
@@ -131,13 +131,13 @@ namespace ArachnaeSwarm
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in delayed pawn kill: {ex}"); ArachnaeLog.Debug($"Error in delayed pawn kill: {ex}");
} }
}, "ArachnaeSwarm_KillDuplicatePawn", false, null); }, "ArachnaeSwarm_KillDuplicatePawn", false, null);
} }
catch (Exception ex) catch (Exception ex)
{ {
Log.Error($"Error in KillPawn: {ex}"); ArachnaeLog.Debug($"Error in KillPawn: {ex}");
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using HarmonyLib; using HarmonyLib;
using RimWorld; using RimWorld;
@@ -38,7 +38,7 @@ namespace ArachnaeSwarm
GlobalVariableManager.ClearAllVariables(); GlobalVariableManager.ClearAllVariables();
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message("GlobalVariableManager: Cleared all variables for new game"); ArachnaeLog.Debug("GlobalVariableManager: Cleared all variables for new game");
} }
} }
} }
@@ -53,7 +53,7 @@ namespace ArachnaeSwarm
GlobalVariableManager.Initialize(); GlobalVariableManager.Initialize();
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message("GlobalVariableManager: Initialized for loaded game"); ArachnaeLog.Debug("GlobalVariableManager: Initialized for loaded game");
} }
} }
} }
@@ -107,7 +107,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在"); ArachnaeLog.Debug($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在");
} }
__result = false; // 返回 false 表示复活失败 __result = false; // 返回 false 表示复活失败
@@ -117,7 +117,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in resurrection prevention: {ex}"); ArachnaeLog.Debug($"Error in resurrection prevention: {ex}");
} }
return true; // 继续执行原始方法 return true; // 继续执行原始方法
@@ -162,7 +162,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在"); ArachnaeLog.Debug($"阻止复活 {pawn.Label},因为全局变量 '{variable}' 已存在");
} }
__result = false; // 返回 false 表示复活失败 __result = false; // 返回 false 表示复活失败
@@ -172,7 +172,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in resurrection prevention: {ex}"); ArachnaeLog.Debug($"Error in resurrection prevention: {ex}");
} }
return true; // 继续执行原始方法 return true; // 继续执行原始方法
@@ -193,7 +193,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message("GlobalVariableManager: Initialized"); ArachnaeLog.Debug("GlobalVariableManager: Initialized");
} }
} }
} }
@@ -214,7 +214,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"GlobalVariableManager: Saved {_globalVariables.Count} variables"); ArachnaeLog.Debug($"GlobalVariableManager: Saved {_globalVariables.Count} variables");
} }
} }
} }
@@ -228,7 +228,7 @@ namespace ArachnaeSwarm
_globalVariables = new HashSet<string>(variablesList); _globalVariables = new HashSet<string>(variablesList);
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"GlobalVariableManager: Loaded {_globalVariables.Count} variables"); ArachnaeLog.Debug($"GlobalVariableManager: Loaded {_globalVariables.Count} variables");
} }
} }
else else
@@ -236,14 +236,14 @@ namespace ArachnaeSwarm
_globalVariables = new HashSet<string>(); _globalVariables = new HashSet<string>();
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message("GlobalVariableManager: No variables found in save, initializing empty set"); ArachnaeLog.Debug("GlobalVariableManager: No variables found in save, initializing empty set");
} }
} }
} }
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Error($"Error in GlobalVariableManager.ExposeData: {ex}"); ArachnaeLog.Debug($"Error in GlobalVariableManager.ExposeData: {ex}");
} }
} }
@@ -260,7 +260,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"GlobalVariableManager: Added variable '{variable}'"); ArachnaeLog.Debug($"GlobalVariableManager: Added variable '{variable}'");
} }
} }
@@ -271,7 +271,7 @@ namespace ArachnaeSwarm
if (removed && Prefs.DevMode) if (removed && Prefs.DevMode)
{ {
Log.Message($"GlobalVariableManager: Removed variable '{variable}'"); ArachnaeLog.Debug($"GlobalVariableManager: Removed variable '{variable}'");
} }
return removed; return removed;
@@ -291,7 +291,7 @@ namespace ArachnaeSwarm
if (Prefs.DevMode) if (Prefs.DevMode)
{ {
Log.Message($"GlobalVariableManager: Cleared {count} variables"); ArachnaeLog.Debug($"GlobalVariableManager: Cleared {count} variables");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
using System.Collections.Generic; using System.Collections.Generic;
@@ -124,7 +124,7 @@ namespace ArachnaeSwarm
// 应用初始武装方案 // 应用初始武装方案
ApplyWeaponSet(pawn, CurrentWeaponSet); ApplyWeaponSet(pawn, CurrentWeaponSet);
Log.Message($"[PA_Debug] 装备动力装甲,应用武装方案: {CurrentWeaponSet?.label ?? ""}"); ArachnaeLog.Debug($"[PA_Debug] 装备动力装甲,应用武装方案: {CurrentWeaponSet?.label ?? ""}");
} }
public override void Notify_Unequipped(Pawn pawn) public override void Notify_Unequipped(Pawn pawn)
@@ -161,7 +161,7 @@ namespace ArachnaeSwarm
} }
string destroyedWeaponLabel = currentPowerArmorWeapon.Label; string destroyedWeaponLabel = currentPowerArmorWeapon.Label;
currentPowerArmorWeapon.Destroy(); currentPowerArmorWeapon.Destroy();
Log.Message($"[PA_Debug] Notify_Unequipped: 销毁动力装甲武器 {destroyedWeaponLabel}."); ArachnaeLog.Debug($"[PA_Debug] Notify_Unequipped: 销毁动力装甲武器 {destroyedWeaponLabel}.");
currentPowerArmorWeapon = null; currentPowerArmorWeapon = null;
} }
@@ -171,7 +171,7 @@ namespace ArachnaeSwarm
string originalWeaponLabel = originalWeapon.Label; string originalWeaponLabel = originalWeapon.Label;
pawn.equipment.MakeRoomFor(originalWeapon); pawn.equipment.MakeRoomFor(originalWeapon);
pawn.equipment.AddEquipment(originalWeapon); pawn.equipment.AddEquipment(originalWeapon);
Log.Message($"[PA_Debug] Notify_Unequipped: 恢复原始武器 {originalWeaponLabel}."); ArachnaeLog.Debug($"[PA_Debug] Notify_Unequipped: 恢复原始武器 {originalWeaponLabel}.");
originalWeapon = null; originalWeapon = null;
} }
} }
@@ -184,7 +184,7 @@ namespace ArachnaeSwarm
ThingDef buildingDef = Ext?.buildingDef; ThingDef buildingDef = Ext?.buildingDef;
if (buildingDef == null) if (buildingDef == null)
{ {
Log.Error($"[ArachnaeSwarm] 动力装甲 {this.def.defName} 卸下但在其PowerArmorExtension中未定义buildingDef且源建筑引用丢失。"); ArachnaeLog.Debug($"[ArachnaeSwarm] 动力装甲 {this.def.defName} 卸下但在其PowerArmorExtension中未定义buildingDef且源建筑引用丢失。");
this.Destroy(DestroyMode.Vanish); this.Destroy(DestroyMode.Vanish);
return; return;
} }
@@ -209,13 +209,13 @@ namespace ArachnaeSwarm
buildingQuality.SetQuality(apparelQuality.Quality, ArtGenerationContext.Colony); buildingQuality.SetQuality(apparelQuality.Quality, ArtGenerationContext.Colony);
} }
Log.Message($"[PA_Debug] Notify_Unequipped: 生成建筑前 (ID: {building.thingIDNumber}) - HitPoints: {building.HitPoints}, StackCount: {building.stackCount}"); ArachnaeLog.Debug($"[PA_Debug] Notify_Unequipped: 生成建筑前 (ID: {building.thingIDNumber}) - HitPoints: {building.HitPoints}, StackCount: {building.stackCount}");
// 确保建筑堆叠数至少为1 // 确保建筑堆叠数至少为1
if (building.stackCount <= 0) if (building.stackCount <= 0)
{ {
building.stackCount = 1; building.stackCount = 1;
Log.Warning($"[PA_Debug] Notify_Unequipped: 修正建筑 (ID: {building.thingIDNumber}) 堆叠数为1因为原为0。"); ArachnaeLog.Debug($"[PA_Debug] Notify_Unequipped: 修正建筑 (ID: {building.thingIDNumber}) 堆叠数为1因为原为0。");
} }
// 设置派系 // 设置派系
@@ -223,7 +223,7 @@ namespace ArachnaeSwarm
// 重新生成原始建筑实例 // 重新生成原始建筑实例
GenPlace.TryPlaceThing(building, pawn.Position, pawn.Map, ThingPlaceMode.Near); GenPlace.TryPlaceThing(building, pawn.Position, pawn.Map, ThingPlaceMode.Near);
Log.Message($"[PA_Debug] Notify_Unequipped: 生成建筑后 (ID: {building.thingIDNumber}) - HitPoints: {building.HitPoints}, StackCount: {building.stackCount}"); ArachnaeLog.Debug($"[PA_Debug] Notify_Unequipped: 生成建筑后 (ID: {building.thingIDNumber}) - HitPoints: {building.HitPoints}, StackCount: {building.stackCount}");
} }
#endregion #endregion
@@ -239,7 +239,7 @@ namespace ArachnaeSwarm
currentWeaponSetIndex = (currentWeaponSetIndex + 1) % WeaponSetCount; currentWeaponSetIndex = (currentWeaponSetIndex + 1) % WeaponSetCount;
var newSet = CurrentWeaponSet; var newSet = CurrentWeaponSet;
Log.Message($"[PA_Debug] 切换武装方案: {oldSet?.label ?? ""} -> {newSet?.label ?? ""}"); ArachnaeLog.Debug($"[PA_Debug] 切换武装方案: {oldSet?.label ?? ""} -> {newSet?.label ?? ""}");
ApplyWeaponSet(Wearer, newSet, oldSet); ApplyWeaponSet(Wearer, newSet, oldSet);
} }
@@ -255,7 +255,7 @@ namespace ArachnaeSwarm
currentWeaponSetIndex = index; currentWeaponSetIndex = index;
var newSet = CurrentWeaponSet; var newSet = CurrentWeaponSet;
Log.Message($"[PA_Debug] 切换到武装方案: {oldSet?.label ?? ""} -> {newSet?.label ?? ""}"); ArachnaeLog.Debug($"[PA_Debug] 切换到武装方案: {oldSet?.label ?? ""} -> {newSet?.label ?? ""}");
ApplyWeaponSet(Wearer, newSet, oldSet); ApplyWeaponSet(Wearer, newSet, oldSet);
} }
@@ -297,7 +297,7 @@ namespace ArachnaeSwarm
{ {
var hediff = pawn.health.GetOrAddHediff(hediffDef); var hediff = pawn.health.GetOrAddHediff(hediffDef);
activeHediffs.Add(hediff); activeHediffs.Add(hediff);
Log.Message($"[PA_Debug] 添加Hediff: {hediffDef.defName}"); ArachnaeLog.Debug($"[PA_Debug] 添加Hediff: {hediffDef.defName}");
} }
} }
@@ -327,7 +327,7 @@ namespace ArachnaeSwarm
} }
currentPowerArmorWeapon.Destroy(); currentPowerArmorWeapon.Destroy();
currentPowerArmorWeapon = null; currentPowerArmorWeapon = null;
Log.Message($"[PA_Debug] 销毁当前动力装甲武器"); ArachnaeLog.Debug($"[PA_Debug] 销毁当前动力装甲武器");
} }
// 如果新方案有武器,装备新武器 // 如果新方案有武器,装备新武器
@@ -346,14 +346,14 @@ namespace ArachnaeSwarm
pawn.equipment.AddEquipment(weapon); pawn.equipment.AddEquipment(weapon);
SetCurrentPowerArmorWeapon(weapon); SetCurrentPowerArmorWeapon(weapon);
Log.Message($"[PA_Debug] 装备新武器: {weapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 装备新武器: {weapon.Label}");
} }
// 如果没有武器,恢复原始武器 // 如果没有武器,恢复原始武器
else if (originalWeapon != null) else if (originalWeapon != null)
{ {
pawn.equipment.MakeRoomFor(originalWeapon); pawn.equipment.MakeRoomFor(originalWeapon);
pawn.equipment.AddEquipment(originalWeapon); pawn.equipment.AddEquipment(originalWeapon);
Log.Message($"[PA_Debug] 恢复原始武器: {originalWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 恢复原始武器: {originalWeapon.Label}");
} }
} }

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
using Verse.AI; using Verse.AI;
@@ -54,7 +54,7 @@ namespace ArachnaeSwarm
// 重置装备燃料并同步建筑燃料 // 重置装备燃料并同步建筑燃料
apparelFuelComp.ConsumeFuel(apparelFuelComp.Fuel); // 先清空 apparelFuelComp.ConsumeFuel(apparelFuelComp.Fuel); // 先清空
apparelFuelComp.ReceiveFuel(buildingFuelComp.Fuel); apparelFuelComp.ReceiveFuel(buildingFuelComp.Fuel);
Log.Message($"[PA_Debug] 同步燃料: 建筑 {buildingFuelComp.Fuel} -> 装备 {apparelFuelComp.Fuel}"); ArachnaeLog.Debug($"[PA_Debug] 同步燃料: 建筑 {buildingFuelComp.Fuel} -> 装备 {apparelFuelComp.Fuel}");
} }
// 同步质量 // 同步质量
@@ -62,7 +62,7 @@ namespace ArachnaeSwarm
apparel.TryGetComp<CompQuality>() is CompQuality apparelQuality) apparel.TryGetComp<CompQuality>() is CompQuality apparelQuality)
{ {
apparelQuality.SetQuality(buildingQuality.Quality, ArtGenerationContext.Colony); apparelQuality.SetQuality(buildingQuality.Quality, ArtGenerationContext.Colony);
Log.Message($"[PA_Debug] 同步质量: {buildingQuality.Quality}"); ArachnaeLog.Debug($"[PA_Debug] 同步质量: {buildingQuality.Quality}");
} }
// 保存原始武器(如果有) // 保存原始武器(如果有)
@@ -70,7 +70,7 @@ namespace ArachnaeSwarm
if (originalWeapon != null) if (originalWeapon != null)
{ {
apparel.SetOriginalWeapon(originalWeapon); apparel.SetOriginalWeapon(originalWeapon);
Log.Message($"[PA_Debug] 保存原始武器: {originalWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 保存原始武器: {originalWeapon.Label}");
} }
// 获取动力装甲扩展和默认武装方案 // 获取动力装甲扩展和默认武装方案
@@ -88,7 +88,7 @@ namespace ArachnaeSwarm
} }
defaultSet = powerArmorExt.weaponSets[defaultIndex]; defaultSet = powerArmorExt.weaponSets[defaultIndex];
Log.Message($"[PA_Debug] 使用武装方案: {defaultSet?.label ?? ""} (索引: {defaultIndex})"); ArachnaeLog.Debug($"[PA_Debug] 使用武装方案: {defaultSet?.label ?? ""} (索引: {defaultIndex})");
// 如果默认方案有武器,需要卸下原始武器 // 如果默认方案有武器,需要卸下原始武器
if (defaultSet?.weapon != null && originalWeapon != null) if (defaultSet?.weapon != null && originalWeapon != null)
@@ -97,7 +97,7 @@ namespace ArachnaeSwarm
if (actor.equipment.Contains(originalWeapon)) if (actor.equipment.Contains(originalWeapon))
{ {
actor.equipment.Remove(originalWeapon); actor.equipment.Remove(originalWeapon);
Log.Message($"[PA_Debug] 卸下原始武器: {originalWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 卸下原始武器: {originalWeapon.Label}");
} }
// 创建并装备动力装甲武器 // 创建并装备动力装甲武器
@@ -115,27 +115,27 @@ namespace ArachnaeSwarm
actor.equipment.AddEquipment(powerArmorWeapon); actor.equipment.AddEquipment(powerArmorWeapon);
apparel.SetCurrentPowerArmorWeapon(powerArmorWeapon); apparel.SetCurrentPowerArmorWeapon(powerArmorWeapon);
Log.Message($"[PA_Debug] 装备动力装甲武器: {powerArmorWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 装备动力装甲武器: {powerArmorWeapon.Label}");
} }
// 如果默认方案没有武器,但原始武器存在,保留原始武器 // 如果默认方案没有武器,但原始武器存在,保留原始武器
else if (originalWeapon != null) else if (originalWeapon != null)
{ {
Log.Message($"[PA_Debug] 默认方案无武器,保留原始武器: {originalWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 默认方案无武器,保留原始武器: {originalWeapon.Label}");
} }
} }
else else
{ {
Log.Message($"[PA_Debug] 无武装方案配置,使用原有逻辑"); ArachnaeLog.Debug($"[PA_Debug] 无武装方案配置,使用原有逻辑");
// 如果没有武装方案配置,就不进行武器切换 // 如果没有武装方案配置,就不进行武器切换
// 保留殖民者的原始武器 // 保留殖民者的原始武器
if (originalWeapon != null) if (originalWeapon != null)
{ {
Log.Message($"[PA_Debug] 无武装方案,保留原始武器: {originalWeapon.Label}"); ArachnaeLog.Debug($"[PA_Debug] 无武装方案,保留原始武器: {originalWeapon.Label}");
} }
else else
{ {
Log.Message($"[PA_Debug] 无武装方案,且无原始武器"); ArachnaeLog.Debug($"[PA_Debug] 无武装方案,且无原始武器");
} }
} }
@@ -143,18 +143,18 @@ namespace ArachnaeSwarm
// 第三个参数 'false' 是 playerForced这很关键 // 第三个参数 'false' 是 playerForced这很关键
// 如果 playerForced 为 true游戏会自动锁定装备 // 如果 playerForced 为 true游戏会自动锁定装备
actor.apparel.Wear(apparel, false, false); actor.apparel.Wear(apparel, false, false);
Log.Message($"[PA_Debug] 成功穿戴动力装甲: {apparel.Label}"); ArachnaeLog.Debug($"[PA_Debug] 成功穿戴动力装甲: {apparel.Label}");
// 销毁建筑 // 销毁建筑
building.DeSpawn(); building.DeSpawn();
Log.Message($"[PA_Debug] 销毁动力装甲站建筑"); ArachnaeLog.Debug($"[PA_Debug] 销毁动力装甲站建筑");
// 显示成功消息 // 显示成功消息
Messages.Message($"{actor.LabelShort} 已装备{apparel.Label}", actor, MessageTypeDefOf.PositiveEvent); Messages.Message($"{actor.LabelShort} 已装备{apparel.Label}", actor, MessageTypeDefOf.PositiveEvent);
} }
else else
{ {
Log.Error($"[ArachnaeSwarm] 动力装甲建筑 {building.def.defName} 缺少 CompProperties_PowerArmorStation 或 apparelDef。"); ArachnaeLog.Debug($"[ArachnaeSwarm] 动力装甲建筑 {building.def.defName} 缺少 CompProperties_PowerArmorStation 或 apparelDef。");
// 显示错误消息 // 显示错误消息
Messages.Message("装备动力装甲失败:配置错误", actor, MessageTypeDefOf.NegativeEvent); Messages.Message("装备动力装甲失败:配置错误", actor, MessageTypeDefOf.NegativeEvent);

View File

@@ -1,4 +1,4 @@
using RimWorld; using RimWorld;
using Verse; using Verse;
using System.Linq; using System.Linq;
@@ -19,7 +19,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationCost.ShouldShowFor for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationCost.ShouldShowFor for {req.Def?.defName}: {ex.Message}");
return false; return false;
} }
} }
@@ -42,7 +42,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationCost.GetValueUnfinalized for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationCost.GetValueUnfinalized for {req.Def?.defName}: {ex.Message}");
return 0f; return 0f;
} }
} }
@@ -59,7 +59,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationCost.GetExplanationUnfinalized for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationCost.GetExplanationUnfinalized for {req.Def?.defName}: {ex.Message}");
return string.Empty; return string.Empty;
} }
} }
@@ -73,7 +73,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationCost.HasIncubationComp for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationCost.HasIncubationComp for {req.Def?.defName}: {ex.Message}");
return false; return false;
} }
} }
@@ -94,7 +94,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationTime.ShouldShowFor for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationTime.ShouldShowFor for {req.Def?.defName}: {ex.Message}");
return false; return false;
} }
} }
@@ -117,7 +117,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationTime.GetValueUnfinalized for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationTime.GetValueUnfinalized for {req.Def?.defName}: {ex.Message}");
return 0f; return 0f;
} }
} }
@@ -134,7 +134,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationTime.GetExplanationUnfinalized for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationTime.GetExplanationUnfinalized for {req.Def?.defName}: {ex.Message}");
return string.Empty; return string.Empty;
} }
} }
@@ -150,7 +150,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationTime.GetStatDrawEntryLabel for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationTime.GetStatDrawEntryLabel for {req.Def?.defName}: {ex.Message}");
return value.ToString(); return value.ToString();
} }
} }
@@ -164,7 +164,7 @@ namespace ArachnaeSwarm
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {
Log.Warning($"Error in StatWorker_IncubationTime.HasIncubationComp for {req.Def?.defName}: {ex.Message}"); ArachnaeLog.Debug($"Error in StatWorker_IncubationTime.HasIncubationComp for {req.Def?.defName}: {ex.Message}");
return false; return false;
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Verse; using Verse;
namespace ArachnaeSwarm namespace ArachnaeSwarm
@@ -28,7 +28,7 @@ namespace ArachnaeSwarm
{ {
if (raidDef == null) if (raidDef == null)
{ {
Log.Warning("GetCurrentWave called with null raidDef"); ArachnaeLog.Debug("GetCurrentWave called with null raidDef");
return 0; return 0;
} }
@@ -49,11 +49,11 @@ namespace ArachnaeSwarm
int currentWave = GetCurrentWave(raidDef); int currentWave = GetCurrentWave(raidDef);
waveCounters[key] = currentWave + 1; waveCounters[key] = currentWave + 1;
Log.Message($"CustomRaidTracker: Incremented wave for {raidDef.defName} to {waveCounters[key]}"); ArachnaeLog.Debug($"CustomRaidTracker: Incremented wave for {raidDef.defName} to {waveCounters[key]}");
} }
else else
{ {
Log.Warning("IncrementWave called with null raidDef"); ArachnaeLog.Debug("IncrementWave called with null raidDef");
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using RimWorld; using RimWorld;
using Verse; using Verse;
@@ -29,21 +29,21 @@ namespace ArachnaeSwarm
CustomRaidDef raidDef = GetCustomRaidDef(); CustomRaidDef raidDef = GetCustomRaidDef();
if (raidDef == null) if (raidDef == null)
{ {
Log.Warning("CustomRaidDef not found in CanFireNowSub"); ArachnaeLog.Debug("CustomRaidDef not found in CanFireNowSub");
return false; return false;
} }
// 检查最小天数 // 检查最小天数
if (GenDate.DaysPassedSinceSettle < 15f) // 可以配置化 if (GenDate.DaysPassedSinceSettle < 15f) // 可以配置化
{ {
Log.Message($"Custom raid cannot fire: only {GenDate.DaysPassedSinceSettle} days passed, need 15"); ArachnaeLog.Debug($"Custom raid cannot fire: only {GenDate.DaysPassedSinceSettle} days passed, need 15");
return false; return false;
} }
// 检查目标是否有效 // 检查目标是否有效
if (parms.target == null) if (parms.target == null)
{ {
Log.Warning("Custom raid target is null"); ArachnaeLog.Debug("Custom raid target is null");
return false; return false;
} }
@@ -51,7 +51,7 @@ namespace ArachnaeSwarm
Map map = parms.target as Map; Map map = parms.target as Map;
if (map == null) if (map == null)
{ {
Log.Warning("Custom raid target is not a Map or map is null"); ArachnaeLog.Debug("Custom raid target is not a Map or map is null");
return false; return false;
} }
@@ -59,7 +59,7 @@ namespace ArachnaeSwarm
Faction faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef); Faction faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef);
if (faction == null) if (faction == null)
{ {
Log.Warning($"Faction {raidDef.factionDef?.defName} not found for custom raid"); ArachnaeLog.Debug($"Faction {raidDef.factionDef?.defName} not found for custom raid");
return false; return false;
} }
@@ -68,58 +68,58 @@ namespace ArachnaeSwarm
protected override bool TryExecuteWorker(IncidentParms parms) protected override bool TryExecuteWorker(IncidentParms parms)
{ {
Log.Message("=== Custom Raid Incident Started ==="); ArachnaeLog.Debug("=== Custom Raid Incident Started ===");
// 检查目标地图 // 检查目标地图
Map map = parms.target as Map; Map map = parms.target as Map;
if (map == null) if (map == null)
{ {
Log.Error("Custom raid target is not a valid Map"); ArachnaeLog.Debug("Custom raid target is not a valid Map");
return false; return false;
} }
CustomRaidDef raidDef = GetCustomRaidDef(); CustomRaidDef raidDef = GetCustomRaidDef();
if (raidDef == null) if (raidDef == null)
{ {
Log.Error("CustomRaidDef not found"); ArachnaeLog.Debug("CustomRaidDef not found");
return false; return false;
} }
CustomRaidTracker tracker = GetTracker(); CustomRaidTracker tracker = GetTracker();
if (tracker == null) if (tracker == null)
{ {
Log.Error("CustomRaidTracker not found"); ArachnaeLog.Debug("CustomRaidTracker not found");
return false; return false;
} }
// 获取当前波次 // 获取当前波次
int currentWave = tracker.GetCurrentWave(raidDef); int currentWave = tracker.GetCurrentWave(raidDef);
Log.Message($"Current wave: {currentWave}"); ArachnaeLog.Debug($"Current wave: {currentWave}");
// 计算袭击规模 // 计算袭击规模
int raidSize = CalculateRaidSize(currentWave, raidDef); int raidSize = CalculateRaidSize(currentWave, raidDef);
Log.Message($"Calculated raid size: {raidSize}"); ArachnaeLog.Debug($"Calculated raid size: {raidSize}");
// 选择波次定义 // 选择波次定义
RaidWaveDef waveDef = SelectWaveForSize(raidSize, raidDef); RaidWaveDef waveDef = SelectWaveForSize(raidSize, raidDef);
if (waveDef == null) if (waveDef == null)
{ {
Log.Error($"No wave found for raid size {raidSize}"); ArachnaeLog.Debug($"No wave found for raid size {raidSize}");
return false; return false;
} }
Log.Message($"Selected wave: {waveDef.defName}"); ArachnaeLog.Debug($"Selected wave: {waveDef.defName}");
// 设置派系 // 设置派系
parms.faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef); parms.faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef);
if (parms.faction == null) if (parms.faction == null)
{ {
Log.Error($"Faction {raidDef.factionDef.defName} not found"); ArachnaeLog.Debug($"Faction {raidDef.factionDef.defName} not found");
return false; return false;
} }
// 设置点数 // 设置点数
parms.points = CalculateThreatPoints(raidSize); parms.points = CalculateThreatPoints(raidSize);
Log.Message($"Threat points: {parms.points}"); ArachnaeLog.Debug($"Threat points: {parms.points}");
// 设置袭击策略 // 设置袭击策略
parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack;
@@ -130,7 +130,7 @@ namespace ArachnaeSwarm
parms.SetCustomRaidDef(raidDef); parms.SetCustomRaidDef(raidDef);
parms.SetCustomRaidWaveNumber(currentWave); parms.SetCustomRaidWaveNumber(currentWave);
Log.Message($"Custom raid parameters set: wave={waveDef.defName}, size={raidSize}, waveNum={currentWave}"); ArachnaeLog.Debug($"Custom raid parameters set: wave={waveDef.defName}, size={raidSize}, waveNum={currentWave}");
// 执行袭击 // 执行袭击
bool success = base.TryExecuteWorker(parms); bool success = base.TryExecuteWorker(parms);
@@ -139,14 +139,14 @@ namespace ArachnaeSwarm
{ {
// 成功执行后增加波次 // 成功执行后增加波次
tracker.IncrementWave(raidDef); tracker.IncrementWave(raidDef);
Log.Message($"Custom raid wave {currentWave + 1} executed successfully. Next wave will be {currentWave + 2}"); ArachnaeLog.Debug($"Custom raid wave {currentWave + 1} executed successfully. Next wave will be {currentWave + 2}");
} }
else else
{ {
Log.Error("Custom raid execution failed"); ArachnaeLog.Debug("Custom raid execution failed");
} }
Log.Message("=== Custom Raid Incident Finished ==="); ArachnaeLog.Debug("=== Custom Raid Incident Finished ===");
return success; return success;
} }
@@ -155,7 +155,7 @@ namespace ArachnaeSwarm
// 对于自定义袭击,我们已经通过扩展设置了派系 // 对于自定义袭击,我们已经通过扩展设置了派系
if (parms.faction != null) if (parms.faction != null)
{ {
Log.Message($"Raid faction resolved: {parms.faction.Name}"); ArachnaeLog.Debug($"Raid faction resolved: {parms.faction.Name}");
return true; return true;
} }
@@ -165,11 +165,11 @@ namespace ArachnaeSwarm
{ {
parms.faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef); parms.faction = Find.FactionManager.FirstFactionOfDef(raidDef.factionDef);
bool success = parms.faction != null; bool success = parms.faction != null;
Log.Message($"Resolved faction from raidDef: {raidDef.factionDef.defName}, success: {success}"); ArachnaeLog.Debug($"Resolved faction from raidDef: {raidDef.factionDef.defName}, success: {success}");
return success; return success;
} }
Log.Warning("Could not resolve raid faction"); ArachnaeLog.Debug("Could not resolve raid faction");
return false; return false;
} }
@@ -178,7 +178,7 @@ namespace ArachnaeSwarm
// 如果已经设置了袭击策略,直接使用 // 如果已经设置了袭击策略,直接使用
if (parms.raidStrategy != null) if (parms.raidStrategy != null)
{ {
Log.Message($"Raid strategy already set: {parms.raidStrategy.defName}"); ArachnaeLog.Debug($"Raid strategy already set: {parms.raidStrategy.defName}");
return; return;
} }
@@ -189,13 +189,13 @@ namespace ArachnaeSwarm
// 这里可以根据 waveDef 的内容设置不同的策略 // 这里可以根据 waveDef 的内容设置不同的策略
// 例如,如果有特定标签就使用特定策略 // 例如,如果有特定标签就使用特定策略
parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack;
Log.Message($"Set raid strategy from waveDef: {parms.raidStrategy.defName}"); ArachnaeLog.Debug($"Set raid strategy from waveDef: {parms.raidStrategy.defName}");
return; return;
} }
// 默认策略 // 默认策略
parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; parms.raidStrategy = RaidStrategyDefOf.ImmediateAttack;
Log.Message($"Set default raid strategy: {parms.raidStrategy.defName}"); ArachnaeLog.Debug($"Set default raid strategy: {parms.raidStrategy.defName}");
} }
protected override void ResolveRaidPoints(IncidentParms parms) protected override void ResolveRaidPoints(IncidentParms parms)
@@ -203,7 +203,7 @@ namespace ArachnaeSwarm
// 如果已经设置了点数,直接使用 // 如果已经设置了点数,直接使用
if (parms.points > 0) if (parms.points > 0)
{ {
Log.Message($"Raid points already set: {parms.points}"); ArachnaeLog.Debug($"Raid points already set: {parms.points}");
return; return;
} }
@@ -212,13 +212,13 @@ namespace ArachnaeSwarm
if (raidSize > 0) if (raidSize > 0)
{ {
parms.points = CalculateThreatPoints(raidSize); parms.points = CalculateThreatPoints(raidSize);
Log.Message($"Set raid points from custom size: {raidSize} -> {parms.points}"); ArachnaeLog.Debug($"Set raid points from custom size: {raidSize} -> {parms.points}");
return; return;
} }
// 回退到原版点数计算 // 回退到原版点数计算
parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target); parms.points = StorytellerUtility.DefaultThreatPointsNow(parms.target);
Log.Message($"Set raid points from default calculation: {parms.points}"); ArachnaeLog.Debug($"Set raid points from default calculation: {parms.points}");
} }
protected override string GetLetterLabel(IncidentParms parms) protected override string GetLetterLabel(IncidentParms parms)
@@ -279,42 +279,42 @@ namespace ArachnaeSwarm
int baseSize = raidDef.baseRaidNembers; int baseSize = raidDef.baseRaidNembers;
var growthConfig = raidDef.pointsGrowthPerWave; var growthConfig = raidDef.pointsGrowthPerWave;
Log.Message($"Calculating raid size: base={baseSize}, wave={currentWave}, growthType={growthConfig.growthType}"); ArachnaeLog.Debug($"Calculating raid size: base={baseSize}, wave={currentWave}, growthType={growthConfig.growthType}");
if (growthConfig.growthType == "Linear") if (growthConfig.growthType == "Linear")
{ {
int result = baseSize + (int)(currentWave * growthConfig.linearGrowth); int result = baseSize + (int)(currentWave * growthConfig.linearGrowth);
Log.Message($"Linear growth: {baseSize} + ({currentWave} * {growthConfig.linearGrowth}) = {result}"); ArachnaeLog.Debug($"Linear growth: {baseSize} + ({currentWave} * {growthConfig.linearGrowth}) = {result}");
return result; return result;
} }
else if (growthConfig.growthType == "Exponential") else if (growthConfig.growthType == "Exponential")
{ {
int result = (int)(baseSize * System.Math.Pow(growthConfig.exponentialBase, currentWave)); int result = (int)(baseSize * System.Math.Pow(growthConfig.exponentialBase, currentWave));
Log.Message($"Exponential growth: {baseSize} * {growthConfig.exponentialBase}^{currentWave} = {result}"); ArachnaeLog.Debug($"Exponential growth: {baseSize} * {growthConfig.exponentialBase}^{currentWave} = {result}");
return result; return result;
} }
// 默认线性增长 // 默认线性增长
int defaultResult = baseSize + currentWave; int defaultResult = baseSize + currentWave;
Log.Message($"Default growth: {baseSize} + {currentWave} = {defaultResult}"); ArachnaeLog.Debug($"Default growth: {baseSize} + {currentWave} = {defaultResult}");
return defaultResult; return defaultResult;
} }
private RaidWaveDef SelectWaveForSize(int raidSize, CustomRaidDef raidDef) private RaidWaveDef SelectWaveForSize(int raidSize, CustomRaidDef raidDef)
{ {
Log.Message($"Selecting wave for size: {raidSize}"); ArachnaeLog.Debug($"Selecting wave for size: {raidSize}");
foreach (var poolRange in raidDef.pointWavePools) foreach (var poolRange in raidDef.pointWavePools)
{ {
bool minCondition = raidSize >= poolRange.minPoints; bool minCondition = raidSize >= poolRange.minPoints;
bool maxCondition = poolRange.maxPoints >= 99999f || raidSize < poolRange.maxPoints; bool maxCondition = poolRange.maxPoints >= 99999f || raidSize < poolRange.maxPoints;
Log.Message($"Checking pool range: min={poolRange.minPoints}, max={poolRange.maxPoints}, matches={minCondition && maxCondition}"); ArachnaeLog.Debug($"Checking pool range: min={poolRange.minPoints}, max={poolRange.maxPoints}, matches={minCondition && maxCondition}");
if (minCondition && maxCondition) if (minCondition && maxCondition)
{ {
var selectedWave = SelectWaveFromPool(poolRange.wavePool); var selectedWave = SelectWaveFromPool(poolRange.wavePool);
Log.Message($"Selected wave from pool {poolRange.wavePool.defName}: {selectedWave?.defName}"); ArachnaeLog.Debug($"Selected wave from pool {poolRange.wavePool.defName}: {selectedWave?.defName}");
return selectedWave; return selectedWave;
} }
} }
@@ -324,11 +324,11 @@ namespace ArachnaeSwarm
{ {
var lastPool = raidDef.pointWavePools[raidDef.pointWavePools.Count - 1]; var lastPool = raidDef.pointWavePools[raidDef.pointWavePools.Count - 1];
var selectedWave = SelectWaveFromPool(lastPool.wavePool); var selectedWave = SelectWaveFromPool(lastPool.wavePool);
Log.Message($"Selected wave from last pool {lastPool.wavePool.defName}: {selectedWave?.defName}"); ArachnaeLog.Debug($"Selected wave from last pool {lastPool.wavePool.defName}: {selectedWave?.defName}");
return selectedWave; return selectedWave;
} }
Log.Error("No wave pools found in CustomRaidDef"); ArachnaeLog.Debug("No wave pools found in CustomRaidDef");
return null; return null;
} }
@@ -336,13 +336,13 @@ namespace ArachnaeSwarm
{ {
if (wavePool == null) if (wavePool == null)
{ {
Log.Error("WavePool is null"); ArachnaeLog.Debug("WavePool is null");
return null; return null;
} }
if (wavePool.waves.NullOrEmpty()) if (wavePool.waves.NullOrEmpty())
{ {
Log.Error($"WavePool {wavePool.defName} has no waves"); ArachnaeLog.Debug($"WavePool {wavePool.defName} has no waves");
return null; return null;
} }
@@ -353,14 +353,14 @@ namespace ArachnaeSwarm
if (weightedWaves.Any()) if (weightedWaves.Any())
{ {
var selected = weightedWaves.RandomElementByWeight(waveDef => wavePool.selectionWeights[waveDef.defName]); var selected = weightedWaves.RandomElementByWeight(waveDef => wavePool.selectionWeights[waveDef.defName]);
Log.Message($"Selected weighted wave: {selected.defName}"); ArachnaeLog.Debug($"Selected weighted wave: {selected.defName}");
return selected; return selected;
} }
} }
// 否则均匀随机 // 否则均匀随机
var randomWave = wavePool.waves.RandomElement(); var randomWave = wavePool.waves.RandomElement();
Log.Message($"Selected random wave: {randomWave.defName}"); ArachnaeLog.Debug($"Selected random wave: {randomWave.defName}");
return randomWave; return randomWave;
} }
@@ -369,7 +369,7 @@ namespace ArachnaeSwarm
// 根据袭击规模计算威胁点数 // 根据袭击规模计算威胁点数
// 这里可以基于原版的威胁点数计算逻辑进行调整 // 这里可以基于原版的威胁点数计算逻辑进行调整
float points = raidSize * 100f; float points = raidSize * 100f;
Log.Message($"Calculated threat points: {raidSize} * 100 = {points}"); ArachnaeLog.Debug($"Calculated threat points: {raidSize} * 100 = {points}");
return points; return points;
} }
@@ -378,7 +378,7 @@ namespace ArachnaeSwarm
{ {
if (parms.raidArrivalMode != null) if (parms.raidArrivalMode != null)
{ {
Log.Message($"Raid arrival mode already set: {parms.raidArrivalMode.defName}"); ArachnaeLog.Debug($"Raid arrival mode already set: {parms.raidArrivalMode.defName}");
return; return;
} }
// 从自定义波次定义中获取进场方式 // 从自定义波次定义中获取进场方式
@@ -392,7 +392,7 @@ namespace ArachnaeSwarm
selectedMode = waveDef.possibleArrivalModes.RandomElement(); selectedMode = waveDef.possibleArrivalModes.RandomElement();
parms.raidArrivalMode = selectedMode; parms.raidArrivalMode = selectedMode;
Log.Message($"Set random raid arrival mode from waveDef: {parms.raidArrivalMode.defName}"); ArachnaeLog.Debug($"Set random raid arrival mode from waveDef: {parms.raidArrivalMode.defName}");
return; return;
} }
} }
@@ -402,13 +402,13 @@ namespace ArachnaeSwarm
{ {
// 阿拉克涅虫群默认使用空投 // 阿拉克涅虫群默认使用空投
parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop; parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop;
Log.Message($"Set ARA_Hostile_Hive default raid arrival mode: {parms.raidArrivalMode.defName}"); ArachnaeLog.Debug($"Set ARA_Hostile_Hive default raid arrival mode: {parms.raidArrivalMode.defName}");
} }
else else
{ {
// 默认使用边缘进入 // 默认使用边缘进入
parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn; parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
Log.Message($"Set default raid arrival mode: {parms.raidArrivalMode.defName}"); ArachnaeLog.Debug($"Set default raid arrival mode: {parms.raidArrivalMode.defName}");
} }
} }
@@ -423,7 +423,7 @@ namespace ArachnaeSwarm
Map map = Find.CurrentMap; Map map = Find.CurrentMap;
if (map == null) if (map == null)
{ {
Log.Error("No current map found"); ArachnaeLog.Debug("No current map found");
return; return;
} }
@@ -437,7 +437,7 @@ namespace ArachnaeSwarm
} }
else else
{ {
Log.Error("CustomRaidIncident not found"); ArachnaeLog.Debug("CustomRaidIncident not found");
} }
} }
} }

View File

@@ -1,4 +1,4 @@
using Verse; using Verse;
using RimWorld; using RimWorld;
using System.Linq; using System.Linq;
using System; // For Activator using System; // For Activator
@@ -24,7 +24,7 @@ namespace ArachnaeSwarm
{ {
if (pawn.GetComp<ThingComp_GuardianPsyField>() == null) if (pawn.GetComp<ThingComp_GuardianPsyField>() == null)
{ {
Log.Message($"[DynamicInterceptor] Adding ThingComp_GuardianPsyField to {pawn.LabelShort}."); ArachnaeLog.Debug($"[DynamicInterceptor] Adding ThingComp_GuardianPsyField to {pawn.LabelShort}.");
var newComp = (ThingComp_GuardianPsyField)Activator.CreateInstance(typeof(ThingComp_GuardianPsyField)); var newComp = (ThingComp_GuardianPsyField)Activator.CreateInstance(typeof(ThingComp_GuardianPsyField));
newComp.parent = pawn; newComp.parent = pawn;
// Initialize with the actual properties from the HediffDef // Initialize with the actual properties from the HediffDef
@@ -42,7 +42,7 @@ namespace ArachnaeSwarm
var comp = pawn.GetComp<ThingComp_GuardianPsyField>(); var comp = pawn.GetComp<ThingComp_GuardianPsyField>();
if (comp != null) if (comp != null)
{ {
Log.Message($"[DynamicInterceptor] Removing ThingComp_GuardianPsyField from {pawn.LabelShort}."); ArachnaeLog.Debug($"[DynamicInterceptor] Removing ThingComp_GuardianPsyField from {pawn.LabelShort}.");
pawn.AllComps.Remove(comp); pawn.AllComps.Remove(comp);
} }
} }

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using RimWorld; using RimWorld;
using UnityEngine; using UnityEngine;
using Verse; using Verse;
@@ -33,7 +33,7 @@ namespace ArachnaeSwarm
Wula_BeamPierce_Extension props = Props; Wula_BeamPierce_Extension props = Props;
if (props == null) if (props == null)
{ {
Log.Error("Projectile_WulaBeam requires a Wula_BeamPierce_Extension in its def."); ArachnaeLog.Debug("Projectile_WulaBeam requires a Wula_BeamPierce_Extension in its def.");
Destroy(DestroyMode.Vanish); Destroy(DestroyMode.Vanish);
return; return;
} }

View File

@@ -333,7 +333,7 @@ namespace ArachnaeSwarm
bool flag2 = flag; bool flag2 = flag;
if (flag2) if (flag2)
{ {
Log.Error("TargetTakeDamage has null caster or target"); ArachnaeLog.Debug("TargetTakeDamage has null caster or target");
} }
else else
{ {