This commit is contained in:
2025-12-28 15:31:14 +08:00
parent 180f678173
commit 0ce11a0d86
6 changed files with 90 additions and 28 deletions

View File

@@ -143,16 +143,18 @@
<cooldownTicksRange>1</cooldownTicksRange> <cooldownTicksRange>1</cooldownTicksRange>
<hotKey>Misc12</hotKey> <hotKey>Misc12</hotKey>
<casterMustBeCapableOfViolence>false</casterMustBeCapableOfViolence> <casterMustBeCapableOfViolence>false</casterMustBeCapableOfViolence>
<displayGizmoWhileUndrafted>true</displayGizmoWhileUndrafted>
<disableGizmoWhileUndrafted>false</disableGizmoWhileUndrafted>
<verbProperties> <verbProperties>
<verbClass>Verb_CastAbility</verbClass> <verbClass>Verb_CastAbility</verbClass>
<drawAimPie>false</drawAimPie> <drawAimPie>false</drawAimPie>
<requireLineOfSight>false</requireLineOfSight> <requireLineOfSight>false</requireLineOfSight>
<warmupTime>0</warmupTime> <warmupTime>2</warmupTime>
<range>500</range> <range>-1</range>
<targetable>true</targetable> <targetable>false</targetable>
<targetParams> <targetParams>
<canTargetSelf>false</canTargetSelf> <canTargetSelf>true</canTargetSelf>
<canTargetLocations>true</canTargetLocations> <canTargetLocations>false</canTargetLocations>
</targetParams> </targetParams>
</verbProperties> </verbProperties>
<comps> <comps>
@@ -161,23 +163,8 @@
<aircraftCooldownTicks>15000</aircraftCooldownTicks> <aircraftCooldownTicks>15000</aircraftCooldownTicks>
<aircraftsPerUse>1</aircraftsPerUse> <aircraftsPerUse>1</aircraftsPerUse>
</li> </li>
<li Class="WulaFallenEmpire.CompProperties_AbilitySpawnFlyOver"> <li Class="WulaFallenEmpire.CompProperties_AbilityEnableOverwatch">
<flyOverDef>WULA_MotherShip_Planet_Interdiction</flyOverDef> <durationSeconds>180</durationSeconds>
<flyOverType>GroundStrafing</flyOverType>
<flightSpeed>0.02</flightSpeed>
<altitude>20</altitude>
<playFlyOverSound>true</playFlyOverSound>
<approachType>Perpendicular</approachType>
<!-- 只传递信号,不传递具体参数 -->
<enableSectorSurveillance>true</enableSectorSurveillance>
<!-- 可视化 -->
<showStrafePreview>false</showStrafePreview>
<!-- 预览配置 -->
<showSectorPreview>true</showSectorPreview>
<sectorPreviewColor>(0.3,0.7,1.0,0.3)</sectorPreviewColor>
</li> </li>
<li Class="WulaFallenEmpire.CompProperties_AbilityRequiresNonHostility"> <li Class="WulaFallenEmpire.CompProperties_AbilityRequiresNonHostility">
<factionDef>Wula_PIA_Legion_Faction</factionDef> <factionDef>Wula_PIA_Legion_Faction</factionDef>

View File

@@ -172,7 +172,6 @@
<Wula_AI_Thinking_RetrySuffix> 重试中</Wula_AI_Thinking_RetrySuffix> <Wula_AI_Thinking_RetrySuffix> 重试中</Wula_AI_Thinking_RetrySuffix>
<Wula_ResourceDrop>{FACTION_name}已经在附近投下了一些资源。</Wula_ResourceDrop> <Wula_ResourceDrop>{FACTION_name}已经在附近投下了一些资源。</Wula_ResourceDrop>
<!-- AI Overwatch --> <!-- AI Overwatch -->
<WULA_AIOverwatch_Label>P.I.A 正在接管轨道防御!</WULA_AIOverwatch_Label> <WULA_AIOverwatch_Label>P.I.A 正在接管轨道防御!</WULA_AIOverwatch_Label>
<WULA_AIOverwatch_Desc>P.I.A 已经接管了轨道防御系统,正在持续扫描敌对目标。\n\n如果有敌人出现且无误伤风险轨道舰队将自动进行打击。\n\n剩余时间{0} 秒</WULA_AIOverwatch_Desc> <WULA_AIOverwatch_Desc>P.I.A 已经接管了轨道防御系统,正在持续扫描敌对目标。\n\n如果有敌人出现且无误伤风险轨道舰队将自动进行打击。\n\n剩余时间{0} 秒</WULA_AIOverwatch_Desc>

