This commit is contained in:
2025-11-18 11:50:30 +08:00
parent 710eca55d4
commit 875edfcc41
14 changed files with 1275 additions and 89 deletions

View File

@@ -217,6 +217,56 @@
</comps>
</AbilityDef>
<AbilityDef>
<defName>WULA_Spawn_BattleShip_Artillery</defName>
<label>呼叫全域封锁舰队</label>
<description>申请沿指定航道发起全域封锁,一整只乌拉帝国舰队将在大量战机编队的掩护下沿着航道行进,并使用所有的可用武器进行轰炸,以彻底粉碎一切抵抗。</description>
<iconPath>Wula/UI/Abilities/WULA_Spawn_Fighter_Drone_Laser</iconPath>
<cooldownTicksRange>1</cooldownTicksRange>
<hotKey>Misc12</hotKey>
<casterMustBeCapableOfViolence>false</casterMustBeCapableOfViolence>
<verbProperties>
<verbClass>Verb_CastAbility</verbClass>
<drawAimPie>false</drawAimPie>
<requireLineOfSight>false</requireLineOfSight>
<warmupTime>0</warmupTime>
<range>120</range>
<targetable>true</targetable>
<targetParams>
<canTargetSelf>false</canTargetSelf>
<canTargetLocations>true</canTargetLocations>
</targetParams>
</verbProperties>
<comps>
<!-- <li Class="WulaFallenEmpire.CompProperties_AbilityResearchPrereq">
<requiredResearch>WULA_Light_Fighter_Drone_Technology</requiredResearch>
</li> -->
<!-- <li Class="WulaFallenEmpire.CompProperties_AircraftStrike">
<requiredAircraftType>WULA_Fighter_Drone_Entity</requiredAircraftType>
<aircraftCooldownTicks>5000</aircraftCooldownTicks>
<aircraftsPerUse>1</aircraftsPerUse>
</li> -->
<li Class="WulaFallenEmpire.CompProperties_AbilitySpawnFlyOver">
<flyOverDef>WULA_MotherShip_Planet_Interdiction</flyOverDef>
<flyOverType>GroundStrafing</flyOverType>
<flightSpeed>0.005</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>
</comps>
</AbilityDef>
<!-- 飞行器 -->
<AbilityDef>
<defName>WULA_Spawn_Fighter_Drone_Laser</defName>

View File

@@ -13,7 +13,7 @@
</descriptions>
<options>
<li>
<label>再见</label>
<label>我想问些事情</label>
<useCustomColors>true</useCustomColors>
<normalColor>(255,255,255,255)</normalColor>
<hoverColor>(157,201,185,195)</hoverColor>
@@ -23,6 +23,24 @@
<li>
<effects>
<li Class="WulaFallenEmpire.Effect_CloseDialog" />
<li Class="WulaFallenEmpire.Effect_TriggerRaid">
<letterLabel>陆行舰正在逼近</letterLabel>
<letterText>艾妮西娅按照要求,吸引了一艘乌拉帝国的陆行舰机械体攻击我们的殖民地!</letterText>
<points>100</points>
<faction>Mechanoid</faction>
<raidStrategy>ImmediateAttack</raidStrategy>
<raidArrivalMode>EdgeWalkIn</raidArrivalMode>
<groupKind>Combat</groupKind>
<pawnGroupMakers>
<li>
<kindDef>Combat</kindDef>
<commonality>100</commonality>
<options>
<Wula_Mech_Mobile_Factory_1>100</Wula_Mech_Mobile_Factory_1>
</options>
</li>
</pawnGroupMakers>
</li>
</effects>
</li>
</optionEffects>

View File

@@ -105,6 +105,7 @@
<li>WULA_CallAircraftCarrier</li>
<li>WULA_CallConstructionShip</li>
<li>WULA_ClearFlightPath</li>
<li>WULA_Spawn_BattleShip_Artillery</li>
</abilityDefs>
</li>
</comps>

View File

@@ -181,17 +181,22 @@
<numIncidentsRange>1</numIncidentsRange>
</li>
<!-- Odyssey grav engine quest -->
<li Class="StorytellerCompProperties_ImportantQuest">
<!-- 乌拉族初始任务 -->
<li Class="WulaFallenEmpire.StorytellerCompProperties_ImportantQuestWithFactionFilter">
<fireAfterDaysPassed>1</fireAfterDaysPassed>
<questIncident MayRequire="Ludeon.RimWorld.Odyssey">WULA_GiveQuest_Intro_Spy</questIncident>
<questDef MayRequire="Ludeon.RimWorld.Odyssey">WULA_Intro_Spy</questDef>
<questIncident>WULA_GiveQuest_Intro_Spy</questIncident>
<questDef>WULA_Intro_Spy</questDef>
<useFactionFilter>true</useFactionFilter> <!-- 添加这一行 -->
<defaultBehavior>Allow</defaultBehavior> <!-- 明确指定默认行为 -->
<factionTypeBlacklist>
<li>WULA_Awakened_Synth</li>
</factionTypeBlacklist>
<!-- <factionTypeWhitelist>
<li>Empire</li>
</factionTypeWhitelist> -->
<allowedTargetTags>
<li>Map_PlayerHome</li>
</allowedTargetTags>
<enableIfAnyModActive>
<li>Ludeon.RimWorld.Odyssey</li>
</enableIfAnyModActive>
</li>
</comps>
</StorytellerDef>

View File

@@ -750,7 +750,7 @@
<!-- 基础射线参数 -->
<hasStandardCommand>true</hasStandardCommand>
<range>52</range>
<burstShotCount>32</burstShotCount>
<burstShotCount>99999</burstShotCount>
<ticksBetweenBurstShots>1</ticksBetweenBurstShots>
<beamDamageDef>WULA_RW_Handle_Cannon_Burn</beamDamageDef>
<beamTotalDamage>1</beamTotalDamage>

