This commit is contained in:
Tourswen
2025-12-02 21:13:08 +08:00
parent e10fc59204
commit 1d1ac76524
9 changed files with 147 additions and 51 deletions

View File

@@ -5,7 +5,7 @@
<defName>Wula_Sonar_Mine_Cleanzone</defName>
<label>TAm-1"鹅卵石"感应地雷</label>
<description>清理出一块场地并准备好资源,使得乌拉帝国可以向此处投放建筑,建造好的信标可以收起或移至他处。\n\nTAm-1"鹅卵石"感应地雷是一种危险的地雷,它们通常由乌拉帝国的工程部队部署到战场上,拥有智能敌我识别能力,在检测到敌军活动时会将自身的战斗部直接向敌人的位置发射。</description>
<uiIconPath>Wula/Building/Wula_Base_ATGun_Turret</uiIconPath>
<uiIconPath>Wula/Building/Wula_Sonar_Mine</uiIconPath>
<minifiedDef>MinifiedThing</minifiedDef>
<tickerType>Normal</tickerType>
<tradeability>None</tradeability>
@@ -33,7 +33,7 @@
<rotatable>false</rotatable>
<terrainAffordanceNeeded>Light</terrainAffordanceNeeded>
<researchPrerequisites Inherit="False">
<li>WULA_Turret_Base_AT_Technology</li>
<li>WULA_Bunker_Drop_Technology</li>
</researchPrerequisites>
<statBases>
<MarketValue>0</MarketValue>
@@ -46,7 +46,7 @@
<constructionSkillPrerequisite>0</constructionSkillPrerequisite>
<resourcesFractionWhenDeconstructed>0</resourcesFractionWhenDeconstructed>
<costList Inherit="False">
<WULA_Alloy>2</WULA_Alloy>
<WULA_Alloy>1</WULA_Alloy>
<Chemfuel>5</Chemfuel>
</costList>
<building>
@@ -80,7 +80,7 @@
<label>TAm-1"鹅卵石"感应地雷</label>
<size>(1,1)</size>
<graphicData>
<texPath>Wula/Building/Wula_Base_ATGun_Turret_Incoming</texPath>
<texPath>Wula/Building/Wula_Sonar_Mine_Incoming</texPath>
<graphicClass>Graphic_Single</graphicClass>
<shaderType>CutoutFlying</shaderType>
<drawSize>(1,1)</drawSize>
@@ -109,17 +109,19 @@
</li>
</comps>
</ThingDef>
<ThingDef ParentName="BuildingBase">
<ThingDef ParentName="BuildingBase">
<defName>Wula_Sonar_Mine</defName>
<label>TAm-1"鹅卵石"感应地雷</label>
<description>一种危险的地雷,它们通常由乌拉帝国的工程部队部署到战场上,拥有智能敌我识别能力,在检测到敌军活动时会将自身的战斗部直接向敌人的位置发射。</description>
<graphicData>
<graphicClass>Graphic_Single</graphicClass>
<texPath>Wula/Building/Wula_Sonar_Mine</texPath>
<graphicClass>Graphic_Multi</graphicClass>
<drawSize>(1,1)</drawSize>
<damageData>
<rect>(0.1,0,0.8,0.3)</rect>
<enabled>false</enabled>
</damageData>
</graphicData>
<uiIconOffset>(0,-0.14)</uiIconOffset>
<uiIconOffset>(0,0)</uiIconOffset>
<altitudeLayer>Building</altitudeLayer>
<rotatable>false</rotatable>
<tickerType>Normal</tickerType>
@@ -128,7 +130,7 @@
<size>(1,1)</size>
<leaveResourcesWhenKilled>false</leaveResourcesWhenKilled>
<costList Inherit="False">
<WULA_Alloy>2</WULA_Alloy>
<WULA_Alloy>1</WULA_Alloy>
<Chemfuel>5</Chemfuel>
</costList>
<uiOrder>40</uiOrder>
@@ -153,6 +155,22 @@
<li>PlaceWorker_NeverAdjacentTrap</li>
</placeWorkers>
<comps>
<li Class="CompProperties_Stunnable">
<affectedDamageDefs>
<li>Stun</li>
<li>EMP</li>
</affectedDamageDefs>
<adaptableDamageDefs>
<li>EMP</li>
</adaptableDamageDefs>
</li>
<!-- 特殊组件放在setter前可以无视setter设置眩晕炮塔 -->
<li Class="WulaFallenEmpire.CompProperties_DelayedDamageIfNotPlayer">
<damageDef>EMP</damageDef>
<damageAmount>10</damageAmount>
<armorPenetration>2</armorPenetration>
<destroyIfKilled>true</destroyIfKilled>
</li>
<li Class="CompProperties_Explosive">
<explosiveRadius>3.9</explosiveRadius>
<explosiveDamageType>Bomb</explosiveDamageType>
@@ -168,7 +186,7 @@
<li Class="WulaFallenEmpire.CompProperties_TrapLauncher">
<detectionRadius>15</detectionRadius> <!-- 检测半径,单位:格 -->
<scanIntervalTicks>60</scanIntervalTicks> <!-- 扫描间隔 -->
<projectileDef>Bullet_Wula_AI_Heavy_Panzer_Main_Weapon</projectileDef> <!-- 抛射体类型 -->
<projectileDef>Proj_Wula_Sonar_Mine</projectileDef> <!-- 抛射体类型 -->
<requireLineOfSight>false</requireLineOfSight> <!-- 需要视线 -->
<showDetectionRadius>true</showDetectionRadius> <!-- 显示检测范围 -->
<burstCount>1</burstCount> <!-- 单次发射数量 -->
@@ -184,8 +202,55 @@
<usePlayerFactionIfNull>true</usePlayerFactionIfNull>
<overrideExistingFaction>false</overrideExistingFaction>
</li>
<li Class="CompProperties_Glower">
<glowRadius>2</glowRadius>
<glowColor>(120,240,252,0)</glowColor>
</li>
</comps>
</ThingDef>
<ThingDef ParentName="BaseBullet">
<defName>Proj_Wula_Sonar_Mine</defName>
<label>TAm-1"鹅卵石"感应地雷</label>
<drawerType>RealtimeOnly</drawerType>
<graphicData>
<texPath>Wula/Projectile/WULA_Shrapnel</texPath>
<graphicClass>Graphic_Single</graphicClass>
<drawSize>(1,1)</drawSize>
</graphicData>
<thingClass>WulaFallenEmpire.Projectile_NorthArcTrail</thingClass>
<tickerType>Normal</tickerType>
<neverMultiSelect>True</neverMultiSelect>
<projectile>
<damageDef>Bomb</damageDef>
<damageAmountBase>60</damageAmountBase>
<speed>25</speed>
<explosionRadius>5</explosionRadius>
<armorPenetrationBase>2</armorPenetrationBase>
<flyOverhead>true</flyOverhead>
<soundHitThickRoof>Artillery_HitThickRoof</soundHitThickRoof>
<soundExplode>MortarBomb_Explode</soundExplode>
<soundImpactAnticipate>MortarRound_PreImpact</soundImpactAnticipate>
<soundAmbient>MortarRound_Ambient</soundAmbient>
<stoppingPower>10</stoppingPower>
<preExplosionSpawnSingleThingDef>Filth_BlastMark</preExplosionSpawnSingleThingDef>
</projectile>
<modExtensions>
<li Class="WulaFallenEmpire.NorthArcModExtension">
<northOffsetDistance>5</northOffsetDistance>
<curveSteepness>1.0</curveSteepness>
<useArcTrajectory>true</useArcTrajectory>
</li>
<li Class="WulaFallenEmpire.TrackingBulletDef">
<tailFleckDef>WULA_Smoke_Tail</tailFleckDef>
<fleckMakeFleckTickMax>5</fleckMakeFleckTickMax>
<fleckDelayTicks>1</fleckDelayTicks>
<fleckMakeFleckNum>1~2</fleckMakeFleckNum>
<fleckScale>0.5~1.0</fleckScale>
<fleckSpeed>0.1~0.3</fleckSpeed>
<fleckAngle>-30~30</fleckAngle>
</li>
</modExtensions>
</ThingDef>
<!-- 猫猫地堡 -->
<ThingDef ParentName="BuildingBase">

