diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 00ea8919..d4ea2d28 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/Source/WulaFallenEmpire/Flyover/WULA_SpawnFlyOver/CompAbilityEffect_SpawnFlyOver.cs b/Source/WulaFallenEmpire/Ability/WULA_SpawnFlyOver/CompAbilityEffect_SpawnFlyOver.cs similarity index 100% rename from Source/WulaFallenEmpire/Flyover/WULA_SpawnFlyOver/CompAbilityEffect_SpawnFlyOver.cs rename to Source/WulaFallenEmpire/Ability/WULA_SpawnFlyOver/CompAbilityEffect_SpawnFlyOver.cs diff --git a/Source/WulaFallenEmpire/Flyover/WULA_SpawnFlyOver/CompProperties_AbilitySpawnFlyOver.cs b/Source/WulaFallenEmpire/Ability/WULA_SpawnFlyOver/CompProperties_AbilitySpawnFlyOver.cs similarity index 100% rename from Source/WulaFallenEmpire/Flyover/WULA_SpawnFlyOver/CompProperties_AbilitySpawnFlyOver.cs rename to Source/WulaFallenEmpire/Ability/WULA_SpawnFlyOver/CompProperties_AbilitySpawnFlyOver.cs diff --git a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs index f4e662eb..cb47aea4 100644 --- a/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs +++ b/Source/WulaFallenEmpire/BuildingComp/WULA_MechanoidRecycler/Building_MechanoidRecycler.cs @@ -66,10 +66,6 @@ namespace WulaFallenEmpire Messages.Message("WULA_MechRecycled".Translate(mech.LabelCap, storedMechanoidCount, Props.maxStorageCapacity), MessageTypeDefOf.PositiveEvent); - - // 通知转换组件存储更新 - var transformComp = this.TryGetComp(); - transformComp?.NotifyStorageUpdated(); } // 消耗机械族计数 diff --git a/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs b/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs index 1dfa5ec2..7c7696e8 100644 --- a/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs +++ b/Source/WulaFallenEmpire/EventSystem/AI/AIIntelligenceCore.cs @@ -390,7 +390,6 @@ For each function call, return a JSON object within tags _tools.Add(new Tool_ModifyGoodwill()); _tools.Add(new Tool_SendReinforcement()); _tools.Add(new Tool_GetPawnStatus()); - _tools.Add(new Tool_GetPawnGear()); _tools.Add(new Tool_GetMapResources()); _tools.Add(new Tool_GetAvailablePrefabs()); _tools.Add(new Tool_GetMapPawns()); diff --git a/Source/WulaFallenEmpire/HarmonyPatches/WULA_MechUnit/Patch_TakeDamage.cs b/Source/WulaFallenEmpire/HarmonyPatches/WULA_MechUnit/Patch_TakeDamage.cs index 87d8308a..b761647c 100644 --- a/Source/WulaFallenEmpire/HarmonyPatches/WULA_MechUnit/Patch_TakeDamage.cs +++ b/Source/WulaFallenEmpire/HarmonyPatches/WULA_MechUnit/Patch_TakeDamage.cs @@ -59,31 +59,6 @@ namespace WulaFallenEmpire.HarmonyPatches DebugStats[__instance] = new DamageBlockStats(); DebugStats[__instance].totalHits++; - // 第一步:检查伤害免疫HediffComp - if (__instance is Pawn pawn) - { - bool blockedByInvulnerable = CheckInvulnerableHediff(pawn, dinfo, out HediffComp_Invulnerable invulnerableComp); - - if (blockedByInvulnerable) - { - // 被HediffComp免疫阻挡 - DebugStats[__instance].invulnerableBlocked++; - - // 显示免疫效果 - ShowImmuneEffect(pawn, dinfo); - - // 播放免疫音效 - PlayImmuneSound(pawn); - - // 调用HediffComp的OnDamageBlocked方法 - invulnerableComp?.OnDamageBlocked(dinfo); - - // 返回空结果,跳过原方法 - __result = new DamageWorker.DamageResult(); - return false; - } - } - // 第二步:检查机甲装甲系统 float armorValue = __instance.GetStatValue(ArmorStatDef); @@ -117,62 +92,6 @@ namespace WulaFallenEmpire.HarmonyPatches return true; } - /// - /// 检查伤害免疫HediffComp - /// - private static bool CheckInvulnerableHediff(Pawn pawn, DamageInfo dinfo, out HediffComp_Invulnerable invulnerableComp) - { - invulnerableComp = null; - - if (pawn == null || pawn.health == null || pawn.health.hediffSet == null) - return false; - - // 检查所有Hediff,寻找HediffComp_Invulnerable - foreach (Hediff hediff in pawn.health.hediffSet.hediffs) - { - if (hediff.TryGetComp() is HediffComp_Invulnerable comp) - { - invulnerableComp = comp; - return comp.ShouldBlockDamage(dinfo); - } - } - - return false; - } - - /// - /// 显示免疫效果 - /// - private static void ShowImmuneEffect(Pawn pawn, DamageInfo dinfo) - { - if (!pawn.Spawned) - return; - - // 显示文字效果 - Vector3 textPos = pawn.DrawPos + new Vector3(0, 0, 1f); - MoteMaker.ThrowText(textPos, pawn.Map, "DD_ImmuneToDamage".Translate(), Color.green, 2.5f); - - // 显示粒子效果 - if (ImmuneMoteDef != null) - { - MoteMaker.MakeStaticMote(pawn.DrawPos, pawn.Map, ImmuneMoteDef, 1f); - } - } - - /// - /// 播放免疫音效 - /// - private static void PlayImmuneSound(Pawn pawn) - { - if (!pawn.Spawned) - return; - - if (ImmuneSoundDef != null) - { - ImmuneSoundDef.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map)); - } - } - /// /// 显示阻挡效果 /// diff --git a/Source/WulaFallenEmpire/HediffComp/HediffComp_DamageResponse.cs b/Source/WulaFallenEmpire/HediffComp/WULA_DamageResponse/HediffComp_DamageResponse.cs similarity index 100% rename from Source/WulaFallenEmpire/HediffComp/HediffComp_DamageResponse.cs rename to Source/WulaFallenEmpire/HediffComp/WULA_DamageResponse/HediffComp_DamageResponse.cs diff --git a/Source/WulaFallenEmpire/HediffComp/WULA_SyncedWithMech/HediffCompProperties_SyncedWithMech.cs b/Source/WulaFallenEmpire/HediffComp/WULA_SyncedWithMech/HediffCompProperties_SyncedWithMech.cs new file mode 100644 index 00000000..3b9afd4b --- /dev/null +++ b/Source/WulaFallenEmpire/HediffComp/WULA_SyncedWithMech/HediffCompProperties_SyncedWithMech.cs @@ -0,0 +1,284 @@ +// File: HediffComp_SyncedWithMech_Fixed.cs +using System; +using System.Collections.Generic; +using RimWorld; +using UnityEngine; +using Verse; +using System.Linq; + +namespace WulaFallenEmpire +{ + public class HediffCompProperties_SyncedWithMech : HediffCompProperties + { + public float severityOnPawn = 0.5f; // 在Pawn身上的严重性 + public float severityOnMech = 1.5f; // 在Mech身上的严重性 + public bool transferToMech = true; // 是否转移到机甲 + public bool removeWhenLeaving = true; // 离开时是否从机甲移除 + public string syncEffectDef = null; // 同步时的效果 + + public HediffCompProperties_SyncedWithMech() + { + this.compClass = typeof(HediffComp_SyncedWithMech); + } + } + + public class HediffComp_SyncedWithMech : HediffComp + { + // 同步状态数据 + public Pawn linkedMech = null; + public bool isOnMech = false; + private bool initialized = false; + + // 缓存属性 + private HediffCompProperties_SyncedWithMech Props => + (HediffCompProperties_SyncedWithMech)this.props; + + // 新增:供CompMechPilotHolder调用的公共方法 + public void OnPilotEnteredMech(Pawn mech) + { + if (mech is Wulamechunit dmech) + { + LinkToMech(dmech); + } + else if (Prefs.DevMode) + { + Log.Warning($"[DD] OnPilotEnteredMech: 参数不是Wulamechunit类型: {mech?.GetType().Name}"); + } + } + + public void OnPilotExitedMech() + { + UnlinkFromMech(); + } + + public override void CompPostTick(ref float severityAdjustment) + { + base.CompPostTick(ref severityAdjustment); + + // 首次初始化 + if (!initialized) + { + Initialize(); + initialized = true; + } + + // 检查是否需要同步 + CheckSyncStatus(); + + // 如果不在机甲上,保持Pawn的严重性 + if (!isOnMech && !(parent.pawn is Wulamechunit)) + { + parent.Severity = Props.severityOnPawn; + } + } + + private void Initialize() + { + // 如果Pawn是机甲,不应用这个效果 + if (parent.pawn is Wulamechunit) + { + return; + } + + // 设置初始严重性 + parent.Severity = Props.severityOnPawn; + + // 检查Pawn是否已经在机甲中 + CheckIfInMech(); + } + + // 检查Pawn是否在机甲中 + private void CheckIfInMech() + { + // 如果Pawn是机甲,跳过 + if (parent.pawn is Wulamechunit) + return; + + // 查找Pawn所在的机甲 + var mech = FindMechContainingPawn(parent.pawn); + if (mech != null && mech != linkedMech) + { + // 连接到新的机甲 + LinkToMech(mech); + } + else if (mech == null && linkedMech != null) + { + // 从机甲断开 + UnlinkFromMech(); + } + } + + // 查找包含Pawn的机甲 + private Wulamechunit FindMechContainingPawn(Pawn pawn) + { + if (pawn == null || pawn.Map == null) + return null; + + // 检查所有机甲 + foreach (var thing in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Pawn)) + { + if (thing is Wulamechunit mech) + { + var pilotComp = mech.TryGetComp(); + if (pilotComp != null && pilotComp.GetPilots().Contains(pawn)) + { + return mech; + } + } + } + + return null; + } + + // 连接到机甲 + private void LinkToMech(Wulamechunit mech) + { + if (mech == null || !Props.transferToMech) + return; + + // 记录连接的机甲 + linkedMech = mech; + isOnMech = true; + + // 设置Pawn的严重性(在机甲内) + parent.Severity = Props.severityOnPawn; + + // 在机甲上添加同样的Hediff + AddHediffToMech(mech); + + // 触发同步效果 + TriggerSyncEffect(); + + } + + // 从机甲断开 + private void UnlinkFromMech() + { + if (linkedMech == null) + return; + + // 从机甲移除Hediff + if (Props.removeWhenLeaving) + { + RemoveHediffFromMech(linkedMech); + } + + // 重置状态 + var oldMech = linkedMech; + linkedMech = null; + isOnMech = false; + + // 恢复Pawn的严重性 + parent.Severity = Props.severityOnPawn; + } + + // 在机甲上添加Hediff + private void AddHediffToMech(Wulamechunit mech) + { + try + { + // 检查是否已经有相同的Hediff + var existingHediff = mech.health.hediffSet.GetFirstHediffOfDef(parent.def); + if (existingHediff != null) + { + // 更新现有Hediff的严重性 + existingHediff.Severity = Props.severityOnMech; + } + else + { + // 添加新的Hediff + var hediff = HediffMaker.MakeHediff(parent.def, mech); + hediff.Severity = Props.severityOnMech; + + // 确保Hediff有同样的comp + var syncComp = hediff.TryGetComp(); + if (syncComp != null) + { + syncComp.linkedMech = null; // 机甲上的Hediff不链接其他机甲 + syncComp.isOnMech = true; // 标记为在机甲上 + } + + mech.health.AddHediff(hediff); + } + } + catch (Exception ex) + { + Log.Error($"[DD] 在机甲{mech.LabelShort}上添加Hediff时出错: {ex}"); + } + } + + // 从机甲移除Hediff + private void RemoveHediffFromMech(Pawn mech) + { + try + { + var hediff = mech.health.hediffSet.GetFirstHediffOfDef(parent.def); + if (hediff != null) + { + mech.health.RemoveHediff(hediff); + } + } + catch (Exception ex) + { + Log.Error($"[DD] 从机甲{mech.LabelShort}移除Hediff时出错: {ex}"); + } + } + + // 触发同步效果 + private void TriggerSyncEffect() + { + if (string.IsNullOrEmpty(Props.syncEffectDef)) + return; + + try + { + var effectDef = DefDatabase.GetNamed(Props.syncEffectDef, false); + if (effectDef != null && parent.pawn.Spawned) + { + Effecter effecter = effectDef.Spawn(); + effecter.Trigger(parent.pawn, parent.pawn); + effecter.Cleanup(); + } + } + catch (Exception ex) + { + Log.Error($"[DD] 触发同步效果时出错: {ex}"); + } + } + + // 定期检查同步状态 + private void CheckSyncStatus() + { + // 每60帧检查一次 + if (Find.TickManager.TicksGame % 60 != 0) + return; + + CheckIfInMech(); + + // 如果Pawn死亡或消失,从机甲移除 + if (parent.pawn == null || parent.pawn.Dead || parent.pawn.Destroyed) + { + UnlinkFromMech(); + } + } + + // 当Hediff被移除时 + public override void CompPostPostRemoved() + { + base.CompPostPostRemoved(); + + // 从机甲移除对应的Hediff + UnlinkFromMech(); + } + + // 保存和加载状态 + public override void CompExposeData() + { + base.CompExposeData(); + + Scribe_References.Look(ref linkedMech, "linkedMech"); + Scribe_Values.Look(ref isOnMech, "isOnMech", false); + Scribe_Values.Look(ref initialized, "initialized", false); + } + } +} diff --git a/Source/WulaFallenEmpire/Pawn/Comp_MultiTurretGun.cs b/Source/WulaFallenEmpire/Pawn/Comp_MultiTurretGun.cs deleted file mode 100644 index 24911777..00000000 --- a/Source/WulaFallenEmpire/Pawn/Comp_MultiTurretGun.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using Verse; -using Verse.AI; -using RimWorld; -using UnityEngine; - -namespace WulaFallenEmpire -{ - public class CompProperties_MultiTurretGun : CompProperties_TurretGun - { - public int ID; - public CompProperties_MultiTurretGun() - { - compClass = typeof(Comp_MultiTurretGun); - } - } - public class Comp_MultiTurretGun : CompTurretGun - { - private bool fireAtWill = true; - public new CompProperties_MultiTurretGun Props => (CompProperties_MultiTurretGun)props; - public override void CompTick() - { - base.CompTick(); - if (!currentTarget.IsValid && burstCooldownTicksLeft <= 0) - { - // 在其他情况下没有目标且冷却结束时也回正 - curRotation = parent.Rotation.AsAngle + Props.angleOffset; - } - } - private void MakeGun() - { - gun = ThingMaker.MakeThing(Props.turretDef); - UpdateGunVerbs(); - } - private void UpdateGunVerbs() - { - List allVerbs = gun.TryGetComp().AllVerbs; - for (int i = 0; i < allVerbs.Count; i++) - { - Verb verb = allVerbs[i]; - verb.caster = parent; - verb.castCompleteCallback = delegate - { - burstCooldownTicksLeft = AttackVerb.verbProps.defaultCooldownTime.SecondsToTicks(); - }; - } - } - public override void PostExposeData() - { - Scribe_Values.Look(ref burstCooldownTicksLeft, "burstCooldownTicksLeft", 0); - Scribe_Values.Look(ref burstWarmupTicksLeft, "burstWarmupTicksLeft", 0); - Scribe_TargetInfo.Look(ref currentTarget, "currentTarget_" + Props.ID); - Scribe_Deep.Look(ref gun, "gun_" + Props.ID); - Scribe_Values.Look(ref fireAtWill, "fireAtWill", defaultValue: true); - if (Scribe.mode == LoadSaveMode.PostLoadInit) - { - if (gun == null) - { - WulaLog.Debug("CompTurrentGun had null gun after loading. Recreating."); - MakeGun(); - } - else - { - UpdateGunVerbs(); - } - } - } - } - -} diff --git a/Source/WulaFallenEmpire/Pawn/Mechunit.cs b/Source/WulaFallenEmpire/Pawn/Mechunit.cs index 963d37c0..75e2c988 100644 --- a/Source/WulaFallenEmpire/Pawn/Mechunit.cs +++ b/Source/WulaFallenEmpire/Pawn/Mechunit.cs @@ -1,4 +1,4 @@ -// File: DDmechunit_Fixed.cs +// File: Wulamechunit_Fixed.cs using RimWorld; using System.Collections.Generic; using Verse; diff --git a/Source/WulaFallenEmpire/Pawn_Comps/MechFuel/CompMechFuel.cs b/Source/WulaFallenEmpire/Pawn_Comps/MechFuel/CompMechFuel.cs index ed900195..57e96611 100644 --- a/Source/WulaFallenEmpire/Pawn_Comps/MechFuel/CompMechFuel.cs +++ b/Source/WulaFallenEmpire/Pawn_Comps/MechFuel/CompMechFuel.cs @@ -280,7 +280,7 @@ namespace WulaFallenEmpire } // 为殖民者创建强制加注工作 - Job job = JobMaker.MakeJob(Wula_JobDefOf.DD_RefuelMech, parent, fuel); + Job job = JobMaker.MakeJob(Wula_JobDefOf.WULA_RefuelMech, parent, fuel); job.count = GetFuelCountToFullyRefuel(); job.playerForced = true; diff --git a/Source/WulaFallenEmpire/Pawn_Comps/MechRepairable/CompMechRepairable.cs b/Source/WulaFallenEmpire/Pawn_Comps/MechRepairable/CompMechRepairable.cs index 0495b4ca..6f68edf5 100644 --- a/Source/WulaFallenEmpire/Pawn_Comps/MechRepairable/CompMechRepairable.cs +++ b/Source/WulaFallenEmpire/Pawn_Comps/MechRepairable/CompMechRepairable.cs @@ -150,7 +150,7 @@ namespace WulaFallenEmpire } // 创建强制维修工作 - Job job = JobMaker.MakeJob(Wula_JobDefOf.DD_RepairMech, parent); + Job job = JobMaker.MakeJob(Wula_JobDefOf.WULA_RepairMech, parent); job.playerForced = true; bestColonist.jobs.StartJob(job, JobCondition.InterruptForced, null, resumeCurJobAfterwards: true); diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index e5ddbadc..d6d67dfc 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -34,41 +34,6 @@ 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\..\..\..\..\workshop\content\294100\2009463077\1.5\Assemblies\0Harmony.dll False @@ -117,6 +82,17 @@ ..\..\..\..\..\..\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.ScreenCaptureModule.dll False + + + + + + + + + + + @@ -141,8 +117,18 @@ + + + + + + + + + + @@ -153,6 +139,7 @@ + @@ -178,12 +165,15 @@ + + + @@ -245,6 +235,7 @@ + @@ -264,8 +255,9 @@ - - + + + @@ -281,6 +273,7 @@ + @@ -323,11 +316,11 @@ + - @@ -337,10 +330,10 @@ + - - + @@ -389,6 +382,7 @@ + @@ -408,7 +402,11 @@ + + + + @@ -421,21 +419,25 @@ - + + + + + @@ -485,8 +487,10 @@ + + @@ -504,11 +508,8 @@ + - - - -