This commit is contained in:
2025-11-02 02:39:53 +08:00
parent 392a114f17
commit 7ec0fb64db
12 changed files with 543 additions and 71 deletions

Binary file not shown.

View File

@@ -1693,7 +1693,7 @@
</offsets>
</li>
<li>
<path>ArachnaeSwarm/Things/ARA_HiveNode/Addons/ArachnaeNode_Race_Addons_NeuroSwarm</path>
<path>ArachnaeSwarm/Apparel/ARA_Evening_Dress_Hat</path>
<inFrontOfBody>true</inFrontOfBody>
<layerInvert>false</layerInvert>
<offsets>

View File

@@ -170,13 +170,13 @@
<comps>
<!-- 入场信封信息 -->
<li Class="ArachnaeSwarm.CompProperties_SendLetterAfterTicks">
<ticksDelay>60</ticksDelay> <!-- 2秒后发送 -->
<ticksDelay>60</ticksDelay> <!-- 2秒后发送 -->
<letterLabel>虫巢母舰</letterLabel>
<letterText>苍穹之上传来嘶鸣,无数的虫群掠过殖民地,一只庞然大物投下的阴影遮天蔽日——\n\n虫巢母舰阿拉克涅虫群中最大的节点生物也是虫群永恒远征的支柱。现在正有这样的一只骇人之物盘踞在殖民地的上空。它会使用一切手段摧毁你的防御并投放无穷无尽的虫海淹没你的殖民者直到其离开殖民地上方轨道。准备好迎接冲击</letterText>
<letterDef>ThreatBig</letterDef>
<onlySendOnce>true</onlySendOnce>
<requireOnMap>true</requireOnMap>
<destroyAfterSending>false</destroyAfterSending> <!-- 发送后销毁flyover -->
<destroyAfterSending>false</destroyAfterSending> <!-- 发送后销毁flyover -->
</li>
<!-- 空投 -->
<li Class="ArachnaeSwarm.CompProperties_FlyOverDropPods">
@@ -244,16 +244,16 @@
<attackRadius>60</attackRadius>
<shellsPerVolley>3</shellsPerVolley>
<ignoreProtectionChance>0.1</ignoreProtectionChance>
<skyfallerDef>ARA_HiveShip_Fire_Incoming</skyfallerDef>
<attackSound>Skyfaller_Crashing</attackSound>
<impactSound>Explosion_Bomb</impactSound>
<useRandomTargets>true</useRandomTargets>
<avoidPlayerAssets>true</avoidPlayerAssets>
<playerAssetAvoidanceRadius>10</playerAssetAvoidanceRadius>
<sendAttackLetter>false</sendAttackLetter>
<customLetterLabel>战舰炮击警告</customLetterLabel>
<customLetterText>一艘敌方战舰正在对殖民地进行炮击!立即寻找掩护!</customLetterText>
@@ -262,39 +262,39 @@
<!-- 伴飞 -->
<li Class="ArachnaeSwarm.CompProperties_FlyOverEscort">
<escortFlyOverDef>ARA_HiveCorvette_Fake</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>250</spawnIntervalTicks> <!-- 5秒 -->
<spawnIntervalTicks>250</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>30</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>100</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<minSafeDistanceBetweenEscorts>10</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>70</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>20</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<escortSpeedMultiplier>20</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>1.2</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
@@ -307,39 +307,39 @@
<!-- 伴飞 -->
<li Class="ArachnaeSwarm.CompProperties_FlyOverEscort">
<escortFlyOverDef>ARA_HiveShip_Fake</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>3000</spawnIntervalTicks> <!-- 5秒 -->
<spawnIntervalTicks>3000</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>3</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>20</spawnDistance>
<lateralOffset>380</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<minSafeDistanceBetweenEscorts>25</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>100</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<minSafeDistanceBetweenEscorts>25</minSafeDistanceBetweenEscorts> <!-- 伴飞物之间的距离 -->
<minSafeDistanceFromMain>100</minSafeDistanceFromMain> <!-- 与主飞行物的距离检查 -->
<!-- 飞行配置 -->
<escortSpeedMultiplier>1</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<escortSpeedMultiplier>1</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<mirrorMovement>false</mirrorMovement>
<!-- 行为配置 -->
<spawnOnStart>true</spawnOnStart>
<destroyWithParent>true</destroyWithParent>
<continuousSpawning>true</continuousSpawning>
<!-- 外观配置 -->
<useParentRotation>true</useParentRotation>
<!-- 缩放区间配置 -->
<escortScaleRange>
<min>0.3</min>
<max>0.5</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
@@ -350,7 +350,7 @@
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
</comps>
</ThingDef>
</ThingDef>
<ThingDef Parent="EtherealThingBase">
<defName>ARA_HiveShip_Fake</defName>
<label>虫巢母舰</label>
@@ -392,37 +392,37 @@
<!-- 伴飞 -->
<li Class="ArachnaeSwarm.CompProperties_FlyOverEscort">
<escortFlyOverDef>ARA_HiveCorvette_Fake</escortFlyOverDef>
<!-- 生成配置 -->
<spawnIntervalTicks>250</spawnIntervalTicks> <!-- 5秒 -->
<spawnIntervalTicks>250</spawnIntervalTicks> <!-- 5秒 -->
<maxEscorts>5</maxEscorts>
<spawnCount>1</spawnCount>
<!-- 位置配置 -->
<spawnDistance>0</spawnDistance>
<lateralOffset>50</lateralOffset>
<verticalOffset>5</verticalOffset>
<useRandomOffset>true</useRandomOffset>
<!-- 飞行配置 -->
<escortSpeedMultiplier>20</escortSpeedMultiplier> <!-- 比主舰稍快 -->
<escortAltitudeOffset>10</escortAltitudeOffset> <!-- 比主舰稍高 -->
<escortSpeedMultiplier>20</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>1.2</max>
</escortScaleRange>
<!-- 高度遮罩配置 -->
<useHeightMask>true</useHeightMask>
<heightMaskAlphaRange>
@@ -433,7 +433,7 @@
<heightMaskScaleMultiplier>1.3</heightMaskScaleMultiplier>
</li>
</comps>
</ThingDef>
</ThingDef>
<ThingDef Parent="EtherealThingBase">
<defName>ARA_HiveCorvette_Fake</defName>
<label>天妖种兽虫</label>
@@ -519,14 +519,14 @@
<li Class="ArachnaeSwarm.CompProperties_GroundStrafing">
<projectileDef>Proj_ARA_HiveCorvette</projectileDef>
<range>50</range>
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>13</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>13</longitudinalInitialOffset>
<longitudinalMinOffset>13</longitudinalMinOffset>
@@ -539,19 +539,19 @@
</li>
<li Class="ArachnaeSwarm.CompProperties_SectorSurveillance">
<projectileDef>Bullet_ARA_HiveCorvette</projectileDef>
<sectorAngle>30</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>3</shotCount> <!-- 发射次数 -->
<shotInterval>0.3</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>24</maxProjectiles><!-- 最大射弹数量限制-->
<sectorAngle>30</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>3</shotCount> <!-- 发射次数 -->
<shotInterval>0.3</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>24</maxProjectiles> <!-- 最大射弹数量限制-->
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>13</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>13</longitudinalInitialOffset>
<longitudinalMinOffset>13</longitudinalMinOffset>
@@ -607,14 +607,14 @@
<li Class="ArachnaeSwarm.CompProperties_GroundStrafing">
<projectileDef>Projectile_CatastropheMissile</projectileDef>
<range>50</range>
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>13</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>13</longitudinalInitialOffset>
<longitudinalMinOffset>13</longitudinalMinOffset>
@@ -668,16 +668,16 @@
<altitudeLayer>MetaOverlays</altitudeLayer>
<comps>
<li Class="ArachnaeSwarm.CompProperties_GroundStrafing">
<projectileDef>Bullet_ARA_RW_Acid_Mortar</projectileDef>
<projectileDef>Bullet_ARA_Acid_Bombardment</projectileDef>
<range>15</range>
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>11</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>11</longitudinalInitialOffset>
<longitudinalMinOffset>3</longitudinalMinOffset>
@@ -690,19 +690,19 @@
</li>
<li Class="ArachnaeSwarm.CompProperties_SectorSurveillance">
<projectileDef>Bullet_ARA_HiveCorvette</projectileDef>
<sectorAngle>60</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>1</shotCount> <!-- 发射次数 -->
<shotInterval>0.5</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>-1</maxProjectiles><!-- 最大射弹数量限制-->
<sectorAngle>60</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>1</shotCount> <!-- 发射次数 -->
<shotInterval>0.5</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>-1</maxProjectiles> <!-- 最大射弹数量限制-->
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>13</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>13</longitudinalInitialOffset>
<longitudinalMinOffset>13</longitudinalMinOffset>
@@ -715,6 +715,43 @@
</li>
</comps>
</ThingDef>
<ThingDef ParentName="BaseBullet">
<defName>Bullet_ARA_Acid_Bombardment</defName>
<label>大型酸液团</label>
<graphicData>
<graphicClass>Graphic_Single_AgeSecs</graphicClass>
<texPath>Things/Projectile/FleshmassSpitterProjectileSheet</texPath>
<drawSize>(.75, .75)</drawSize>
<shaderType>MoteGlow</shaderType>
</graphicData>
<uiIconScale>0.8</uiIconScale>
<thingClass>Projectile_Explosive</thingClass>
<projectile>
<useGraphicClass>True</useGraphicClass>
<shadowSize>1</shadowSize>
<damageDef>ARA_AcidBurn</damageDef>
<spinRate>15</spinRate>
<damageAmountBase>10</damageAmountBase>
<speed>30</speed>
<arcHeightFactor>1</arcHeightFactor>
<explosionRadius>3.5</explosionRadius>
<flyOverhead>true</flyOverhead>
<soundExplode>ThumpCannon_Impact</soundExplode>
<filth>ARA_Filth_SpentAcid</filth>
<filthCount>2</filthCount>
<explosionEffect>Shell_AcidSpitImpact</explosionEffect>
<explosionEffectLifetimeTicks>60</explosionEffectLifetimeTicks>
<doExplosionVFX>false</doExplosionVFX>
</projectile>
<comps>
<li Class="CompProperties_ProjectileEffecter">
<effecterDef>Shell_AcidSpitStream</effecterDef>
</li>
<li Class="CompProperties_ProjectileEffecter">
<effecterDef>Shell_AcidSpitLaunched</effecterDef>
</li>
</comps>
</ThingDef>
<ThingDef Parent="EtherealThingBase">
<defName>ARA_HiveCorvette_Strike</defName>
<label>天巫种兽虫(棘刺扫射)</label>
@@ -757,19 +794,19 @@
<comps>
<li Class="ArachnaeSwarm.CompProperties_SectorSurveillance">
<projectileDef>Bullet_ARA_HiveCorvette</projectileDef>
<sectorAngle>30</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>10</shotCount> <!-- 发射次数 -->
<shotInterval>0.5</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>-1</maxProjectiles><!-- 最大射弹数量限制-->
<sectorAngle>30</sectorAngle> <!-- 扇形角度 -->
<sectorRange>50</sectorRange> <!-- 射程 -->
<shotCount>10</shotCount> <!-- 发射次数 -->
<shotInterval>0.5</shotInterval> <!-- 发射间隔 -->
<maxProjectiles>-1</maxProjectiles> <!-- 最大射弹数量限制-->
<!-- 横向偏移配置(左右) -->
<lateralOffsetDistance>13</lateralOffsetDistance>
<lateralInitialOffsetAngle>0</lateralInitialOffsetAngle>
<lateralMaxOffsetAngle>0</lateralMaxOffsetAngle>
<lateralAngleIncrement>0</lateralAngleIncrement>
<lateralOffsetMode>Alternating</lateralOffsetMode>
<!-- 纵向偏移配置(前后) -->
<longitudinalInitialOffset>13</longitudinalInitialOffset>
<longitudinalMinOffset>13</longitudinalMinOffset>