View File

@@ -0,0 +1,76 @@
using System;
using RimWorld;
using Verse;
using WulaFallenEmpire.EventSystem.AI;
namespace WulaFallenEmpire
{
public class CompProperties_AbilityEnableOverwatch : CompProperties_AbilityEffect
{
public int durationSeconds = 180; // Default 3 minutes
public CompProperties_AbilityEnableOverwatch()
{
compClass = typeof(CompAbilityEffect_EnableOverwatch);
}
}
public class CompAbilityEffect_EnableOverwatch : CompAbilityEffect
{
public new CompProperties_AbilityEnableOverwatch Props => (CompProperties_AbilityEnableOverwatch)props;
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
Map map = parent.pawn?.Map ?? Find.CurrentMap;
if (map == null)
{
Messages.Message("Error: No active map.", MessageTypeDefOf.RejectInput);
return;
}
var overwatch = map.GetComponent<MapComponent_AIOverwatch>();
if (overwatch == null)
{
overwatch = new MapComponent_AIOverwatch(map);
map.components.Add(overwatch);
}
overwatch.EnableOverwatch(Props.durationSeconds);
}
public override bool CanApplyOn(LocalTargetInfo target, LocalTargetInfo dest)
{
if (!base.CanApplyOn(target, dest))
return false;
Map map = parent.pawn?.Map ?? Find.CurrentMap;
if (map == null)
return false;
var overwatch = map.GetComponent<MapComponent_AIOverwatch>();
if (overwatch != null && overwatch.IsEnabled)
{
// Already active, show remaining time
return false;
}
return true;
}
public override string ExtraLabelMouseAttachment(LocalTargetInfo target)
{
Map map = parent.pawn?.Map ?? Find.CurrentMap;
if (map != null)
{
var overwatch = map.GetComponent<MapComponent_AIOverwatch>();
if (overwatch != null && overwatch.IsEnabled)
{
return $"Already active ({overwatch.DurationTicks / 60}s remaining)";
}
}
return base.ExtraLabelMouseAttachment(target);
}
}
}

View File

@@ -63,10 +63,10 @@ namespace WulaFallenEmpire.EventSystem.AI
{ {
try try
{ {
var flyOverDef = DefDatabase<ThingDef>.GetNamedSilentFail("WULA_AircraftCarrier"); var flyOverDef = DefDatabase<ThingDef>.GetNamedSilentFail("WULA_MotherShip_Planet_Interdiction");
if (flyOverDef == null) if (flyOverDef == null)
{ {
WulaLog.Debug("[AI Overwatch] Could not find WULA_AircraftCarrier ThingDef."); WulaLog.Debug("[AI Overwatch] Could not find WULA_MotherShip_Planet_Interdiction ThingDef.");
return; return;
} }
@@ -80,14 +80,14 @@ namespace WulaFallenEmpire.EventSystem.AI
startPos, startPos,
endPos, endPos,
map, map,
speed: 0.03f, speed: 0.02f, // Slower for mothership
height: 20f height: 20f
); );
if (flyOver != null) if (flyOver != null)
{ {
Messages.Message("WULA_AIOverwatch_FleetCalled".Translate(), MessageTypeDefOf.PositiveEvent); Messages.Message("WULA_AIOverwatch_FleetCalled".Translate(), MessageTypeDefOf.PositiveEvent);
WulaLog.Debug($"[AI Overwatch] Called fleet: WULA_AircraftCarrier spawned from {startPos} to {endPos}."); WulaLog.Debug($"[AI Overwatch] Called fleet: WULA_MotherShip_Planet_Interdiction spawned from {startPos} to {endPos}.");
} }
} }
catch (Exception ex) catch (Exception ex)