View File

@@ -414,4 +414,9 @@
<WULA_TransferError>取出白银时发生错误</WULA_TransferError>
<WULA_TrapLauncherTriggered>感应地雷已启动!</WULA_TrapLauncherTriggered>
<WULA_Designator_CallSkyfallerInArea>区域空投</WULA_Designator_CallSkyfallerInArea>
<WULA_Designator_CallSkyfallerInAreaDesc>标记一块区域,激活其中所有需要空投的乌拉帝国建筑和战争机械体。\n\n区域空投依然需要计算材料消耗如果材料不足则不会进行空投。</WULA_Designator_CallSkyfallerInAreaDesc>
<WULA_AreaCallInitiated>区域空投已下达</WULA_AreaCallInitiated>
<WULA_NoCallableBuildingsInArea>区域内没有可接受空投质量的乌拉帝国空投区</WULA_NoCallableBuildingsInArea>
</LanguageData>

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -4,7 +4,6 @@ using System.Linq;
using UnityEngine;
using Verse;
using Verse.Sound;
using static UnityEngine.GraphicsBuffer;
namespace WulaFallenEmpire
{
@@ -43,6 +42,19 @@ namespace WulaFallenEmpire
if (!parent.Spawned || hasTriggered)
return;
// 检查是否处于眩晕状态
if (IsStunned())
{
// 眩晕状态下暂停所有活动
if (isWarmingUp)
{
// 如果正在预热,暂停预热
// 不清除预热计数,恢复时会继续
Log.Message($"[CompTrapLauncher] {parent.Label} is stunned, pausing warmup");
}
return;
}
// 预热计数
if (isWarmingUp)
@@ -64,6 +76,20 @@ namespace WulaFallenEmpire
}
}
/// <summary>
/// 检查是否处于眩晕状态
/// </summary>
private bool IsStunned()
{
// 尝试获取CompStunnable组件
var stunComp = parent.GetComp<CompStunnable>();
if (stunComp != null && stunComp.StunHandler != null)
{
return stunComp.StunHandler.Stunned;
}
return false;
}
/// <summary>
/// 扫描范围内的敌对目标
/// </summary>
@@ -140,9 +166,6 @@ namespace WulaFallenEmpire
}
}
// 检查是否为机械体(如果设定)
// 这里可以根据需要添加更多过滤条件
return true;
}
@@ -225,12 +248,12 @@ namespace WulaFallenEmpire
// 发射
projectile.Launch(parent, parent.DrawPos, currentTarget, currentTarget, ProjectileHitFlags.IntendedTarget, false);
// 连发延迟
burstCounter++;
// 连发延迟(简化实现)
if (i < Props.burstCount - 1 && Props.burstDelay > 0)
{
// 使用简单的延迟实现
// 在实际游戏中,可能需要更复杂的实现
// 这里我们简化处理
// 在实际游戏中可能需要更复杂的实现
}
}
@@ -362,9 +385,13 @@ namespace WulaFallenEmpire
if (!hasTriggered && DebugSettings.ShowDevGizmos)
{
// 检查眩晕状态显示
bool isStunned = IsStunned();
// 调试:手动触发
Command_Action debugTrigger = new Command_Action();
debugTrigger.defaultLabel = "DEV: Trigger Trap";
debugTrigger.defaultLabel = $"DEV: Trigger Trap (Stunned: {isStunned})";
debugTrigger.disabledReason = "Cannot trigger while stunned";
debugTrigger.action = delegate
{
currentTarget = FindClosestHostilePawn();
@@ -388,6 +415,16 @@ namespace WulaFallenEmpire
SelfDestruct();
};
yield return debugDestruct;
// 调试:显示眩晕状态
Command_Action debugStunStatus = new Command_Action();
debugStunStatus.defaultLabel = $"DEV: Stun Status - {(isStunned ? "STUNNED" : "ACTIVE")}";
debugStunStatus.action = delegate
{
Messages.Message($"Trap Launcher Stun Status: {(isStunned ? "Stunned - Scanning Paused" : "Active - Scanning Normally")}",
parent, MessageTypeDefOf.NeutralEvent);
};
yield return debugStunStatus;
}
}
@@ -458,5 +495,25 @@ namespace WulaFallenEmpire
}
}
}
/// <summary>
/// 在检视字符串中添加眩晕状态信息
/// </summary>
public override string CompInspectStringExtra()
{
string baseString = base.CompInspectStringExtra();
if (IsStunned())
{
string stunInfo = "WULA_TrapLauncherStunned".Translate();
if (!string.IsNullOrEmpty(baseString))
{
return baseString + "\n" + stunInfo;
}
return stunInfo;
}
return baseString;
}
}
}