View File

@@ -696,6 +696,83 @@
</comps>
</ThingDef>
<ThingDef ParentName="ARA_ClothBase">
<defName>ARA_Eveningdress</defName>
<label>阿拉克涅晚礼服</label>
<description>阿拉克涅督虫们所着织物中的一种,高贵又富有魅力,蕴含着强大的灵能力量,这件织物能够增幅穿着者的灵能力量。</description>
<descriptionHyperlinks>
<ThingDef>ARA_Cocoon_Cloth_1Stage</ThingDef>
<AbilityDef>ARA_TerrainHeal_Ability</AbilityDef>
</descriptionHyperlinks>
<recipeMaker>
<recipeUsers Inherit="False" />
<researchPrerequisite>ARA_Technology_5DIL</researchPrerequisite>
<unfinishedThingDef>UnfinishedArmor</unfinishedThingDef>
</recipeMaker>
<costList Inherit="False">
<ARA_Carapace>25</ARA_Carapace>
</costList>
<statBases>
<ARA_IncubationCost>50</ARA_IncubationCost>
<ARA_IncubationTime>3</ARA_IncubationTime>
</statBases>
<graphicData>
<texPath>ArachnaeSwarm/Apparel/ARA_Evening_Dress_Thin_south</texPath>
</graphicData>
<apparel>
<bodyPartGroups>
<li>Torso</li>
<li>Shoulders</li>
<li>Arms</li>
<li>Legs</li>
</bodyPartGroups>
<layers>
<!-- <li>OnSkin</li> -->
<li>Middle</li>
</layers>
<wornGraphicPath>ArachnaeSwarm/Apparel/ARA_Evening_Dress</wornGraphicPath>
</apparel>
<equippedStatOffsets>
</equippedStatOffsets>
<costStuffCount>0</costStuffCount>
<comps>
<li Class="ArachnaeSwarm.CompProperties_ExtraIncubationInfo">
<cocoonDefs>
<li>ARA_Cocoon_Cloth_1Stage</li>
<li>ARA_Cocoon_Cloth_1Stage_From_Death</li>
<li>ARA_BioforgeIncubator_Thing</li>
</cocoonDefs>
</li>
<li Class="ArachnaeSwarm.CompProperties_ApparelInterceptor">
<!-- 基础功能 -->
<radius>3</radius> <!-- 护盾半径,决定了拦截范围 -->
<hitPoints>1000</hitPoints> <!-- 护盾的生命值,每次拦截会消耗 -->
<rechargeDelay>2800</rechargeDelay> <!-- 护盾破裂后的冷却时间 (ticks) -->
<!-- 拦截类型 -->
<interceptGroundProjectiles>true</interceptGroundProjectiles> <!-- 是否拦截地面弹丸 (如子弹) -->
<interceptAirProjectiles>false</interceptAirProjectiles> <!-- 是否拦截空中弹丸 (如炮弹) -->
<interceptNonHostileProjectiles>true</interceptNonHostileProjectiles> <!-- 是否拦截非敌对弹丸 -->
<!-- 视觉与音效 -->
<color>(0.5, 0.3, 0.9, 0.5)</color> <!-- 护盾气泡的颜色 (RGBA) -->
<soundInterceptEffecter>Interceptor_BlockedProjectile</soundInterceptEffecter> <!-- 成功拦截时的音效 -->
<soundBreakEffecter>Shield_Break</soundBreakEffecter> <!-- 护盾破裂时的音效 -->
<reactivateEffect>BulletShieldGenerator_Reactivate</reactivateEffect> <!-- 护盾冷却结束后恢复的特效 -->
<!-- EMP 效果 -->
<isImmuneToEMP>true</isImmuneToEMP> <!-- 是否免疫EMP伤害 -->
<disarmedByEmpForTicks>0</disarmedByEmpForTicks> <!-- 被EMP击中后额外的眩晕/瘫痪时间 (ticks) -->
<!-- 被动恢复 -->
<rechargeHitPointsIntervalTicks>1</rechargeHitPointsIntervalTicks> <!-- 未破盾时每隔多少ticks恢复1点生命值 -->
</li>
</comps>
</ThingDef>
<ApparelLayerDef>
<defName>ARA_Shield</defName>
<label>盾牌和共生肌群</label>

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@@ -258,6 +258,7 @@
<Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompExtraIncubationInfo.cs" />
<Compile Include="Thing_Comps\ARA_CompExtraIncubationInfo\CompProperties_ExtraIncubationInfo.cs" />
<Compile Include="Thing_Comps\CompAndPatch_GiveHediffOnShot.cs" />
<Compile Include="Thing_Comps\CompApparelInterceptor.cs" />
<Compile Include="Pawn_Comps\ARA_AutoMechCarrier\CompAutoMechCarrier.cs" />
<Compile Include="Pawn_Comps\ARA_AutoMechCarrier\CompProperties_AutoMechCarrier.cs" />
<Compile Include="Pawn_Comps\ARA_AutoMechCarrier\PawnProductionEntry.cs" />

