1
This commit is contained in:
Binary file not shown.
@@ -38,6 +38,13 @@
|
|||||||
<endPosition>OppositeMapEdge</endPosition>
|
<endPosition>OppositeMapEdge</endPosition>
|
||||||
<playFlyOverSound>true</playFlyOverSound>
|
<playFlyOverSound>true</playFlyOverSound>
|
||||||
</li>
|
</li>
|
||||||
|
<li Class="WulaFallenEmpire.CompProperties_BlockedByFlyOverFacility">
|
||||||
|
<blockedMessage>航道堵塞:已经有一艘大型舰船在殖民地上空</blockedMessage>
|
||||||
|
<!-- 可选:指定特定的FlyOver定义 -->
|
||||||
|
<!-- <specificFlyOverDef>ARA_HiveShip</specificFlyOverDef> -->
|
||||||
|
<!-- 可选:指定特定的设施名称 -->
|
||||||
|
<!-- <requiredFacility>BombardmentFacility</requiredFacility> -->
|
||||||
|
</li>
|
||||||
</comps>
|
</comps>
|
||||||
</AbilityDef>
|
</AbilityDef>
|
||||||
<AbilityDef>
|
<AbilityDef>
|
||||||
@@ -78,6 +85,13 @@
|
|||||||
<endPosition>OppositeMapEdge</endPosition>
|
<endPosition>OppositeMapEdge</endPosition>
|
||||||
<playFlyOverSound>true</playFlyOverSound>
|
<playFlyOverSound>true</playFlyOverSound>
|
||||||
</li>
|
</li>
|
||||||
|
<li Class="WulaFallenEmpire.CompProperties_BlockedByFlyOverFacility">
|
||||||
|
<blockedMessage>航道堵塞:已经有一艘大型舰船在殖民地上空</blockedMessage>
|
||||||
|
<!-- 可选:指定特定的FlyOver定义 -->
|
||||||
|
<!-- <specificFlyOverDef>ARA_HiveShip</specificFlyOverDef> -->
|
||||||
|
<!-- 可选:指定特定的设施名称 -->
|
||||||
|
<!-- <requiredFacility>BombardmentFacility</requiredFacility> -->
|
||||||
|
</li>
|
||||||
</comps>
|
</comps>
|
||||||
</AbilityDef>
|
</AbilityDef>
|
||||||
<AbilityDef>
|
<AbilityDef>
|
||||||
@@ -118,6 +132,13 @@
|
|||||||
<endPosition>OppositeMapEdge</endPosition>
|
<endPosition>OppositeMapEdge</endPosition>
|
||||||
<playFlyOverSound>true</playFlyOverSound>
|
<playFlyOverSound>true</playFlyOverSound>
|
||||||
</li>
|
</li>
|
||||||
|
<li Class="WulaFallenEmpire.CompProperties_BlockedByFlyOverFacility">
|
||||||
|
<blockedMessage>航道堵塞:已经有一艘大型舰船在殖民地上空</blockedMessage>
|
||||||
|
<!-- 可选:指定特定的FlyOver定义 -->
|
||||||
|
<!-- <specificFlyOverDef>ARA_HiveShip</specificFlyOverDef> -->
|
||||||
|
<!-- 可选:指定特定的设施名称 -->
|
||||||
|
<!-- <requiredFacility>BombardmentFacility</requiredFacility> -->
|
||||||
|
</li>
|
||||||
</comps>
|
</comps>
|
||||||
</AbilityDef>
|
</AbilityDef>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
public class CompAbilityEffect_BlockedByFlyOverFacility : CompAbilityEffect
|
||||||
|
{
|
||||||
|
public new CompProperties_BlockedByFlyOverFacility Props => (CompProperties_BlockedByFlyOverFacility)props;
|
||||||
|
|
||||||
|
public override bool CanApplyOn(LocalTargetInfo target, LocalTargetInfo dest)
|
||||||
|
{
|
||||||
|
if (!base.CanApplyOn(target, dest))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 检查是否有FlyOver存在
|
||||||
|
if (HasFlyOverWithFacilities())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
|
||||||
|
{
|
||||||
|
if (!base.Valid(target, throwMessages))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 检查是否有FlyOver存在
|
||||||
|
if (HasFlyOverWithFacilities())
|
||||||
|
{
|
||||||
|
if (throwMessages)
|
||||||
|
{
|
||||||
|
Messages.Message(Props.blockedMessage, parent.pawn, MessageTypeDefOf.RejectInput);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool GizmoDisabled(out string reason)
|
||||||
|
{
|
||||||
|
if (parent.pawn?.Map == null)
|
||||||
|
{
|
||||||
|
reason = "Cannot use outside of map";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有FlyOver存在
|
||||||
|
if (HasFlyOverWithFacilities())
|
||||||
|
{
|
||||||
|
reason = Props.blockedMessage;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.GizmoDisabled(out reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ExtraLabelMouseAttachment(LocalTargetInfo target)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var flyOvers = GetFlyOversWithFacilities();
|
||||||
|
|
||||||
|
if (flyOvers.Count > 0)
|
||||||
|
{
|
||||||
|
return $"航道堵塞: {flyOvers.Count}个飞行器在场上";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "航道畅通";
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($"[BlockedByFlyOverFacility] Error in ExtraLabelMouseAttachment: {ex}");
|
||||||
|
return "航道状态检查错误";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有任何FlyOver携带设施组件
|
||||||
|
private bool HasFlyOverWithFacilities()
|
||||||
|
{
|
||||||
|
return GetFlyOversWithFacilities().Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有携带设施组件的FlyOver
|
||||||
|
private List<FlyOver> GetFlyOversWithFacilities()
|
||||||
|
{
|
||||||
|
var flyOversWithFacilities = new List<FlyOver>();
|
||||||
|
|
||||||
|
if (parent.pawn?.Map == null)
|
||||||
|
return flyOversWithFacilities;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 获取地图上所有FlyOver
|
||||||
|
var allFlyOvers = new List<Thing>();
|
||||||
|
var dynamicObjects = parent.pawn.Map.dynamicDrawManager.DrawThings;
|
||||||
|
|
||||||
|
foreach (var thing in dynamicObjects)
|
||||||
|
{
|
||||||
|
if (thing is FlyOver flyOver && !flyOver.Destroyed)
|
||||||
|
{
|
||||||
|
allFlyOvers.Add(thing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 筛选携带设施组件的FlyOver
|
||||||
|
foreach (var thing in allFlyOvers)
|
||||||
|
{
|
||||||
|
if (thing is FlyOver flyOver)
|
||||||
|
{
|
||||||
|
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
|
||||||
|
if (facilitiesComp != null)
|
||||||
|
{
|
||||||
|
flyOversWithFacilities.Add(flyOver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Message($"[BlockedByFlyOverFacility] Found {flyOversWithFacilities.Count} FlyOvers with facilities");
|
||||||
|
|
||||||
|
return flyOversWithFacilities;
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($"[BlockedByFlyOverFacility] Error in GetFlyOversWithFacilities: {ex}");
|
||||||
|
return new List<FlyOver>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重写:应用时也进行检查
|
||||||
|
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
||||||
|
{
|
||||||
|
// 在应用前再次检查,确保安全
|
||||||
|
if (HasFlyOverWithFacilities())
|
||||||
|
{
|
||||||
|
Log.Warning($"[BlockedByFlyOverFacility] Attempted to use ability while FlyOvers are present");
|
||||||
|
Messages.Message(Props.blockedMessage, parent.pawn, MessageTypeDefOf.RejectInput);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
base.Apply(target, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CompProperties_BlockedByFlyOverFacility : CompProperties_AbilityEffect
|
||||||
|
{
|
||||||
|
// 堵塞时显示的消息
|
||||||
|
public string blockedMessage = "航道堵塞:场上有飞行器,无法释放技能";
|
||||||
|
|
||||||
|
// 可选:可以指定特定的FlyOver定义,如果为空则检查所有FlyOver
|
||||||
|
public ThingDef specificFlyOverDef;
|
||||||
|
|
||||||
|
// 可选:可以指定特定的设施名称,如果为空则检查任何设施
|
||||||
|
public string requiredFacility;
|
||||||
|
|
||||||
|
public CompProperties_BlockedByFlyOverFacility()
|
||||||
|
{
|
||||||
|
compClass = typeof(CompAbilityEffect_BlockedByFlyOverFacility);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,65 @@ namespace WulaFallenEmpire
|
|||||||
var cooldownComp = parent.GetComp<CompFlyOverCooldown>();
|
var cooldownComp = parent.GetComp<CompFlyOverCooldown>();
|
||||||
return cooldownComp == null || !cooldownComp.IsOnCooldown;
|
return cooldownComp == null || !cooldownComp.IsOnCooldown;
|
||||||
}
|
}
|
||||||
|
// 在 CompFlyOverFacilities 类中添加以下静态方法
|
||||||
|
public static bool AnyFlyOverHasFacilities(Map map)
|
||||||
|
{
|
||||||
|
if (map == null)
|
||||||
|
return false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dynamicObjects = map.dynamicDrawManager.DrawThings;
|
||||||
|
|
||||||
|
foreach (var thing in dynamicObjects)
|
||||||
|
{
|
||||||
|
if (thing is FlyOver flyOver && !flyOver.Destroyed)
|
||||||
|
{
|
||||||
|
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
|
||||||
|
if (facilitiesComp != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($"[FlyOverFacilities] Error in AnyFlyOverHasFacilities: {ex}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static List<FlyOver> GetAllFlyOversWithFacilities(Map map)
|
||||||
|
{
|
||||||
|
var result = new List<FlyOver>();
|
||||||
|
|
||||||
|
if (map == null)
|
||||||
|
return result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dynamicObjects = map.dynamicDrawManager.DrawThings;
|
||||||
|
|
||||||
|
foreach (var thing in dynamicObjects)
|
||||||
|
{
|
||||||
|
if (thing is FlyOver flyOver && !flyOver.Destroyed)
|
||||||
|
{
|
||||||
|
var facilitiesComp = flyOver.GetComp<CompFlyOverFacilities>();
|
||||||
|
if (facilitiesComp != null)
|
||||||
|
{
|
||||||
|
result.Add(flyOver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error($"[FlyOverFacilities] Error in GetAllFlyOversWithFacilities: {ex}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string GetFacilityStatus(string facilityName)
|
public string GetFacilityStatus(string facilityName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,12 +98,12 @@
|
|||||||
<Compile Include="Flyover\WULA_AircraftHangar\CompAbilityEffect_AircraftStrike.cs" />
|
<Compile Include="Flyover\WULA_AircraftHangar\CompAbilityEffect_AircraftStrike.cs" />
|
||||||
<Compile Include="Flyover\WULA_AircraftHangar\CompAircraftHangar.cs" />
|
<Compile Include="Flyover\WULA_AircraftHangar\CompAircraftHangar.cs" />
|
||||||
<Compile Include="Flyover\WULA_AircraftHangar\WorldComponent_AircraftManager.cs" />
|
<Compile Include="Flyover\WULA_AircraftHangar\WorldComponent_AircraftManager.cs" />
|
||||||
|
<Compile Include="Flyover\WULA_BlockedByFlyOverFacility\CompAbilityEffect_BlockedByFlyOverFacility.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverDropPod\CompProperties_FlyOverDropPod.cs" />
|
<Compile Include="Flyover\WULA_FlyOverDropPod\CompProperties_FlyOverDropPod.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverEscort\CompFlyOverEscort.cs" />
|
<Compile Include="Flyover\WULA_FlyOverEscort\CompFlyOverEscort.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverEscort\CompProperties_FlyOverEscort.cs" />
|
<Compile Include="Flyover\WULA_FlyOverEscort\CompProperties_FlyOverEscort.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverFacilities\CompAbilityEffect_RequireFlyOverFacility.cs" />
|
<Compile Include="Flyover\WULA_FlyOverFacilities\CompAbilityEffect_RequireFlyOverFacility.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverFacilities\CompFlyOverFacilities.cs" />
|
<Compile Include="Flyover\WULA_FlyOverFacilities\CompFlyOverFacilities.cs" />
|
||||||
<Compile Include="Flyover\WULA_FlyOverFormation\CompFlyOverFormation.cs" />
|
|
||||||
<Compile Include="Flyover\WULA_GlobalFlyOverCooldown\CompAbilityEffect_GlobalFlyOverCooldown.cs" />
|
<Compile Include="Flyover\WULA_GlobalFlyOverCooldown\CompAbilityEffect_GlobalFlyOverCooldown.cs" />
|
||||||
<Compile Include="Flyover\WULA_GlobalFlyOverCooldown\CompFlyOverCooldown.cs" />
|
<Compile Include="Flyover\WULA_GlobalFlyOverCooldown\CompFlyOverCooldown.cs" />
|
||||||
<Compile Include="Flyover\WULA_GroundStrafing\CompGroundStrafing.cs" />
|
<Compile Include="Flyover\WULA_GroundStrafing\CompGroundStrafing.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user