Merge branch 'master' of https://git.ra3battle.cn/Kalospacer/ArachnaeSwarm
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -543,7 +543,7 @@
|
||||
<race>
|
||||
<!-- <fleshType>WULA_Fleshtype</fleshType> -->
|
||||
<!-- AI行为,勿改 -->
|
||||
<thinkTreeMain>ARA_Humanlike</thinkTreeMain>
|
||||
<thinkTreeMain>Humanlike</thinkTreeMain>
|
||||
<!-- 智力水平 -->
|
||||
<intelligence>Humanlike</intelligence>
|
||||
<bloodDef>Filth_BloodInsect</bloodDef>
|
||||
|
||||
@@ -602,7 +602,7 @@
|
||||
<body>ArachnaeQueen_Body</body>
|
||||
<fleshType>Normal</fleshType>
|
||||
<!-- AI行为,勿改 -->
|
||||
<thinkTreeMain>ARA_Humanlike</thinkTreeMain>
|
||||
<thinkTreeMain>Humanlike</thinkTreeMain>
|
||||
<!-- 智力水平 -->
|
||||
<intelligence>Humanlike</intelligence>
|
||||
<!-- 肉和皮革的定义 -->
|
||||
@@ -800,6 +800,7 @@
|
||||
<li Class="ArachnaeSwarm.CompProperties_AreaDamage">
|
||||
<radius>3</radius>
|
||||
<damageIntervalTicks>180</damageIntervalTicks>
|
||||
<onlyDamageWhenEnemiesPresent>true</onlyDamageWhenEnemiesPresent>
|
||||
<damageDef>Crush</damageDef>
|
||||
<damageAmount>10</damageAmount>
|
||||
<scaleWithPsychicSensitivity>false</scaleWithPsychicSensitivity>
|
||||
|
||||
@@ -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<Thing> thingsInRange = new List<Thing>();
|
||||
foreach (IntVec3 cell in GenRadial.RadialCellsAround(parent.Position, Props.radius, true))
|
||||
@@ -174,6 +192,61 @@ namespace ArachnaeSwarm
|
||||
return thing is Building || thing is Pawn;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查范围内是否有敌人
|
||||
/// </summary>
|
||||
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<Thing> thingList = cell.GetThingList(map);
|
||||
foreach (Thing thing in thingList)
|
||||
{
|
||||
if (IsValidTargetType(thing) && IsHostileTarget(thing))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查目标是否为敌对目标
|
||||
/// </summary>
|
||||
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(双重检查)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user