View File

@@ -8,8 +8,6 @@ namespace WulaFallenEmpire
{
public class Designator_CallSkyfallerInArea : Designator
{
private readonly new Texture2D icon;
// 记录已经处理过的建筑(避免重复)
private HashSet<Thing> processedBuildings = new HashSet<Thing>();
@@ -17,7 +15,7 @@ namespace WulaFallenEmpire
{
defaultLabel = "WULA_Designator_CallSkyfallerInArea".Translate();
defaultDesc = "WULA_Designator_CallSkyfallerInAreaDesc".Translate();
icon = ContentFinder<Texture2D>.Get("Wula/UI/Designators/WULA_AreaSkyfaller");
icon = ContentFinder<Texture2D>.Get("Wula/UI/Designators/Designator_CallSkyfallerInArea");
soundDragSustain = SoundDefOf.Designate_DragStandard;
soundDragChanged = SoundDefOf.Designate_DragStandard_Changed;
useMouseIcon = true;
@@ -147,38 +145,9 @@ namespace WulaFallenEmpire
if (comp == null)
return false;
if (!comp.CanCallSkyfaller)
return GetFailureReason(t, comp);
return true;
}
private string GetFailureReason(Thing building, CompSkyfallerCaller comp)
{
if (!comp.HasRequiredFlyOver && comp.Props.requireFlyOver)
return "WULA_NoBuildingDropperFlyOver".Translate();
if (!comp.CheckRoofConditions)
{
var roof = building.Position.GetRoof(building.Map);
if (roof?.isThickRoof == true)
return "WULA_ThickRoofBlocking".Translate();
else
return "WULA_RoofBlocking".Translate();
}
if (!comp.HasEnoughMaterials())
return "WULA_InsufficientMaterials".Translate();
if (comp.used)
return "WULA_AlreadyUsed".Translate();
if (comp.calling)
return "WULA_AlreadyCalling".Translate();
return "WULA_CannotCallSkyfaller".Translate();
}
public override void DesignateThing(Thing t)
{
// 用于反向设计器(右键菜单)