diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index d2488a0b..e184d87c 100644 Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ diff --git a/1.6/1.6/Defs/HediffDefs/Hediffs_BodyParts_WULA.xml b/1.6/1.6/Defs/HediffDefs/Hediffs_BodyParts_WULA.xml index 724a41ed..68fc762c 100644 --- a/1.6/1.6/Defs/HediffDefs/Hediffs_BodyParts_WULA.xml +++ b/1.6/1.6/Defs/HediffDefs/Hediffs_BodyParts_WULA.xml @@ -1408,64 +1408,65 @@ - - WULA_AutoJumpdrive_Hediff + + WULA_AutoJumpdrive 安装在乌拉帝国合成人军团体内的微型跃迁引擎,会在合成人到达指定作战时间或死亡时将其回收 - HediffWithComps - (1,0,0.5) - 1.0 - 0.0 - true WULA_AutoJumpdrive -
  • - AcidCloud - 6 - 0.25~0.75 - Filth_Slime - DeathAcidifier - ChemicalBurn - 3~6 -
  • -
  • - 10000 -
  • - 15000 - true - PsycastAreaEffect - 2.5 - false - true - true - {0} 通过传送离开了殖民地 + 15000 + true + PsycastAreaEffect + 2.5 + false + true + true + {0} 通过传送离开了殖民地
  • - -
  • - - 0 -
  • -
    WULA_AutoJumpdrive - - 安装在乌拉帝国合成人军团体内的微型跃迁引擎,会在合成人到达指定作战时间或死亡时将其回收。 + + A chest implant for preventing enemy use of captured equipment. Upon the user's death, it releases powerful chemicals that dissolve gear in contact with the user's body. It doesn't damage others. + Spacer + + Things/Item/Health/HealthItem + Graphic_Single + 0.80 + (189,169,118) + - 0.3 - 1 + 400 - -
  • WULA_AutoJumpdrive
  • -
    - - 1 - - - Recipe_Smith - - + +
  • BodyPartsBionic
  • +
    - + + Install_WULA_AutoJumpdrive + + Install a death acidifier. + Installing death acidifier. + +
  • + + +
  • WULA_AutoJumpdrive
  • + + + 1 + +
    + + +
  • WULA_AutoJumpdrive
  • +
    +
    + +
  • Torso
  • +
    + WULA_AutoJumpdrive +
    + \ No newline at end of file diff --git a/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml b/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml index 33a699ea..53f61fd3 100644 --- a/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml +++ b/1.6/1.6/Defs/PawnKinds/PawnKinds_Wula.xml @@ -303,24 +303,31 @@ 10~20 10~20 Poor + Poor + Poor true
  • Wula_Armor_Super_Heavy
  • Wula_Melee_Weapon_T1
  • -
  • Wula_Melee_Weapon_T3
  • +
  • Wula_Melee_Weapon_T2
  • Wula_Ranged_Weapon_T2
  • - - + +
  • WULA_Heavy_Infantry_PowerArmor
  • +
  • WULA_Heavy_Infantry_Helmet
  • +
    3000~8000 + 1 1 + 1 999999~999999 - 1000~2000 - + 999999~999999 +
  • WULA_AutoJumpdrive
  • -
    +
  • DeathAcidifier
  • +
  • diff --git a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml index 5d095413..96bb3795 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml @@ -66,6 +66,7 @@ +
  • Weapon
  • @@ -432,6 +433,7 @@ +
  • Weapon
  • diff --git a/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml index 22bdb237..75ff734e 100644 --- a/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml +++ b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml @@ -337,4 +337,6 @@ 武器阵列:就绪 战争机械已部署 + + 剩余时间: {0} \ No newline at end of file diff --git a/Source/WulaFallenEmpire/HarmonyPatches/Hediff_Mechlink_PostAdd_Patch.cs b/Source/WulaFallenEmpire/HarmonyPatches/Hediff_Mechlink_PostAdd_Patch.cs new file mode 100644 index 00000000..ac2986de --- /dev/null +++ b/Source/WulaFallenEmpire/HarmonyPatches/Hediff_Mechlink_PostAdd_Patch.cs @@ -0,0 +1,32 @@ +using HarmonyLib; +using RimWorld; +using Verse; + +namespace ArachnaeSwarm +{ + [HarmonyPatch(typeof(Hediff_Mechlink), "PostAdd")] + public static class Hediff_Mechlink_PostAdd_Patch + { + public static bool Prefix(Hediff_Mechlink __instance, DamageInfo? dinfo) + { + // 检查 hediff 的 defName 是否是我们要排除的 + if (__instance.def.defName == "WULA_Addons_Antenna_Hediff_Base") + { + // 执行基础逻辑但不弹出信件 + if (!ModLister.CheckBiotech("Mechlink")) + { + __instance.pawn.health.RemoveHediff(__instance); + return false; // 跳过原始方法 + } + + PawnComponentsUtility.AddAndRemoveDynamicComponents(__instance.pawn); + + // 不弹出信件,直接返回 + return false; // 跳过原始方法 + } + + // 对于其他 hediff,正常执行原始方法 + return true; + } + } +} diff --git a/Source/WulaFallenEmpire/Hediff/HediffGiver_NonPlayerFaction.cs b/Source/WulaFallenEmpire/Hediff/HediffGiver_NonPlayerFaction.cs new file mode 100644 index 00000000..88cfe2f7 --- /dev/null +++ b/Source/WulaFallenEmpire/Hediff/HediffGiver_NonPlayerFaction.cs @@ -0,0 +1,121 @@ +using RimWorld; +using Verse; +using System.Collections.Generic; + +namespace WulaFallenEmpire +{ + public class HediffGiver_NonPlayerFaction : HediffGiver + { + // 显式重新定义这些字段,确保 XML 解析器能找到它们 + public float mtbDays; + public new HediffDef hediff; + + // 新增:目标派系列表 + public List targetFactions; + + // 新增:是否排除玩家派系(默认为true) + public bool excludePlayerFaction = true; + + // 新增:是否排除囚犯(默认为true) + public bool excludePrisoners = true; + + // 新增:记录已经处理过的 pawn,避免重复处理 + private HashSet processedPawns = new HashSet(); + + public override void OnIntervalPassed(Pawn pawn, Hediff cause) + { + // 检查 pawn 是否已经处理过 + if (processedPawns.Contains(pawn)) + { + // 如果已经处理过,检查 hediff 是否还存在 + Hediff existingHediff = pawn.health?.hediffSet?.GetFirstHediffOfDef(this.hediff); + if (existingHediff != null) + { + // hediff 还存在,不需要再次处理 + return; + } + else + { + // hediff 被移除了,从记录中移除这个 pawn + processedPawns.Remove(pawn); + } + } + + // 检查派系条件 + if (ShouldHaveHediff(pawn)) + { + // 检查是否已经有这个 hediff + Hediff existing = pawn.health?.hediffSet?.GetFirstHediffOfDef(this.hediff); + if (existing == null) + { + // 给予 hediff + HealthUtility.AdjustSeverity(pawn, this.hediff, 1.0f); + // 标记为已处理 + processedPawns.Add(pawn); + Log.Message($"Added hediff {this.hediff.defName} to pawn {pawn.Label}"); + } + } + else + { + // 移除 hediff + if (RemoveHediffIfExists(pawn)) + { + // 如果成功移除了 hediff,也从记录中移除 + processedPawns.Remove(pawn); + } + } + } + + private bool ShouldHaveHediff(Pawn pawn) + { + // 检查派系是否存在 + if (pawn.Faction == null) + return false; + + // 检查是否排除玩家派系 + if (excludePlayerFaction && pawn.Faction == Faction.OfPlayer) + return false; + + // 检查是否排除囚犯 + if (excludePrisoners && pawn.IsPrisonerOfColony) + return false; + + // 检查目标派系 + if (targetFactions != null && targetFactions.Count > 0) + { + // 如果指定了目标派系,只给这些派系添加 hediff + return targetFactions.Contains(pawn.Faction.def); + } + else + { + // 如果没有指定目标派系,保持原来的行为:给所有非玩家派系添加 + return pawn.Faction != Faction.OfPlayer; + } + } + + private bool RemoveHediffIfExists(Pawn pawn) + { + Hediff existing = pawn.health?.hediffSet?.GetFirstHediffOfDef(this.hediff); + if (existing != null) + { + pawn.health.RemoveHediff(existing); + Log.Message($"Removed hediff {this.hediff.defName} from pawn {pawn.Label}"); + return true; + } + return false; + } + + // 新增:在 pawn 死亡或被销毁时清理记录 + public override void Notify_PawnDied(Pawn pawn, DamageInfo? dinfo) + { + base.Notify_PawnDied(pawn, dinfo); + processedPawns.Remove(pawn); + } + + public override void Notify_PawnDespawned(Pawn pawn, Map map) + { + base.Notify_PawnDespawned(pawn, map); + processedPawns.Remove(pawn); + } + } +} diff --git a/Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect .cs b/Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect.cs similarity index 70% rename from Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect .cs rename to Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect.cs index 8a3b6929..6bdad267 100644 --- a/Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect .cs +++ b/Source/WulaFallenEmpire/HediffComp/HediffCompProperties_DisappearWithEffect.cs @@ -20,7 +20,7 @@ namespace WulaFallenEmpire } } - // HediffComp 实现 + // HediffComp 实现 - 只处理计时器到期 public class HediffComp_DisappearWithEffect : HediffComp { public HediffCompProperties_DisappearWithEffect Props => @@ -54,21 +54,6 @@ namespace WulaFallenEmpire TriggerDisappearEffect(); } } - // 如果 pawn 已经死亡,立即触发效果 - else if (Pawn.Dead) - { - TriggerDisappearEffect(); - } - } - - // 处理 pawn 死亡事件 - 修复参数问题 - public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null) - { - base.Notify_PawnDied(dinfo, culprit); - if (!triggered) - { - TriggerDisappearEffect(); - } } // 触发消失效果的核心方法 @@ -85,22 +70,22 @@ namespace WulaFallenEmpire IntVec3 position = Pawn.Position; Map map = Pawn.Map; - // 1. 清除所有装备 - ClearAllEquipment(map); - - // 2. 播放特效 + // 1. 播放特效 PlayFleckEffect(position, map); - // 3. 播放音效 + // 2. 播放音效 PlaySoundEffect(position, map); - // 4. 发送消失消息(如果配置了) + // 3. 发送消失消息(如果配置了) SendDisappearMessage(); - // 5. 删除 pawn + // 4. 清除装备 + ClearAllEquipment(); + + // 5. 暴力删除 pawn DestroyPawn(); - Log.Message($"[DisappearWithEffect] Pawn {Pawn.LabelCap} disappeared at {position}"); + Log.Message($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed at {position}"); } catch (System.Exception ex) { @@ -108,69 +93,56 @@ namespace WulaFallenEmpire } } - // 清除所有装备 - 修复参数问题 - private void ClearAllEquipment(Map map) + // 清除所有装备 + private void ClearAllEquipment() { - if (Pawn.equipment == null && Pawn.apparel == null && Pawn.inventory == null) - return; - - // 清除装备(武器) + // 销毁装备(武器) if (Pawn.equipment != null) { - var allEquipment = Pawn.equipment.AllEquipmentListForReading.ListFullCopy(); - foreach (var thing in allEquipment) + if (Props.dropEquipment) { - if (Props.dropEquipment) + // 掉落所有装备 + var allEquipment = Pawn.equipment.AllEquipmentListForReading.ListFullCopy(); + foreach (var thing in allEquipment) { - // 掉落装备 - 修复类型转换问题 ThingWithComps droppedWeapon; Pawn.equipment.TryDropEquipment(thing, out droppedWeapon, Pawn.Position, true); } - else - { - // 直接销毁装备 - thing.Destroy(DestroyMode.Vanish); - } + } + else + { + // 直接销毁所有装备 + Pawn.equipment.DestroyAllEquipment(); } } - // 清除 apparel(服装) + // 销毁 apparel(服装) if (Pawn.apparel != null) { - var wornApparel = Pawn.apparel.WornApparel.ListFullCopy(); - foreach (var apparel in wornApparel) + if (Props.dropEquipment) { - if (Props.dropEquipment) + // 掉落所有服装 + var wornApparel = Pawn.apparel.WornApparel.ListFullCopy(); + foreach (var apparel in wornApparel) { - // 掉落服装 Apparel droppedApparel; Pawn.apparel.TryDrop(apparel, out droppedApparel, Pawn.Position, true); } - else - { - // 直接销毁服装 - apparel.Destroy(DestroyMode.Vanish); - } + } + else + { + // 直接销毁所有服装 + Pawn.apparel.DestroyAll(); } } - // 清除 inventory(物品栏) - if (Pawn.inventory != null) + // 销毁 inventory(物品栏) + if (Pawn.inventory != null && !Props.dropEquipment) { var innerContainer = Pawn.inventory.innerContainer.InnerListForReading.ListFullCopy(); foreach (var thing in innerContainer) { - if (Props.dropEquipment) - { - // 掉落物品 - Thing droppedThing; - Pawn.inventory.innerContainer.TryDrop(thing, Pawn.Position, map, ThingPlaceMode.Near, out droppedThing); - } - else - { - // 直接销毁物品 - thing.Destroy(DestroyMode.Vanish); - } + thing.Destroy(DestroyMode.Vanish); } } } @@ -194,7 +166,7 @@ namespace WulaFallenEmpire } } - // 播放音效 - 修复音效播放问题 + // 播放音效 private void PlaySoundEffect(IntVec3 position, Map map) { if (!Props.playSound) return; @@ -232,19 +204,18 @@ namespace WulaFallenEmpire // 删除 pawn private void DestroyPawn() { - if (Pawn.Dead && Props.destroyCorpse) + if (Pawn.Destroyed) return; + + try { - // 如果是尸体,直接销毁 - Pawn.Destroy(); + // 直接调用 Destroy,绕过所有死亡逻辑 + Pawn.Destroy(DestroyMode.Vanish); + + Log.Message($"[DisappearWithEffect] Pawn {Pawn.LabelCap} destroyed"); } - else if (!Pawn.Dead) + catch (System.Exception ex) { - // 如果是活着的 pawn,先杀死再销毁 - Pawn.Kill(null, this.parent); - if (Props.destroyCorpse) - { - Pawn.Destroy(); - } + Log.Error($"[DisappearWithEffect] Error destroying pawn: {ex}"); } } diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index f16d3758..0f3f434f 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -153,6 +153,7 @@ + @@ -160,7 +161,7 @@ - +