diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll index 688bbef5..c078dd25 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/WULA_Misc_Hediffs.xml b/1.6/1.6/Defs/HediffDefs/WULA_Misc_Hediffs.xml index 8a81f2fc..40755b75 100644 --- a/1.6/1.6/Defs/HediffDefs/WULA_Misc_Hediffs.xml +++ b/1.6/1.6/Defs/HediffDefs/WULA_Misc_Hediffs.xml @@ -292,4 +292,33 @@ false + + Wula_Holographic_Flag_Hediff + + 帝皇在注视我! + HediffWithComps + (0.52, 1, 0.95) + +
  • + 120 + false +
  • +
  • + + +
  • + 0 + + -0.01 + + + 0.9 + 1 + 1.1 + 0.9 + +
  • + + false +
    \ No newline at end of file diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Misc_Buildings.xml b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Misc_Buildings.xml index e70803ca..4c7da254 100644 --- a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Misc_Buildings.xml +++ b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Misc_Buildings.xml @@ -611,89 +611,6 @@ - - WULA_Holographic_Flag_Building - - 乌拉帝国行星封锁机关的全息旗帜,没什么用但是可以宣示乌拉帝国的主权。 - WulaFallenEmpire.Building_ExtraGraphics - true - BuildingOnTop - 50 - true - PassThroughOnly - 1 - (1,1) - true - (0.56, 0.62, 0.9) - Wula/Building/Flag/WULA_Flag_Building_A - false - - Wula/Building/Flag/WULA_Flag_Building_Mount - Graphic_Single - (1,1) - - - 5 - - - 50 - 0.5 - 1000 - 5 - 0.65 - - Normal - true - false - North - true - Light - BulletImpact_Metal - true - RealtimeOnly - ConstructMetal - true - WULA_Buildings - - false - BuildingDestroyed_Metal_Big - true - true - - -
  • - 0 - 0 - - -
  • - Wula/Building/Flag/WULA_Flag_Building_A - (3,3) - 0 - (0,1,3) - 1.5 - 0.2 - 0 -
  • -
  • - Wula/Building/Flag/WULA_Flag_Building_Mount - (1,1) - 1 - (0,1,0) - 0 - 0 - 0 -
  • - - -
    - -
  • - 3 - (120,240,252,0) -
  • -
    -
    WULA_Wall_Flag_Building @@ -744,64 +661,4 @@
  • Placeworker_AttachedToWall
  • - - - WULA_BroadshieldProjector - - A man-portable low-angle shield projector. Bullets can go out, but not in. Its compact power source burns out after a few seconds of use. - BuildingOnTop - MapMeshAndRealTime - 0 - Standable - 0.35 - - Things/Building/Security/BroadshieldProjector - Graphic_Single - 0.7 - - (0.3, 0.2, 0.3) - (0,0,-0.1) - - - (0.2,0.2,0.6,0.6) - - - - 250 - 0.5 - - Normal - - false - true - Light - BulletImpact_Metal - ConstructMetal - 0 - - false - BuildingDestroyed_Metal_Small - false - false - Broadshield_Burnout - - -
  • - SolarFlare - 1 - 0.01 -
  • -
  • - 4.9 - true - true - false - (0.6, 0.6, 0.8) - 3 - 0.05 - 600 - Broadshield_Ambience -
  • -
    -
    \ No newline at end of file diff --git a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml index 3e287275..1417d69e 100644 --- a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml +++ b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml @@ -2177,12 +2177,12 @@ - - WULA_Support_Shield_Projection_Skyfaller - + + WULA_Holographic_Flag_Building_Skyfaller + (1,1) - Wula/Building/Flag/WULA_Flag_Building_Mount + Wula/Building/Flag/WULA_Flag_Building_Mount_Incoming Graphic_Single TransparentPostLight (1,1) @@ -2196,23 +2196,28 @@ (0, 0) DropPod_Fall 100 - + Explosion_Vaporize 0.05 - 0 - 0 + 1 + 1
  • (0,0)
  • (1, 1)
  • - WULA_Support_Shield + WULA_Holographic_Flag_Building + +
  • + Smoke_Joint +
  • +
    - - WULA_Support_Shield - - 一面大型护盾,反射所有的敌方射弹,己方的开火不受影响。 + + WULA_Holographic_Flag_Building + + 乌拉帝国行星封锁机关的全息旗帜,除了宣誓主权外,也能激励附近的乌拉星人更加凶狠地战斗。 WulaFallenEmpire.Building_ExtraGraphics true BuildingOnTop @@ -2222,24 +2227,23 @@ 1 (1,1) true + None (0.56, 0.62, 0.9) Wula/Building/Flag/WULA_Flag_Building_A false Wula/Building/Flag/WULA_Flag_Building_Mount Graphic_Single - TransparentPostLight (1,1) - 5 + 1 - 100 + 50 0.5 1000 - 125 - 0.65 + 5 Normal true @@ -2283,19 +2287,23 @@ 0 0 -
  • - Wula/Building/WULA_Support_Shield_Building - (24,24) - 2 - (0,1,0) - 0 - 0 - 0 -
  • +
  • + 15 + Wula_Holographic_Flag_Hediff + 0.5 + true + 120 + +
  • WulaSpecies
  • + + true + false + false +
  • true @@ -2305,6 +2313,20 @@ 3 (120,240,252,0)
  • +
    +
    + + WULA_Support_Shield_Projection_Skyfaller + + + WULA_Support_Shield + + + + WULA_Support_Shield + + 乌拉帝国行星封锁机关的全息旗帜,除了宣誓主权外,也能激励附近的乌拉星人更加凶狠地战斗。这面旗帜的底座附带了一个大型拒止护盾,可以反射所有的敌方射弹,己方的开火不受影响。\n\n在工作一段时间后,该系统将自行烧毁。 +
  • 3600
  • diff --git a/Content/Textures/Wula/Building/Flag/WULA_Flag_Building_Mount_Incoming.png b/Content/Textures/Wula/Building/Flag/WULA_Flag_Building_Mount_Incoming.png new file mode 100644 index 00000000..d477722e Binary files /dev/null and b/Content/Textures/Wula/Building/Flag/WULA_Flag_Building_Mount_Incoming.png differ diff --git a/Source/WulaFallenEmpire/BuildingComp/Building_ExtraGraphics.cs b/Source/WulaFallenEmpire/BuildingComp/Building_ExtraGraphics.cs index 3b692756..84fe40c6 100644 --- a/Source/WulaFallenEmpire/BuildingComp/Building_ExtraGraphics.cs +++ b/Source/WulaFallenEmpire/BuildingComp/Building_ExtraGraphics.cs @@ -58,17 +58,20 @@ namespace WulaFallenEmpire return graphic; } - - // 完全重写 DrawAt 方法,实现自定义渲染系统 protected override void DrawAt(Vector3 drawLoc, bool flip = false) { // 不调用基类的 DrawAt,完全自定义渲染 - + // 更新悬浮动画 UpdateHoverAnimation(); - // 绘制所有配置的图形层 DrawGraphicLayers(drawLoc, flip); + // 新增:绘制护盾 + var shieldComp = this.GetComp(); + if (shieldComp != null) + { + shieldComp.PostDraw(); + } } // 绘制所有图形层 diff --git a/Source/WulaFallenEmpire/Flyover/WULA_FlyOverFacilities/CompAbilityEffect_RequireFlyOverFacility.cs b/Source/WulaFallenEmpire/Flyover/WULA_FlyOverFacilities/CompAbilityEffect_RequireFlyOverFacility.cs index ebc0ea8e..4fd5d932 100644 --- a/Source/WulaFallenEmpire/Flyover/WULA_FlyOverFacilities/CompAbilityEffect_RequireFlyOverFacility.cs +++ b/Source/WulaFallenEmpire/Flyover/WULA_FlyOverFacilities/CompAbilityEffect_RequireFlyOverFacility.cs @@ -40,10 +40,6 @@ namespace WulaFallenEmpire if (validFlyOvers.Count == 0) { - if (throwMessages) - { - Messages.Message(Props.facilityNotFoundMessage, parent.pawn, MessageTypeDefOf.RejectInput); - } return false; } @@ -87,7 +83,6 @@ namespace WulaFallenEmpire { // 如果指定了特定的 FlyOver 定义,只检查该定义的物体 allFlyOvers = parent.pawn.Map.listerThings.ThingsOfDef(Props.flyOverDef); - Log.Message($"[RequireFlyOverFacility] Checking specific FlyOverDef: {Props.flyOverDef.defName}, found: {allFlyOvers.Count}"); } else { @@ -102,7 +97,6 @@ namespace WulaFallenEmpire allFlyOvers.Add(thing); } } - Log.Message($"[RequireFlyOverFacility] Checking all FlyOver types, found: {allFlyOvers.Count}"); } foreach (var thing in allFlyOvers) @@ -119,12 +113,10 @@ namespace WulaFallenEmpire if (!facilitiesComp.HasFacility(Props.requiredFacility)) { - Log.Message($"[RequireFlyOverFacility] FlyOver at {flyOver.Position} missing facility: {Props.requiredFacility}. Has: {string.Join(", ", facilitiesComp.GetActiveFacilities())}"); continue; } validFlyOvers.Add(flyOver); - Log.Message($"[RequireFlyOverFacility] Found valid FlyOver at {flyOver.Position} with facility: {Props.requiredFacility}"); } } @@ -144,7 +136,6 @@ namespace WulaFallenEmpire var selectedFlyOver = availableFlyOvers.FirstOrDefault(); if (selectedFlyOver != null) { - Log.Message($"[RequireFlyOverFacility] Skill executed using FlyOver at {selectedFlyOver.Position} with facility: {Props.requiredFacility}"); } } diff --git a/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompGiveHediffsInRange.cs b/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompGiveHediffsInRange.cs new file mode 100644 index 00000000..923225b9 --- /dev/null +++ b/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompGiveHediffsInRange.cs @@ -0,0 +1,403 @@ +using RimWorld; +using Verse; +using System.Collections.Generic; +using UnityEngine; + +namespace WulaFallenEmpire +{ + public class CompGiveHediffsInRange : ThingComp + { + private CompProperties_GiveHediffsInRange Props => (CompProperties_GiveHediffsInRange)props; + + // 跟踪受影响的pawn和他们的Hediff + private Dictionary affectedPawns = new Dictionary(); + + // 效果实例缓存 + private Dictionary effecters = new Dictionary(); + + public override void CompTick() + { + base.CompTick(); + + if (parent == null || !parent.Spawned || parent.Map == null) + return; + + // 使用间隔检查优化性能 + if (Find.TickManager.TicksGame % Props.checkIntervalTicks != 0) + return; + + UpdateAffectedPawns(); + } + + private void UpdateAffectedPawns() + { + if (Props.hediff == null) return; + + // 获取范围内的所有pawn + List pawnsInRange = GetPawnsInRange(); + + // 处理新进入范围的pawn + foreach (var pawn in pawnsInRange) + { + if (!affectedPawns.ContainsKey(pawn) && ShouldAffectPawn(pawn)) + { + AddHediffToPawn(pawn); + } + } + + // 处理离开范围的pawn + var pawnsToRemove = new List(); + foreach (var kvp in affectedPawns) + { + if (!pawnsInRange.Contains(kvp.Key) || !ShouldAffectPawn(kvp.Key)) + { + pawnsToRemove.Add(kvp.Key); + } + else + { + // 更新持续时间的Hediff + UpdateHediffDuration(kvp.Key, kvp.Value); + } + } + + foreach (var pawn in pawnsToRemove) + { + RemoveHediffFromPawn(pawn); + } + } + + private List GetPawnsInRange() + { + var pawns = new List(); + if (parent?.Map == null) return pawns; + + var map = parent.Map; + var center = parent.Position; + + // 使用网格搜索优化性能 + foreach (var thing in map.listerThings.ThingsInGroup(ThingRequestGroup.Pawn)) + { + if (thing is Pawn pawn && + pawn.Position.DistanceTo(center) <= Props.range && + pawn.Spawned) + { + pawns.Add(pawn); + } + } + + return pawns; + } + + /// + /// 检查pawn是否应该受到效果影响 + /// + private bool ShouldAffectPawn(Pawn pawn) + { + if (pawn == null || pawn.Dead || pawn.Destroyed) + return false; + + // 派系检查 + if (Props.onlyPawnsInSameFaction && pawn.Faction != parent.Faction) + return false; + + // 种族类型检查 + if (Props.requireHumanlike && !pawn.RaceProps.Humanlike) + return false; + if (Props.requireAnimal && !pawn.RaceProps.Animal) + return false; + if (Props.requireMechanoid && !pawn.RaceProps.IsMechanoid) + return false; + + // 特定种族检查 + if (Props.allowedRaces != null && Props.allowedRaces.Count > 0) + { + if (!Props.allowedRaces.Contains(pawn.def)) + return false; + } + + // 排除种族检查 + if (Props.excludedRaces != null && Props.excludedRaces.Count > 0) + { + if (Props.excludedRaces.Contains(pawn.def)) + return false; + } + + // 修复:安全的派系关系检查 + if (parent.Faction != null && pawn.Faction != null) + { + // 避免检查同一派系与自身的关系 + if (parent.Faction == pawn.Faction) + { + // 同一派系,视为盟友 + if (!Props.affectAllies) + return false; + } + else + { + try + { + FactionRelationKind relation = parent.Faction.RelationKindWith(pawn.Faction); + + if (!Props.affectAllies && relation == FactionRelationKind.Ally) + return false; + if (!Props.affectEnemies && relation == FactionRelationKind.Hostile) + return false; + if (!Props.affectNeutrals && relation == FactionRelationKind.Neutral) + return false; + } + catch (System.Exception ex) + { + Log.Warning($"检查派系关系时出错: {ex.Message}"); + // 出错时保守处理,不施加效果 + return false; + } + } + } + else + { + // 如果建筑或pawn没有派系,根据设置处理 + if (parent.Faction == null && pawn.Faction == null) + { + // 两者都没有派系,视为中立 + if (!Props.affectNeutrals) + return false; + } + else if (pawn.Faction == null) + { + // pawn没有派系(野生动物等),视为中立 + if (!Props.affectNeutrals) + return false; + } + } + + // 囚犯和奴隶检查 + if (!Props.affectPrisoners && pawn.IsPrisoner) + return false; + if (!Props.affectSlaves && pawn.IsSlave) + return false; + + return true; + } + + private void AddHediffToPawn(Pawn pawn) + { + try + { + // 检查pawn是否已经有这个Hediff + Hediff existingHediff = pawn.health.hediffSet.GetFirstHediffOfDef(Props.hediff); + if (existingHediff != null) + { + // 如果已经有相同的Hediff,更新它而不是创建新的 + affectedPawns[pawn] = existingHediff; + UpdateHediffDuration(pawn, existingHediff); + return; + } + + // 添加Hediff + Hediff newHediff = HediffMaker.MakeHediff(Props.hediff, pawn); + newHediff.Severity = Props.initialSeverity; + + // 设置持续时间(如果有) + if (Props.hediffDurationTicks > 0) + { + var comp = newHediff.TryGetComp(); + if (comp != null) + { + comp.ticksToDisappear = Props.hediffDurationTicks; + } + } + + pawn.health.AddHediff(newHediff); + affectedPawns[pawn] = newHediff; + + // 创建视觉效果 + CreateEffectForPawn(pawn); + + // 记录日志(可选,调试时使用) + // Log.Message($"给予 {pawn.LabelShort} ({pawn.def.defName}) Hediff: {Props.hediff.defName}"); + } + catch (System.Exception ex) + { + Log.Warning($"无法给 {pawn.LabelShort} 添加Hediff: {ex.Message}"); + } + } + + private void RemoveHediffFromPawn(Pawn pawn) + { + if (affectedPawns.TryGetValue(pawn, out var hediff)) + { + try + { + // 安全地移除Hediff + if (pawn.health.hediffSet.hediffs.Contains(hediff)) + { + pawn.health.RemoveHediff(hediff); + } + } + catch (System.Exception ex) + { + Log.Warning($"移除 {pawn.LabelShort} 的Hediff时出错: {ex.Message}"); + } + + affectedPawns.Remove(pawn); + } + + // 移除视觉效果 + RemoveEffectForPawn(pawn); + } + + private void UpdateHediffDuration(Pawn pawn, Hediff hediff) + { + if (Props.hediffDurationTicks > 0) + { + var comp = hediff.TryGetComp(); + if (comp != null) + { + // 重置持续时间,让效果持续 + comp.ticksToDisappear = Props.hediffDurationTicks; + } + } + } + + private void CreateEffectForPawn(Pawn pawn) + { + if (Props.mote != null) + { + try + { + // 创建持续的视觉效果 + var effecterDef = DefDatabase.GetNamedSilentFail(Props.mote.defName + "_Effecter"); + if (effecterDef != null) + { + var effecter = effecterDef.Spawn(); + effecters[pawn] = effecter; + } + else + { + // 如果没有对应的EffecterDef,直接创建Mote + MoteMaker.MakeStaticMote(pawn.Position, pawn.Map, Props.mote, 1f); + } + } + catch (System.Exception ex) + { + Log.Warning($"创建视觉效果时出错: {ex.Message}"); + } + } + } + + private void RemoveEffectForPawn(Pawn pawn) + { + if (effecters.TryGetValue(pawn, out var effecter)) + { + try + { + effecter.Cleanup(); + } + catch (System.Exception ex) + { + Log.Warning($"清理视觉效果时出错: {ex.Message}"); + } + effecters.Remove(pawn); + } + } + + public override void CompTickRare() + { + base.CompTickRare(); + + // 更新视觉效果 + var effectersToRemove = new List(); + foreach (var kvp in effecters) + { + if (kvp.Key != null && kvp.Key.Spawned && affectedPawns.ContainsKey(kvp.Key)) + { + try + { + kvp.Value.EffectTick(kvp.Key, kvp.Key); + } + catch (System.Exception ex) + { + Log.Warning($"更新视觉效果时出错: {ex.Message}"); + effectersToRemove.Add(kvp.Key); + } + } + else + { + effectersToRemove.Add(kvp.Key); + } + } + + // 清理无效的效果器 + foreach (var pawn in effectersToRemove) + { + RemoveEffectForPawn(pawn); + } + } + + public override void PostDeSpawn(Map map, DestroyMode mode = DestroyMode.Vanish) + { + base.PostDeSpawn(map); + CleanupAllEffects(); + } + + public override void PostDestroy(DestroyMode mode, Map previousMap) + { + base.PostDestroy(mode, previousMap); + CleanupAllEffects(); + } + + /// + /// 清理所有效果 + /// + private void CleanupAllEffects() + { + // 移除所有Hediff + var pawnsToRemove = new List(affectedPawns.Keys); + foreach (var pawn in pawnsToRemove) + { + RemoveHediffFromPawn(pawn); + } + + affectedPawns.Clear(); + + // 清理所有视觉效果 + var effectersToRemove = new List(effecters.Keys); + foreach (var pawn in effectersToRemove) + { + RemoveEffectForPawn(pawn); + } + + effecters.Clear(); + } + + // 调试方法:显示影响范围 + public override void PostDraw() + { + base.PostDraw(); + + if (Find.Selector.IsSelected(parent)) + { + try + { + GenDraw.DrawRadiusRing(parent.Position, Props.range, Color.green); + } + catch (System.Exception ex) + { + Log.Warning($"绘制范围环时出错: {ex.Message}"); + } + } + } + + // 获取当前受影响的pawn数量(用于显示) + public int GetAffectedPawnCount() + { + return affectedPawns.Count; + } + + // 获取受影响的pawn列表(用于调试) + public IEnumerable GetAffectedPawns() + { + return affectedPawns.Keys; + } + } +} diff --git a/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompProperties_GiveHediffsInRange.cs b/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompProperties_GiveHediffsInRange.cs new file mode 100644 index 00000000..ef220e8d --- /dev/null +++ b/Source/WulaFallenEmpire/ThingComp/WULA_GiveHediffsInRange/CompProperties_GiveHediffsInRange.cs @@ -0,0 +1,40 @@ +using RimWorld; +using Verse; +using System.Collections.Generic; + +namespace WulaFallenEmpire +{ + public class CompProperties_GiveHediffsInRange : CompProperties + { + public float range = 10f; + public TargetingParameters targetingParameters; + public HediffDef hediff; + public ThingDef mote; + public bool hideMoteWhenNotDrafted; + public float initialSeverity = 1f; + public bool onlyPawnsInSameFaction = true; + + // 新增:种族筛选 + public List allowedRaces; + public List excludedRaces; + public bool requireHumanlike = false; + public bool requireAnimal = false; + public bool requireMechanoid = false; + + // 新增:效果控制 + public bool affectAllies = true; + public bool affectEnemies = true; + public bool affectNeutrals = true; + public bool affectPrisoners = false; + public bool affectSlaves = false; + + // 新增:间隔控制 + public int checkIntervalTicks = 60; + public int hediffDurationTicks = -1; // -1 表示永久 + + public CompProperties_GiveHediffsInRange() + { + compClass = typeof(CompGiveHediffsInRange); + } + } +} diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj index 3a98a251..d28bf363 100644 --- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj +++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj @@ -261,6 +261,8 @@ + + diff --git a/美术与文本源文件/Wula/Building/WULA_Support_Shield_Building.sai2 b/美术与文本源文件/Wula/Building/WULA_Support_Shield_Building.sai2 deleted file mode 100644 index b3ec89a6..00000000 Binary files a/美术与文本源文件/Wula/Building/WULA_Support_Shield_Building.sai2 and /dev/null differ