diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index 17d032e..399b41d 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.pdb b/1.6/1.6/Assemblies/ArachnaeSwarm.pdb index b320b7d..24ba3af 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.pdb and b/1.6/1.6/Assemblies/ArachnaeSwarm.pdb differ diff --git a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml index 34e9a43..b66e988 100644 --- a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml +++ b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceNodeSwarm.xml @@ -543,7 +543,7 @@ - ARA_Humanlike + Humanlike Humanlike Filth_BloodInsect diff --git a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceQueen.xml b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceQueen.xml index 3ff3e99..f391eb8 100644 --- a/1.6/1.6/Defs/ThingDef_Races/ARA_RaceQueen.xml +++ b/1.6/1.6/Defs/ThingDef_Races/ARA_RaceQueen.xml @@ -602,7 +602,7 @@ ArachnaeQueen_Body Normal - ARA_Humanlike + Humanlike Humanlike @@ -800,6 +800,7 @@
  • 3 180 + true Crush 10 false diff --git a/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompAreaDamage.cs b/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompAreaDamage.cs index a262bb2..39130c6 100644 --- a/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompAreaDamage.cs +++ b/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompAreaDamage.cs @@ -27,7 +27,7 @@ namespace ArachnaeSwarm public override void CompTick() { base.CompTick(); - + if (!parent.Spawned || !enabled) return; @@ -37,6 +37,18 @@ namespace ArachnaeSwarm CleanupOldEffecters(); } + // 如果设置为只在有敌人时才伤害,检查是否有敌人 + if (Props.onlyDamageWhenEnemiesPresent) + { + // 如果没有敌人,重置计时并返回 + if (!HasEnemiesInRange()) + { + ticksUntilNextDamage = Props.damageIntervalTicks; + return; + } + } + + // 只有在有敌人时才进行计时和伤害 ticksUntilNextDamage--; if (ticksUntilNextDamage <= 0) { @@ -79,6 +91,12 @@ namespace ArachnaeSwarm if (map == null) return; + // 如果设置为只在有敌人时才伤害,检查是否有敌人 + if (Props.onlyDamageWhenEnemiesPresent && !HasEnemiesInRange()) + { + return; + } + // 获取范围内的所有物体 List thingsInRange = new List(); foreach (IntVec3 cell in GenRadial.RadialCellsAround(parent.Position, Props.radius, true)) @@ -174,6 +192,61 @@ namespace ArachnaeSwarm return thing is Building || thing is Pawn; } + /// + /// 检查范围内是否有敌人 + /// + private bool HasEnemiesInRange() + { + Map map = parent.Map; + if (map == null) + return false; + + foreach (IntVec3 cell in GenRadial.RadialCellsAround(parent.Position, Props.radius, true)) + { + if (!cell.InBounds(map)) + continue; + + List thingList = cell.GetThingList(map); + foreach (Thing thing in thingList) + { + if (IsValidTargetType(thing) && IsHostileTarget(thing)) + { + return true; + } + } + } + + return false; + } + + /// + /// 检查目标是否为敌对目标 + /// + private bool IsHostileTarget(Thing thing) + { + Faction parentFaction = parent.Faction; + Faction targetFaction = thing.Faction; + + // 如果父物体没有派系,所有有派系的目标都视为敌对 + if (parentFaction == null) + { + return targetFaction != null && !targetFaction.IsPlayer; + } + + // 如果目标是Pawn且敌对 + if (thing is Pawn pawn) + { + return pawn.Faction != null && pawn.Faction.HostileTo(parentFaction); + } + // 如果目标是建筑且属于敌对派系 + else if (thing is Building building) + { + return building.Faction != null && building.Faction.HostileTo(parentFaction); + } + + return false; + } + private bool IsValidTarget(Thing thing) { // 首先检查是否为建筑或Pawn(双重检查) diff --git a/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompProperties_AreaDamage.cs b/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompProperties_AreaDamage.cs index bb941cb..7a936dc 100644 --- a/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompProperties_AreaDamage.cs +++ b/Source/ArachnaeSwarm/Thing_Comps/ARA_AreaaDamage/CompProperties_AreaDamage.cs @@ -50,6 +50,9 @@ namespace ArachnaeSwarm public string toggleDescription = "Enable or disable the area damage effect"; // 开关描述 public string toggleIconPath; // 开关图标路径 + // 优化设置 + public bool onlyDamageWhenEnemiesPresent = false; // 是否只在范围内有敌人时才进行伤害 + public CompProperties_AreaDamage() { compClass = typeof(CompAreaDamage);