View File

@@ -673,6 +673,549 @@
</comps>
</ThingDef>
<!-- 全域封锁舰队 -->
<ThingDef ParentName="EtherealThingBase">
<defName>WULA_MotherShip_Planet_Interdiction</defName>
<label>乌拉帝国母舰(炮击)</label>
<thingClass>WulaFallenEmpire.FlyOver</thingClass>
<tickerType>Normal</tickerType>
<drawerType>RealtimeOnly</drawerType>
<graphicData>
<texPath>Wula/FlyoverThing/WULA_MotherShip_Shadow</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>TransparentPostLight</shaderType>
<drawSize>(100,250)</drawSize>
<color>(195,195,195,45)</color>
</graphicData>
<skyfaller>
<shadow>Wula/Weapon/WULA_Weapon_Empty</shadow>
<shadowSize>(0, 0)</shadowSize>
<motesPerCell>0</motesPerCell>
<floatingSound>FlyOver/Flying</floatingSound>
<!-- <impactSound>FlyOver/Landing</impactSound> -->
</skyfaller>
<modExtensions>
<li Class="WulaFallenEmpire.FlyOverShadowExtension">
<customShadowPath>Wula/Weapon/WULA_Weapon_Empty</customShadowPath>
<useCustomShadow>true</useCustomShadow>
<shadowIntensity>0.8</shadowIntensity>
<minShadowAlpha>0</minShadowAlpha>
<maxShadowAlpha>0</maxShadowAlpha>
<minShadowScale>0</minShadowScale>
<maxShadowScale>0</maxShadowScale>
<!-- 淡入淡出开关 -->
<useFadeEffects>false</useFadeEffects> <!-- 完全禁用淡入淡出 -->
<useFadeIn>false</useFadeIn> <!-- 仅禁用淡入 -->
<useFadeOut>false</useFadeOut> <!-- 仅禁用淡出 -->
<useApproachAnimation>true</useApproachAnimation>
<approachDuration>1</approachDuration>
<approachOffsetDistance>50</approachOffsetDistance>
</li>
</modExtensions>
<seeThroughFog>true</seeThroughFog>
<useHitPoints>false</useHitPoints>
<selectable>false</selectable>
<alwaysHaulable>false</alwaysHaulable>
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="WulaFallenEmpire.CompProperties_ShipArtillery">
<ticksBetweenAttacks>300</ticksBetweenAttacks>
<attackDurationTicks>30</attackDurationTicks>
<attackRadius>65</attackRadius>
<skyfallerDef>WULA_Firepower_Primary_Cannon_Strafe_Skyfaller</skyfallerDef>
<shellsPerVolley>3</shellsPerVolley>
<!-- 新增派系甄别配置 -->
<useFactionDiscrimination>true</useFactionDiscrimination>
<useMicroTracking>true</useMicroTracking>
</li>
<!-- 入场信封信息 -->
<li Class="WulaFallenEmpire.CompProperties_SendLetterAfterTicks">
<ticksDelay>60</ticksDelay> <!-- 2秒后发送 -->
<letterLabel>全域封锁</letterLabel>
<letterText>全域封锁舰队已抵达,请自行寻找掩护!</letterText>
<letterDef>PositiveEvent</letterDef>
<onlySendOnce>true</onlySendOnce>
<requireOnMap>true</requireOnMap>
<destroyAfterSending>false</destroyAfterSending> <!-- 发送后销毁flyover -->
</li>
<!-- 伴飞 -->
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_MotherShip_Planet_Interdiction_Escort</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>3000</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>2</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>40</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>1</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.5</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_BattleShip_Planet_Interdiction</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>4000</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>5</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>70</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>1</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.5</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_Striker_Escort</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>1000</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>20</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>100</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>8</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.6</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_Bomber_Escort</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>1350</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>10</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>130</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>5</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.6</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
</comps>
</ThingDef>
<ThingDef ParentName="EtherealThingBase">
<defName>WULA_MotherShip_Planet_Interdiction_Escort</defName>
<label>乌拉帝国母舰(炮击)</label>
<thingClass>WulaFallenEmpire.FlyOver</thingClass>
<tickerType>Normal</tickerType>
<drawerType>RealtimeOnly</drawerType>
<graphicData>
<texPath>Wula/FlyoverThing/WULA_MotherShip_Shadow</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>TransparentPostLight</shaderType>
<drawSize>(100,250)</drawSize>
<color>(195,195,195,45)</color>
</graphicData>
<skyfaller>
<shadow>Wula/Weapon/WULA_Weapon_Empty</shadow>
<shadowSize>(0, 0)</shadowSize>
<motesPerCell>0</motesPerCell>
<floatingSound>FlyOver/Flying</floatingSound>
<!-- <impactSound>FlyOver/Landing</impactSound> -->
</skyfaller>
<modExtensions>
<li Class="WulaFallenEmpire.FlyOverShadowExtension">
<customShadowPath>Wula/Weapon/WULA_Weapon_Empty</customShadowPath>
<useCustomShadow>true</useCustomShadow>
<shadowIntensity>0.8</shadowIntensity>
<minShadowAlpha>0</minShadowAlpha>
<maxShadowAlpha>0</maxShadowAlpha>
<minShadowScale>0</minShadowScale>
<maxShadowScale>0</maxShadowScale>
<!-- 淡入淡出开关 -->
<useFadeEffects>false</useFadeEffects> <!-- 完全禁用淡入淡出 -->
<useFadeIn>false</useFadeIn> <!-- 仅禁用淡入 -->
<useFadeOut>false</useFadeOut> <!-- 仅禁用淡出 -->
<useApproachAnimation>true</useApproachAnimation>
<approachDuration>1</approachDuration>
<approachOffsetDistance>50</approachOffsetDistance>
</li>
</modExtensions>
<seeThroughFog>true</seeThroughFog>
<useHitPoints>false</useHitPoints>
<selectable>false</selectable>
<alwaysHaulable>false</alwaysHaulable>
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="WulaFallenEmpire.CompProperties_ShipArtillery">
<ticksBetweenAttacks>300</ticksBetweenAttacks>
<attackDurationTicks>300</attackDurationTicks>
<attackRadius>65</attackRadius>
<skyfallerDef>WULA_Firepower_Cannon_Salvo_Skyfaller</skyfallerDef>
<shellsPerVolley>12</shellsPerVolley>
<!-- 新增派系甄别配置 -->
<useFactionDiscrimination>true</useFactionDiscrimination>
<useMicroTracking>true</useMicroTracking>
</li>
<!-- 伴飞 -->
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_Striker_Escort</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>1000</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>20</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>100</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>8</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.6</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
<li Class="WulaFallenEmpire.CompProperties_FlyOverEscort">
<escortFlyOverDef>WULA_Bomber_Escort</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>1350</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>10</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>130</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>5</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>false</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.6</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
<min>0.6</min>
<max>0.8</max>
</heightMaskAlphaRange>
<heightMaskColor>(0.7,0.85,1.0,1.0)</heightMaskColor>
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
</comps>
</ThingDef>
<ThingDef ParentName="EtherealThingBase">
<defName>WULA_BattleShip_Planet_Interdiction</defName>
<label>乌拉帝国巡洋舰(炮击)</label>
<thingClass>WulaFallenEmpire.FlyOver</thingClass>
<tickerType>Normal</tickerType>
<drawerType>RealtimeOnly</drawerType>
<graphicData>
<texPath>Wula/FlyoverThing/WULA_BattleShip_Shadow</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>TransparentPostLight</shaderType>
<drawSize>(70,100)</drawSize>
<color>(195,195,195,45)</color>
</graphicData>
<skyfaller>
<shadow>Wula/Weapon/WULA_Weapon_Empty</shadow>
<shadowSize>(0, 0)</shadowSize>
<motesPerCell>0</motesPerCell>
<floatingSound>FlyOver/Flying</floatingSound>
<!-- <impactSound>FlyOver/Landing</impactSound> -->
</skyfaller>
<modExtensions>
<li Class="WulaFallenEmpire.FlyOverShadowExtension">
<customShadowPath>Wula/Weapon/WULA_Weapon_Empty</customShadowPath>
<useCustomShadow>true</useCustomShadow>
<shadowIntensity>0.8</shadowIntensity>
<minShadowAlpha>0</minShadowAlpha>
<maxShadowAlpha>0</maxShadowAlpha>
<minShadowScale>0</minShadowScale>
<maxShadowScale>0</maxShadowScale>
<!-- 淡入淡出开关 -->
<useFadeEffects>false</useFadeEffects> <!-- 完全禁用淡入淡出 -->
<useFadeIn>false</useFadeIn> <!-- 仅禁用淡入 -->
<useFadeOut>false</useFadeOut> <!-- 仅禁用淡出 -->
<useApproachAnimation>true</useApproachAnimation>
<approachDuration>1</approachDuration>
<approachOffsetDistance>50</approachOffsetDistance>
</li>
</modExtensions>
<seeThroughFog>true</seeThroughFog>
<useHitPoints>false</useHitPoints>
<selectable>false</selectable>
<alwaysHaulable>false</alwaysHaulable>
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="WulaFallenEmpire.CompProperties_ShipArtillery">
<ticksBetweenAttacks>300</ticksBetweenAttacks>
<attackDurationTicks>30</attackDurationTicks>
<attackRadius>25</attackRadius>
<skyfallerDef>WULA_Planet_Interdiction_EnergyLance_Skyfaller</skyfallerDef>
<shellsPerVolley>1</shellsPerVolley>
<!-- 新增派系甄别配置 -->
<useRandomTargets>true</useRandomTargets>
<useFactionDiscrimination>true</useFactionDiscrimination>
</li>
</comps>
</ThingDef>
<ThingDef ParentName="SkyfallerBase">
<defName>WULA_Planet_Interdiction_EnergyLance_Skyfaller</defName>
<label>光矛监视信标</label>
<size>(1,1)</size>
<graphicData>
<texPath>Wula/Weapon/WULA_Weapon_Empty</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>TransparentPostLight</shaderType>
<drawSize>(1,1)</drawSize>
<color>(255,255,255,150)</color>
<damageData>
<enabled>false</enabled>
</damageData>
</graphicData>
<skyfaller>
<movementType>Decelerate</movementType>
<shadow>Things/Skyfaller/SkyfallerShadowDropPod</shadow>
<shadowSize>(0, 0)</shadowSize>
<anticipationSound>DropPod_Fall</anticipationSound>
<anticipationSoundTicks>100</anticipationSoundTicks>
<!-- <impactSound>Explosion_Vaporize</impactSound> -->
<moteSpawnTime>0.05</moteSpawnTime>
<motesPerCell>0</motesPerCell>
<cameraShake>0</cameraShake>
<angleCurve>
<points>
<li>(0,0)</li>
<li>(1, 1)</li>
</points>
</angleCurve>
<spawnThing>WULA_Firepower_EnergyLance_Surveillance_Beacon</spawnThing>
</skyfaller>
</ThingDef>
<ThingDef ParentName="BuildingBase">
<defName>WULA_Planet_Interdiction_EnergyLance_Beacon</defName>
<label>光矛监视信标</label>
<description>一枚标定监视区的轰炸信标,进入此处的敌对势力都会被乌拉帝国舰队的舰炮狠狠打击。</description>
<uiIconPath>Wula/Building/WULA_WeaponArmor_Productor</uiIconPath>
<tickerType>Normal</tickerType>
<selectable>false</selectable>
<useHitPoints>false</useHitPoints>
<size>(1,1)</size>
<graphicData>
<texPath>Wula/Weapon/WULA_Weapon_Empty</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>TransparentPostLight</shaderType>
<drawSize>(72,72)</drawSize>
<color>(255,255,255,150)</color>
<damageData>
<enabled>false</enabled>
</damageData>
</graphicData>
<altitudeLayer>Building</altitudeLayer>
<passability>Standable</passability>
<castEdgeShadows>false</castEdgeShadows>
<fillPercent>0.5</fillPercent>
<canOverlapZones>false</canOverlapZones>
<pathCost>0</pathCost>
<hasInteractionCell>false</hasInteractionCell>
<rotatable>false</rotatable>
<statBases>
<WorkToBuild>1</WorkToBuild>
<Mass>0</Mass>
<Flammability>0</Flammability>
</statBases>
<resourcesFractionWhenDeconstructed>0</resourcesFractionWhenDeconstructed>
<building>
<expandHomeArea>false</expandHomeArea>
<destroySound>BuildingDestroyed_Metal_Small</destroySound>
</building>
<comps>
<li Class="WulaFallenEmpire.CompProperties_EnergyLanceTurret">
<energyLanceDef>WULA_EnergyLance_Surveillance</energyLanceDef>
<energyLanceDuration>600</energyLanceDuration>
<energyLanceMoveDistance>25</energyLanceMoveDistance>
<detectionRange>36</detectionRange>
<targetUpdateInterval>30</targetUpdateInterval>
<targetSwitchRange>20</targetSwitchRange>
<warmupTicks>45</warmupTicks>
<cooldownTicks>180</cooldownTicks>
</li>
<li Class="WulaFallenEmpire.CompProperties_FactionSetter">
<!-- <factionDef>Mechanoid</factionDef> 不写默认玩家派系-->
<usePlayerFactionIfNull>true</usePlayerFactionIfNull>
<overrideExistingFaction>false</overrideExistingFaction>
</li>
<li Class="CompProperties_Lifespan">
<lifespanTicks>600</lifespanTicks>
</li>
</comps>
</ThingDef>
<!-- 战机 -->
<ThingDef Name="WULA_Fighter_Drone_Base" ParentName="EtherealThingBase" Abstract="True">
<thingClass>WulaFallenEmpire.FlyOver</thingClass>