View File

@@ -0,0 +1,357 @@
using HarmonyLib;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using Verse;
using Verse.Sound;
namespace ArachnaeSwarm
{
public class CompProperties_ApparelInterceptor : CompProperties
{
public float radius = 3f;
public int startupDelay = 0;
public int rechargeDelay = 3200;
public int hitPoints = 100;
public bool interceptGroundProjectiles = false;
public bool interceptNonHostileProjectiles = false;
public bool interceptAirProjectiles = true;
public EffecterDef soundInterceptEffecter;
public EffecterDef soundBreakEffecter;
public EffecterDef reactivateEffect;
public Color color = new Color(0.5f, 0.5f, 0.9f);
public bool drawWithNoSelection = true;
public bool isImmuneToEMP = false;
public int cooldownTicks = 0;
public int chargeDurationTicks = 0;
public int chargeIntervalTicks = 0;
public bool startWithMaxHitPoints = true;
public bool hitPointsRestoreInstantlyAfterCharge = true;
public int rechargeHitPointsIntervalTicks = 60;
public bool activated = false;
public int activeDuration = 0;
public SoundDef activeSound;
public bool alwaysShowHitpointsGizmo = false;
public float minAlpha = 0f;
public float idlePulseSpeed = 0.02f;
public float minIdleAlpha = 0.05f;
public int disarmedByEmpForTicks = 0;
public CompProperties_ApparelInterceptor()
{
compClass = typeof(CompApparelInterceptor);
}
}
[StaticConstructorOnStartup]
public class CompApparelInterceptor : ThingComp
{
// 状态变量
private int lastInterceptTicks = -999999;
private int startedChargingTick = -1;
private bool shutDown;
private StunHandler stunner;
private Sustainer sustainer;
public int currentHitPoints = -1;
private int ticksToReset;
private int activatedTick = -999999;
// 视觉效果变量
private float lastInterceptAngle;
private bool drawInterceptCone;
// 静态资源
private static readonly Material ForceFieldMat = MaterialPool.MatFrom("Other/ForceField", ShaderDatabase.MoteGlow);
private static readonly Material ForceFieldConeMat = MaterialPool.MatFrom("Other/ForceFieldCone", ShaderDatabase.MoteGlow);
private static readonly MaterialPropertyBlock MatPropertyBlock = new MaterialPropertyBlock();
private static readonly Color InactiveColor = new Color(0.2f, 0.2f, 0.2f);
// 属性
public CompProperties_ApparelInterceptor Props => (CompProperties_ApparelInterceptor)props;
private Pawn PawnOwner => (parent as Apparel)?.Wearer;
public bool Active
{
get
{
if (PawnOwner == null || !PawnOwner.Spawned) return false;
if (OnCooldown || Charging || stunner.Stunned || shutDown || currentHitPoints <= 0) return false;
if (Props.activated && Find.TickManager.TicksGame > activatedTick + Props.activeDuration) return false;
return true;
}
}
protected bool ShouldDisplay
{
get
{
if (PawnOwner == null || !PawnOwner.Spawned || PawnOwner.Dead || PawnOwner.Downed || !Active)
{
return false;
}
if (PawnOwner.Drafted || PawnOwner.InAggroMentalState || (PawnOwner.Faction != null && PawnOwner.Faction.HostileTo(Faction.OfPlayer) && !PawnOwner.IsPrisoner))
{
return true;
}
if (Find.Selector.IsSelected(PawnOwner))
{
return true;
}
return false;
}
}
public bool OnCooldown => ticksToReset > 0;
public bool Charging => startedChargingTick >= 0 && Find.TickManager.TicksGame < startedChargingTick + Props.startupDelay;
public int CooldownTicksLeft => ticksToReset;
public int ChargingTicksLeft => (startedChargingTick < 0) ? 0 : Mathf.Max(startedChargingTick + Props.startupDelay - Find.TickManager.TicksGame, 0);
public int HitPointsMax => Props.hitPoints;
protected virtual int HitPointsPerInterval => 1;
public override void PostPostMake()
{
base.PostPostMake();
stunner = new StunHandler(parent);
if (Props.startupDelay > 0)
{
startedChargingTick = Find.TickManager.TicksGame;
currentHitPoints = 0;
}
else
{
currentHitPoints = HitPointsMax;
}
}
public override void PostExposeData()
{
base.PostExposeData();
Scribe_Values.Look(ref lastInterceptTicks, "lastInterceptTicks", -999999);
Scribe_Values.Look(ref shutDown, "shutDown", defaultValue: false);
Scribe_Values.Look(ref startedChargingTick, "startedChargingTick", -1);
Scribe_Values.Look(ref currentHitPoints, "currentHitPoints", -1);
Scribe_Values.Look(ref ticksToReset, "ticksToReset", 0);
Scribe_Values.Look(ref activatedTick, "activatedTick", -999999);
Scribe_Deep.Look(ref stunner, "stunner", parent);
if (Scribe.mode == LoadSaveMode.PostLoadInit)
{
if (stunner == null) stunner = new StunHandler(parent);
if (currentHitPoints == -1) currentHitPoints = HitPointsMax;
}
}
public bool TryIntercept(Projectile projectile, Vector3 lastExactPos, Vector3 newExactPos)
{
if (PawnOwner == null || !PawnOwner.Spawned || !Active)
{
return false;
}
if (!GenGeo.IntersectLineCircleOutline(PawnOwner.Position.ToVector2(), Props.radius, lastExactPos.ToVector2(), newExactPos.ToVector2()))
{
return false;
}
if (!InterceptsProjectile(Props, projectile))
{
return false;
}
bool isHostile = (projectile.Launcher != null && projectile.Launcher.HostileTo(PawnOwner)) || (projectile.Launcher == null && Props.interceptNonHostileProjectiles);
if (!isHostile)
{
return false;
}
// --- Interception Success ---
lastInterceptAngle = projectile.ExactPosition.AngleToFlat(PawnOwner.TrueCenter());
lastInterceptTicks = Find.TickManager.TicksGame;
drawInterceptCone = true;
if (Props.soundInterceptEffecter != null) Props.soundInterceptEffecter.Spawn(PawnOwner.Position, PawnOwner.Map).Cleanup();
if (projectile.DamageDef == DamageDefOf.EMP && !Props.isImmuneToEMP)
{
BreakShieldEmp(new DamageInfo(projectile.DamageDef, projectile.DamageAmount, instigator: projectile.Launcher));
}
else if (HitPointsMax > 0)
{
currentHitPoints -= projectile.DamageAmount;
if (currentHitPoints <= 0)
{
BreakShieldHitpoints(new DamageInfo(projectile.DamageDef, projectile.DamageAmount, instigator: projectile.Launcher));
}
}
return true;
}
public override void CompTick()
{
base.CompTick();
if (PawnOwner == null || !PawnOwner.Spawned) return;
stunner.StunHandlerTick();
if (OnCooldown)
{
ticksToReset--;
if (ticksToReset <= 0) Reset();
}
else if (Charging)
{
// Charging logic handled by property
}
else if (currentHitPoints < HitPointsMax && parent.IsHashIntervalTick(Props.rechargeHitPointsIntervalTicks))
{
currentHitPoints = Mathf.Clamp(currentHitPoints + HitPointsPerInterval, 0, HitPointsMax);
}
if (Props.activeSound != null)
{
if (Active && (sustainer == null || sustainer.Ended)) sustainer = Props.activeSound.TrySpawnSustainer(SoundInfo.InMap(parent));
sustainer?.Maintain();
if (!Active && sustainer != null && !sustainer.Ended) sustainer.End();
}
}
public void Reset()
{
if (PawnOwner.Spawned) Props.reactivateEffect?.Spawn(PawnOwner.Position, PawnOwner.Map).Cleanup();
currentHitPoints = HitPointsMax;
ticksToReset = 0;
}
private void BreakShieldHitpoints(DamageInfo dinfo)
{
if (PawnOwner.Spawned)
{
if (Props.soundBreakEffecter != null) Props.soundBreakEffecter.SpawnAttached(PawnOwner, PawnOwner.MapHeld, Props.radius).Cleanup();
}
currentHitPoints = 0;
ticksToReset = Props.rechargeDelay;
}
private void BreakShieldEmp(DamageInfo dinfo)
{
BreakShieldHitpoints(dinfo);
if (Props.disarmedByEmpForTicks > 0) stunner.Notify_DamageApplied(new DamageInfo(DamageDefOf.EMP, (float)Props.disarmedByEmpForTicks / 30f));
}
public static bool InterceptsProjectile(CompProperties_ApparelInterceptor props, Projectile projectile)
{
if (projectile.def.projectile.flyOverhead) return props.interceptAirProjectiles;
return props.interceptGroundProjectiles;
}
// --- DRAWING LOGIC ---
public override void CompDrawWornExtras()
{
base.CompDrawWornExtras();
if (PawnOwner == null || !PawnOwner.Spawned || !ShouldDisplay) return;
Vector3 drawPos = PawnOwner.Drawer.DrawPos;
drawPos.y = AltitudeLayer.MoteOverhead.AltitudeFor();
float alpha = GetCurrentAlpha();
if (alpha > 0f)
{
Color color = Props.color;
color.a *= alpha;
MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
Matrix4x4 matrix = default(Matrix4x4);
matrix.SetTRS(drawPos, Quaternion.identity, new Vector3(Props.radius * 2f * 1.1601562f, 1f, Props.radius * 2f * 1.1601562f));
Graphics.DrawMesh(MeshPool.plane10, matrix, ForceFieldMat, 0, null, 0, MatPropertyBlock);
}
float coneAlpha = GetCurrentConeAlpha_RecentlyIntercepted();
if (coneAlpha > 0f)
{
Color color = Props.color;
color.a *= coneAlpha;
MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
Matrix4x4 matrix = default(Matrix4x4);
matrix.SetTRS(drawPos, Quaternion.Euler(0f, lastInterceptAngle - 90f, 0f), new Vector3(Props.radius * 2f, 1f, Props.radius * 2f));
Graphics.DrawMesh(MeshPool.plane10, matrix, ForceFieldConeMat, 0, null, 0, MatPropertyBlock);
}
}
private float GetCurrentAlpha()
{
float idleAlpha = Mathf.Lerp(0.3f, 0.6f, (Mathf.Sin((float)Gen.HashCombineInt(parent.thingIDNumber, 35990913) + Time.realtimeSinceStartup * 2f) + 1f) / 2f);
float interceptAlpha = Mathf.Clamp01(1f - (float)(Find.TickManager.TicksGame - lastInterceptTicks) / 40f);
return Mathf.Max(idleAlpha, interceptAlpha);
}
private float GetCurrentConeAlpha_RecentlyIntercepted()
{
if (!drawInterceptCone) return 0f;
return Mathf.Clamp01(1f - (float)(Find.TickManager.TicksGame - lastInterceptTicks) / 40f) * 0.82f;
}
// --- GIZMO ---
public override IEnumerable<Gizmo> CompGetWornGizmosExtra()
{
if (PawnOwner != null && Find.Selector.SingleSelectedThing == PawnOwner)
{
yield return new Gizmo_EnergyShieldStatus { shield = this };
}
}
public override string CompInspectStringExtra()
{
StringBuilder sb = new StringBuilder();
if (OnCooldown)
{
sb.Append("Cooldown: " + CooldownTicksLeft.ToStringTicksToPeriod());
}
else if (stunner.Stunned)
{
sb.Append("EMP Shutdown: " + stunner.StunTicksLeft.ToStringTicksToPeriod());
}
return sb.ToString();
}
}
[StaticConstructorOnStartup]
public class Gizmo_EnergyShieldStatus : Gizmo
{
public CompApparelInterceptor shield;
private static readonly Texture2D FullShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.8f, 0.85f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D;
private static readonly Texture2D EmptyShieldBarTex = SolidColorMaterials.NewSolidColorMaterial(new Color(0.2f, 0.2f, 0.24f), ShaderDatabase.MetaOverlay).mainTexture as Texture2D;
public override float GetWidth(float maxWidth) => 140f;
public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
{
Rect rect = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
Rect rect2 = rect.ContractedBy(6f);
Widgets.DrawWindowBackground(rect);
Rect labelRect = rect2;
labelRect.height = rect.height / 2f;
Text.Font = GameFont.Tiny;
Widgets.Label(labelRect, shield.parent.LabelCap);
Rect barRect = rect2;
barRect.yMin = rect2.y + rect2.height / 2f;
float fillPercent = (float)shield.currentHitPoints / shield.HitPointsMax;
Widgets.FillableBar(barRect, fillPercent, FullShieldBarTex, EmptyShieldBarTex, false);
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleCenter;
TaggedString statusText = shield.OnCooldown ? "Broken".Translate() : new TaggedString(shield.currentHitPoints + " / " + shield.HitPointsMax);
Widgets.Label(barRect, statusText);
Text.Anchor = TextAnchor.UpperLeft;
return new GizmoResult(GizmoState.Clear);
}
}
}