View File

@@ -24,33 +24,110 @@ namespace WulaFallenEmpire
if (parent.pawn?.Map == null) return;
// 销毁有 FlyOver 物体
DestroyAllFlyOvers();
// 销毁CompFlyOverFacilities 的 FlyOver
DestroyFlyOversWithFacilities();
}
// 销毁所有 FlyOver
private void DestroyAllFlyOvers()
// 销毁带有设施的 FlyOver
private void DestroyFlyOversWithFacilities()
{
List<Thing> flyOvers = new List<Thing>();
List<FlyOver> flyOversWithFacilities = new List<FlyOver>();
// 获取地图上所有的 FlyOver
foreach (Thing thing in parent.pawn.Map.listerThings.AllThings)
// 使用 CompFlyOverFacilities 的静态方法来获取所有带有设施的 FlyOver
var allFlyOvers = CompFlyOverFacilities.GetAllFlyOversWithFacilities(parent.pawn.Map);
if (allFlyOvers.Count > 0)
{
if (thing is FlyOver flyOver)
foreach (var flyOver in allFlyOvers)
{
flyOvers.Add(flyOver);
if (flyOver != null && !flyOver.Destroyed)
{
flyOversWithFacilities.Add(flyOver);
}
}
}
// 销毁找到的 FlyOver
foreach (FlyOver flyOver in flyOvers)
// 销毁找到的带有设施的 FlyOver
foreach (FlyOver flyOver in flyOversWithFacilities)
{
flyOver.EmergencyDestroy();
Log.Message($"[DestroyFlyOverByFacilities] Destroyed FlyOver with facilities at {flyOver.Position}");
}
if (flyOvers.Count > 0)
if (flyOversWithFacilities.Count > 0)
{
Messages.Message($"WULA_DestroyFlyOver".Translate(), parent.pawn, MessageTypeDefOf.PositiveEvent);
Messages.Message($"WULA_DestroyFlyOver".Translate(flyOversWithFacilities.Count), parent.pawn, MessageTypeDefOf.PositiveEvent);
}
else
{
Messages.Message("WULA_NoFlyOverWithFacilities".Translate(), parent.pawn, MessageTypeDefOf.NeutralEvent);
}
}
// 添加验证方法,确保只在有相关 FlyOver 时可用
public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
{
if (!base.Valid(target, throwMessages))
return false;
// 检查是否有带有设施的 FlyOver
if (parent.pawn?.Map == null)
return false;
var flyOversWithFacilities = CompFlyOverFacilities.GetAllFlyOversWithFacilities(parent.pawn.Map);
if (flyOversWithFacilities.Count == 0)
{
if (throwMessages)
{
Messages.Message("WULA_NoFlyOverWithFacilities".Translate(), 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
var flyOversWithFacilities = CompFlyOverFacilities.GetAllFlyOversWithFacilities(parent.pawn.Map);
if (flyOversWithFacilities.Count == 0)
{
reason = "No FlyOver with facilities found";
return true;
}
return base.GizmoDisabled(out reason);
}
public override string ExtraLabelMouseAttachment(LocalTargetInfo target)
{
try
{
if (parent.pawn?.Map == null)
return "Cannot use outside of map";
var flyOversWithFacilities = CompFlyOverFacilities.GetAllFlyOversWithFacilities(parent.pawn.Map);
if (flyOversWithFacilities.Count > 0)
{
return $"Will destroy {flyOversWithFacilities.Count} FlyOver(s) with facilities";
}
return "No FlyOver with facilities found";
}
catch (System.Exception ex)
{
Log.Error($"[DestroyFlyOverByFacilities] Error in ExtraLabelMouseAttachment: {ex}");
return "Error checking FlyOver status";
}
}
}

View File

@@ -42,11 +42,16 @@ namespace WulaFallenEmpire
public bool avoidHittingFlyOver = true;
// 信件通知
public bool sendAttackLetter = true; // 是否发送攻击信件
public bool sendAttackLetter = false; // 是否发送攻击信件
public string customLetterLabel; // 自定义信件标题
public string customLetterText; // 自定义信件内容
public LetterDef letterDef = LetterDefOf.ThreatBig; // 信件类型
// 新增:派系甄别系统
public bool useFactionDiscrimination = false; // 是否使用派系甄别
public FactionDef targetFaction; // 目标派系(友军派系)
public bool useMicroTracking = false; // 是否启用微追踪
public CompProperties_ShipArtillery()
{
compClass = typeof(CompShipArtillery);

View File

@@ -24,6 +24,16 @@ namespace WulaFallenEmpire
// 目标跟踪
private List<IntVec3> previousTargets = new List<IntVec3>();
// 新增:微追踪目标列表
private List<LocalTargetInfo> microTrackingTargets = new List<LocalTargetInfo>();
private List<float> microTrackingWeights = new List<float>(); // 新增:权重列表
// 新增:目标类型权重配置
private const float PAWN_WEIGHT = 5.0f; // Pawn权重5倍
private const float OWNED_BUILDING_WEIGHT = 1.0f; // 有主建筑权重1倍
private const float UNOWNED_BUILDING_WEIGHT = 0.01f; // 无主建筑权重0.01倍
private const float OTHER_WEIGHT = 1.0f; // 其他目标权重1倍
public override void Initialize(CompProperties props)
{
base.Initialize(props);
@@ -31,6 +41,7 @@ namespace WulaFallenEmpire
ticksUntilNextAttack = Props.ticksBetweenAttacks;
Log.Message($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius");
Log.Message($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {Props.targetFaction?.defName ?? "None"}, Micro Tracking: {Props.useMicroTracking}");
}
public override void CompTick()
@@ -40,6 +51,12 @@ namespace WulaFallenEmpire
if (parent is not FlyOver flyOver || !flyOver.Spawned || flyOver.Map == null)
return;
// 更新微追踪目标列表(如果需要)
if (Props.useMicroTracking && Props.useFactionDiscrimination)
{
UpdateMicroTrackingTargets(flyOver);
}
// 更新预热状态
if (isWarmingUp)
{
@@ -65,6 +82,173 @@ namespace WulaFallenEmpire
}
}
// 新增:更新微追踪目标列表
private void UpdateMicroTrackingTargets(FlyOver flyOver)
{
microTrackingTargets.Clear();
microTrackingWeights.Clear();
Faction targetFaction = GetTargetFaction(flyOver);
if (targetFaction == null) return;
// 获取飞越物体当前位置
IntVec3 center = GetFlyOverPosition(flyOver);
// 搜索范围内的所有潜在目标
foreach (IntVec3 cell in GenRadial.RadialCellsAround(center, Props.attackRadius, true))
{
if (!cell.InBounds(flyOver.Map)) continue;
// 检查建筑
Building building = cell.GetEdifice(flyOver.Map);
if (building != null && IsValidMicroTrackingTarget(building, targetFaction))
{
microTrackingTargets.Add(new LocalTargetInfo(building));
float weight = GetTargetWeight(building);
microTrackingWeights.Add(weight);
}
// 检查生物
List<Thing> thingList = cell.GetThingList(flyOver.Map);
foreach (Thing thing in thingList)
{
if (thing is Pawn pawn && IsValidMicroTrackingTarget(pawn, targetFaction))
{
microTrackingTargets.Add(new LocalTargetInfo(pawn));
float weight = GetTargetWeight(pawn);
microTrackingWeights.Add(weight);
}
}
}
// 移除重复目标(基于位置)
for (int i = microTrackingTargets.Count - 1; i >= 0; i--)
{
for (int j = 0; j < i; j++)
{
if (microTrackingTargets[i].Cell == microTrackingTargets[j].Cell)
{
microTrackingTargets.RemoveAt(i);
microTrackingWeights.RemoveAt(i);
break;
}
}
}
if (DebugSettings.godMode)
{
Log.Message($"MicroTracking: Found {microTrackingTargets.Count} targets for faction {targetFaction.def.defName}");
// 输出目标统计信息
var targetStats = GetTargetStatistics();
Log.Message($"Target Statistics - Pawns: {targetStats.pawnCount}, Owned Buildings: {targetStats.ownedBuildingCount}, Unowned Buildings: {targetStats.unownedBuildingCount}, Others: {targetStats.otherCount}");
}
}
// 新增:获取目标权重
private float GetTargetWeight(Thing thing)
{
if (thing is Pawn)
{
return PAWN_WEIGHT;
}
else if (thing is Building building)
{
if (building.Faction == null)
{
return UNOWNED_BUILDING_WEIGHT;
}
else
{
return OWNED_BUILDING_WEIGHT;
}
}
else
{
return OTHER_WEIGHT;
}
}
// 新增:获取目标统计信息
private (int pawnCount, int ownedBuildingCount, int unownedBuildingCount, int otherCount) GetTargetStatistics()
{
int pawnCount = 0;
int ownedBuildingCount = 0;
int unownedBuildingCount = 0;
int otherCount = 0;
for (int i = 0; i < microTrackingTargets.Count; i++)
{
Thing thing = microTrackingTargets[i].Thing;
if (thing == null) continue;
if (thing is Pawn)
{
pawnCount++;
}
else if (thing is Building building)
{
if (building.Faction == null)
{
unownedBuildingCount++;
}
else
{
ownedBuildingCount++;
}
}
else
{
otherCount++;
}
}
return (pawnCount, ownedBuildingCount, unownedBuildingCount, otherCount);
}
// 新增:检查是否为有效的微追踪目标
private bool IsValidMicroTrackingTarget(Thing thing, Faction targetFaction)
{
if (thing == null || thing.Destroyed) return false;
// 检查派系关系:目标派系的友军不应该被攻击
if (thing.Faction != null)
{
if (thing.Faction == targetFaction) return false;
if (thing.Faction.RelationKindWith(targetFaction) == FactionRelationKind.Ally) return false;
}
// 检查是否在保护范围内
if (Props.avoidPlayerAssets && IsNearPlayerAssets(thing.Position, thing.Map))
{
return false;
}
// 避免击中飞越物体本身
if (Props.avoidHittingFlyOver && thing.Position.DistanceTo(parent.Position) < 10f)
{
return false;
}
return true;
}
// 新增:获取目标派系
private Faction GetTargetFaction(FlyOver flyOver)
{
if (!Props.useFactionDiscrimination)
return null;
// 如果指定了目标派系,使用指定的派系
if (Props.targetFaction != null)
{
Faction faction = Find.FactionManager.FirstFactionOfDef(Props.targetFaction);
if (faction != null) return faction;
}
// 否则使用玩家当前派系
return Faction.OfPlayer;
}
private void StartAttack(FlyOver flyOver)
{
if (!CanAttack(flyOver))
@@ -195,8 +379,16 @@ namespace WulaFallenEmpire
return;
}
// 直接选择随机目标
IntVec3 shellTarget = SelectRandomTarget(flyOver);
// 选择目标
IntVec3 shellTarget;
if (Props.useMicroTracking && Props.useFactionDiscrimination && microTrackingTargets.Count > 0)
{
shellTarget = SelectMicroTrackingTarget(flyOver);
}
else
{
shellTarget = SelectRandomTarget(flyOver);
}
// 关键修复:使用 SkyfallerMaker 创建并立即生成 Skyfaller
SkyfallerMaker.SpawnSkyfaller(shellDef, shellTarget, flyOver.Map);
@@ -216,6 +408,79 @@ namespace WulaFallenEmpire
}
}
// 修改:微追踪目标选择 - 现在使用权重系统
private IntVec3 SelectMicroTrackingTarget(FlyOver flyOver)
{
if (microTrackingTargets.Count == 0)
{
Log.Warning("MicroTracking: No targets available, falling back to random target");
return SelectRandomTarget(flyOver);
}
// 使用权重系统选择目标
LocalTargetInfo selectedTarget = SelectTargetByWeight();
IntVec3 targetCell = selectedTarget.Cell;
// 在目标周围添加随机偏移,避免过于精确
float offsetDistance = Rand.Range(0f, 2f);
float angle = Rand.Range(0f, 360f);
IntVec3 offsetTarget = targetCell;
offsetTarget.x += Mathf.RoundToInt(Mathf.Cos(angle * Mathf.Deg2Rad) * offsetDistance);
offsetTarget.z += Mathf.RoundToInt(Mathf.Sin(angle * Mathf.Deg2Rad) * offsetDistance);
// 确保目标在地图内
if (!offsetTarget.InBounds(flyOver.Map))
{
offsetTarget = targetCell;
}
if (DebugSettings.godMode)
{
Thing selectedThing = selectedTarget.Thing;
string targetType = selectedThing is Pawn ? "Pawn" :
selectedThing is Building building ?
(building.Faction == null ? "Unowned Building" : "Owned Building") : "Other";
Log.Message($"MicroTracking: Targeting {selectedThing?.Label ?? "unknown"} ({targetType}) at {targetCell}, final target: {offsetTarget}");
}
return offsetTarget;
}
// 新增:基于权重的目标选择
private LocalTargetInfo SelectTargetByWeight()
{
if (microTrackingTargets.Count == 0)
return LocalTargetInfo.Invalid;
if (microTrackingTargets.Count == 1)
return microTrackingTargets[0];
// 计算总权重
float totalWeight = 0f;
foreach (float weight in microTrackingWeights)
{
totalWeight += weight;
}
// 随机选择
float randomValue = Rand.Range(0f, totalWeight);
float currentSum = 0f;
for (int i = 0; i < microTrackingTargets.Count; i++)
{
currentSum += microTrackingWeights[i];
if (randomValue <= currentSum)
{
return microTrackingTargets[i];
}
}
// 回退到最后一个目标
return microTrackingTargets[microTrackingTargets.Count - 1];
}
private ThingDef SelectShellDef()
{
if (Props.skyfallerDefs != null && Props.skyfallerDefs.Count > 0)
@@ -352,6 +617,45 @@ namespace WulaFallenEmpire
if (!Props.avoidPlayerAssets)
return false;
// 如果启用了派系甄别,检查目标派系
if (Props.useFactionDiscrimination)
{
Faction targetFaction = GetTargetFaction(parent as FlyOver);
if (targetFaction != null)
{
foreach (IntVec3 checkCell in GenRadial.RadialCellsAround(cell, Props.playerAssetAvoidanceRadius, true))
{
if (!checkCell.InBounds(map))
continue;
// 检查目标派系建筑
var building = checkCell.GetEdifice(map);
if (building != null && building.Faction == targetFaction)
return true;
// 检查目标派系殖民者
var pawn = map.thingGrid.ThingAt<Pawn>(checkCell);
if (pawn != null && pawn.Faction == targetFaction && pawn.RaceProps.Humanlike)
return true;
// 检查目标派系动物
var animal = map.thingGrid.ThingAt<Pawn>(checkCell);
if (animal != null && animal.Faction == targetFaction && animal.RaceProps.Animal)
return true;
// 检查目标派系物品
var items = checkCell.GetThingList(map);
foreach (var item in items)
{
if (item.Faction == targetFaction && item.def.category == ThingCategory.Item)
return true;
}
}
return false;
}
}
// 默认行为:检查玩家资产
foreach (IntVec3 checkCell in GenRadial.RadialCellsAround(cell, Props.playerAssetAvoidanceRadius, true))
{
if (!checkCell.InBounds(map))
@@ -470,6 +774,8 @@ namespace WulaFallenEmpire
Scribe_Values.Look(ref isWarmingUp, "isWarmingUp", false);
Scribe_Values.Look(ref currentTarget, "currentTarget");
Scribe_Collections.Look(ref previousTargets, "previousTargets", LookMode.Value);
Scribe_Collections.Look(ref microTrackingTargets, "microTrackingTargets", LookMode.LocalTargetInfo);
Scribe_Collections.Look(ref microTrackingWeights, "microTrackingWeights", LookMode.Value);
}
public override IEnumerable<Gizmo> CompGetGizmosExtra()
@@ -504,9 +810,44 @@ namespace WulaFallenEmpire
IntVec3 flyOverPos = GetFlyOverPosition(flyOver);
Log.Message($"FlyOver - DrawPos: {flyOver.DrawPos}, Position: {flyOver.Position}, Calculated: {flyOverPos}");
Log.Message($"Current Target: {currentTarget}, Distance: {flyOverPos.DistanceTo(currentTarget):F1}");
// 显示派系甄别信息
Faction targetFaction = GetTargetFaction(flyOver);
Log.Message($"Faction Discrimination: {Props.useFactionDiscrimination}, Target Faction: {targetFaction?.def.defName ?? "None"}");
Log.Message($"Micro Tracking: {Props.useMicroTracking}, Targets Found: {microTrackingTargets.Count}");
// 显示目标统计
var stats = GetTargetStatistics();
Log.Message($"Target Stats - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Others: {stats.otherCount}");
}
}
};
// 显示微追踪目标信息
if (Props.useMicroTracking && Props.useFactionDiscrimination)
{
yield return new Command_Action
{
defaultLabel = $"Dev: Show Micro Targets ({microTrackingTargets.Count})",
action = () =>
{
if (parent is FlyOver flyOver)
{
for (int i = 0; i < microTrackingTargets.Count; i++)
{
var target = microTrackingTargets[i];
float weight = microTrackingWeights[i];
Thing thing = target.Thing;
string type = thing is Pawn ? "Pawn" :
thing is Building building ?
(building.Faction == null ? "Unowned Building" : "Owned Building") : "Other";
Log.Message($"Micro Target: {thing?.Label ?? "Unknown"} ({type}) at {target.Cell}, Weight: {weight:F2}");
}
}
}
};
}
}
}

View File

@@ -0,0 +1,33 @@
using RimWorld;
using System.Collections.Generic;
using Verse;
namespace WulaFallenEmpire
{
public class StorytellerCompProperties_ImportantQuestWithFactionFilter : StorytellerCompProperties_ImportantQuest
{
// 派系类型白名单 - 只有这些派系类型的殖民地会触发任务
public List<FactionDef> factionTypeWhitelist;
// 派系类型黑名单 - 这些派系类型的殖民地不会触发任务
public List<FactionDef> factionTypeBlacklist;
// 是否启用派系过滤
public bool useFactionFilter = false;
// 默认行为(当派系不在白名单中时的处理方式)
public FactionFilterDefaultBehavior defaultBehavior = FactionFilterDefaultBehavior.Allow;
public StorytellerCompProperties_ImportantQuestWithFactionFilter()
{
compClass = typeof(StorytellerComp_ImportantQuestWithFactionFilter);
}
}
// 派系过滤的默认行为枚举
public enum FactionFilterDefaultBehavior
{
Allow, // 允许不在列表中的派系
Deny // 拒绝不在列表中的派系
}
}

View File

@@ -0,0 +1,175 @@
using RimWorld;
using System.Collections.Generic;
using Verse;
using System.Text;
using System.Linq;
using RimWorld.Planet;
namespace WulaFallenEmpire
{
public class StorytellerComp_ImportantQuestWithFactionFilter : StorytellerComp
{
private StorytellerCompProperties_ImportantQuestWithFactionFilter FilterProps =>
(StorytellerCompProperties_ImportantQuestWithFactionFilter)props;
// 重新实现基类的私有属性
private static int IntervalsPassed => Find.TickManager.TicksGame / 1000;
private bool BeenGivenQuest => Find.QuestManager.QuestsListForReading.Any((Quest q) => q.root == FilterProps.questDef);
public override IEnumerable<FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
{
// 先检查基础条件(天数、是否已给任务等)
if (IntervalsPassed <= FilterProps.fireAfterDaysPassed * 60 || BeenGivenQuest)
yield break;
// 检查派系过滤条件
if (!PassesFactionFilter(target))
yield break;
IncidentDef questIncident = FilterProps.questIncident;
if (questIncident.TargetAllowed(target))
{
yield return new FiringIncident(questIncident, this, GenerateParms(questIncident.category, target));
}
}
/// <summary>
/// 检查目标是否符合派系过滤条件
/// </summary>
private bool PassesFactionFilter(IIncidentTarget target)
{
// 如果不启用派系过滤,直接通过
if (!FilterProps.useFactionFilter)
return true;
// 获取目标的派系
Faction faction = GetTargetFaction(target);
if (faction == null)
return false;
// 检查黑名单
if (FilterProps.factionTypeBlacklist != null &&
FilterProps.factionTypeBlacklist.Contains(faction.def))
{
Log.Message($"[FactionFilter] Quest blocked: {faction.def.defName} is in blacklist");
return false;
}
// 检查白名单
if (FilterProps.factionTypeWhitelist != null &&
FilterProps.factionTypeWhitelist.Count > 0)
{
bool inWhitelist = FilterProps.factionTypeWhitelist.Contains(faction.def);
switch (FilterProps.defaultBehavior)
{
case FactionFilterDefaultBehavior.Allow:
// 白名单模式:在白名单中或默认允许
if (!inWhitelist)
{
Log.Message($"[FactionFilter] Quest allowed: {faction.def.defName} not in whitelist, but default behavior is Allow");
}
return true;
case FactionFilterDefaultBehavior.Deny:
// 白名单模式:只有在白名单中才允许
if (inWhitelist)
{
Log.Message($"[FactionFilter] Quest allowed: {faction.def.defName} is in whitelist");
return true;
}
else
{
Log.Message($"[FactionFilter] Quest blocked: {faction.def.defName} not in whitelist and default behavior is Deny");
return false;
}
}
}
// 如果没有设置白名单,根据默认行为决定
switch (FilterProps.defaultBehavior)
{
case FactionFilterDefaultBehavior.Allow:
Log.Message($"[FactionFilter] Quest allowed: No whitelist, default behavior is Allow");
return true;
case FactionFilterDefaultBehavior.Deny:
Log.Message($"[FactionFilter] Quest blocked: No whitelist, default behavior is Deny");
return false;
default:
return true;
}
}
/// <summary>
/// 获取目标的派系
/// </summary>
private Faction GetTargetFaction(IIncidentTarget target)
{
if (target is Map map)
{
return map.ParentFaction ?? Faction.OfPlayer;
}
else if (target is World world)
{
return Faction.OfPlayer;
}
else if (target is Caravan caravan)
{
return caravan.Faction;
}
return Faction.OfPlayer;
}
/// <summary>
/// 调试方法:显示当前过滤状态
/// </summary>
public string GetFactionFilterStatus(IIncidentTarget target)
{
if (!FilterProps.useFactionFilter)
return "Faction filter: DISABLED";
Faction faction = GetTargetFaction(target);
if (faction == null)
return "Faction filter: NO FACTION";
StringBuilder status = new StringBuilder();
status.AppendLine($"Faction filter: {faction.def.defName}");
// 黑名单检查
if (FilterProps.factionTypeBlacklist != null &&
FilterProps.factionTypeBlacklist.Contains(faction.def))
{
status.AppendLine("❌ BLACKLISTED");
return status.ToString();
}
// 白名单检查
if (FilterProps.factionTypeWhitelist != null &&
FilterProps.factionTypeWhitelist.Count > 0)
{
bool inWhitelist = FilterProps.factionTypeWhitelist.Contains(faction.def);
if (inWhitelist)
{
status.AppendLine("✅ WHITELISTED");
}
else
{
status.AppendLine(FilterProps.defaultBehavior == FactionFilterDefaultBehavior.Allow ?
"⚠️ NOT IN WHITELIST (Allowed by default)" :
"❌ NOT IN WHITELIST (Denied by default)");
}
}
else
{
status.AppendLine(FilterProps.defaultBehavior == FactionFilterDefaultBehavior.Allow ?
"✅ NO WHITELIST (Allowed by default)" :
"❌ NO WHITELIST (Denied by default)");
}
return status.ToString();
}
}
}

View File

@@ -1,63 +0,0 @@
using System.Collections.Generic;
using RimWorld;
using Verse;
namespace WulaFallenEmpire
{
public class StorytellerComp_SingleOnceFixed_FactionFilter : StorytellerComp_SingleOnceFixed
{
private StorytellerCompProperties_SingleOnceFixed_FactionFilter PropsFilter => (StorytellerCompProperties_SingleOnceFixed_FactionFilter)props;
public override IEnumerable<FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
{
// 检查派系过滤条件
if (!CheckFactionFilter())
{
yield break;
}
// 调用父类的逻辑
foreach (var incident in base.MakeIntervalIncidents(target))
{
yield return incident;
}
}
private bool CheckFactionFilter()
{
if (Faction.OfPlayer == null)
return false;
var playerFactionDef = Faction.OfPlayer.def;
// 优先检查白名单:如果白名单有内容,只有白名单内的派系才能触发
if (PropsFilter.allowedFactionTypes != null && PropsFilter.allowedFactionTypes.Count > 0)
{
return PropsFilter.allowedFactionTypes.Contains(playerFactionDef);
}
// 然后检查黑名单:如果黑名单有内容,黑名单内的派系不能触发
if (PropsFilter.excludedFactionTypes != null && PropsFilter.excludedFactionTypes.Count > 0)
{
return !PropsFilter.excludedFactionTypes.Contains(playerFactionDef);
}
// 如果既没有白名单也没有黑名单,所有派系都能触发
return true;
}
}
public class StorytellerCompProperties_SingleOnceFixed_FactionFilter : StorytellerCompProperties_SingleOnceFixed
{
// 黑名单:这些派系类型不会触发事件
public List<FactionDef> excludedFactionTypes;
// 白名单:只有这些派系类型会触发事件(优先级高于黑名单)
public List<FactionDef> allowedFactionTypes;
public StorytellerCompProperties_SingleOnceFixed_FactionFilter()
{
compClass = typeof(StorytellerComp_SingleOnceFixed_FactionFilter);
}
}
}

View File

@@ -208,7 +208,8 @@
<Compile Include="Stat\StatWorker_Energy.cs" />
<Compile Include="Stat\StatWorker_Maintenance.cs" />
<Compile Include="Stat\StatWorker_NanoRepair.cs" />
<Compile Include="Storyteller\StorytellerComp_SingleOnceFixed_FactionFilter.cs" />
<Compile Include="Storyteller\StorytellerCompProperties_ImportantQuestWithFactionFilter.cs" />
<Compile Include="Storyteller\StorytellerComp_ImportantQuestWithFactionFilter.cs" />
<Compile Include="ThingComp\CompAndPatch_GiveHediffOnShot.cs" />
<Compile Include="ThingComp\CompApparelInterceptor.cs" />
<Compile Include="ThingComp\CompPsychicScaling.cs" />