diff --git a/1.6/1.6/Assemblies/WulaFallenEmpire.dll b/1.6/1.6/Assemblies/WulaFallenEmpire.dll
index ade5b720..03c30a74 100644
Binary files a/1.6/1.6/Assemblies/WulaFallenEmpire.dll and b/1.6/1.6/Assemblies/WulaFallenEmpire.dll differ
diff --git a/1.6/1.6/Defs/AbilityDefs/WULA_Flyover_Ability.xml b/1.6/1.6/Defs/AbilityDefs/WULA_Flyover_Ability.xml
index 4f045eef..09e480b4 100644
--- a/1.6/1.6/Defs/AbilityDefs/WULA_Flyover_Ability.xml
+++ b/1.6/1.6/Defs/AbilityDefs/WULA_Flyover_Ability.xml
@@ -100,7 +100,7 @@
WULA_ClearFlightPath
使近地轨道上的舰队离开,以使得其他乌拉帝国舰队可以入场
- Wula/UI/Abilities/WULA_CallConstructionShip
+ Wula/UI/Abilities/WULA_ClearFlightPath
1
Misc12
false
@@ -918,8 +918,8 @@
35
70
0.1
- 16
- 16
+ 8
+ 8
240
30
2
diff --git a/1.6/1.6/Defs/EventDefs/EventDef_Wula/Wula_MainEvent.xml b/1.6/1.6/Defs/EventDefs/EventDef_Wula/Wula_MainEvent.xml
index bf5b83d3..8599faa3 100644
--- a/1.6/1.6/Defs/EventDefs/EventDef_Wula/Wula_MainEvent.xml
+++ b/1.6/1.6/Defs/EventDefs/EventDef_Wula/Wula_MainEvent.xml
@@ -52,10 +52,6 @@
false
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -77,15 +73,11 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
- WULA_GiveQuest_Colony_Promotion_UI_1
+ WULA_Colony_Promotion_UI_1
@@ -95,10 +87,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -222,10 +210,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -670,10 +654,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
diff --git a/1.6/1.6/Defs/QuestScriptDefs/WULA_Base_Tex_Quest.xml b/1.6/1.6/Defs/QuestScriptDefs/WULA_Base_Tex_Quest.xml
index 94269dd3..28301f97 100644
--- a/1.6/1.6/Defs/QuestScriptDefs/WULA_Base_Tex_Quest.xml
+++ b/1.6/1.6/Defs/QuestScriptDefs/WULA_Base_Tex_Quest.xml
@@ -210,10 +210,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
diff --git a/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml b/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml
index 75b72c15..46521c93 100644
--- a/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml
+++ b/1.6/1.6/Defs/QuestScriptDefs/WULA_Colony_Promotion.xml
@@ -1,7 +1,7 @@
- WULA_GiveQuest_Colony_Promotion_UI_1
+ WULA_Colony_Promotion_UI_1
Wula/Events/Portraits/WULA_Legion_2
「军团」,P.I.A
@@ -12,17 +12,24 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
+ false
+ 我记得我已经送了一个分体去你们殖民地了?在30天内,我不会再派出审查队。
+
+
+ WULA_Colony_Promotion_Lock
+
+
-
+
+ WULA_Colony_Promotion_Lock
+ 1800000
+
WULA_Colony_Promotion
+
@@ -30,10 +37,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -328,9 +331,9 @@
Raids
1.0
- 0.5
+ 1.5
0.04
- 1~1.5
+ 1~1
1.1
500
@@ -375,7 +378,7 @@
Fail
- -5
+ -30
$asker
QuestPawnArrested
@@ -395,7 +398,7 @@
Fail
- -5
+ -30
$asker
PerformedHarmfulSurgery
@@ -415,7 +418,7 @@
Fail
- -5
+ -30
$asker
XenogermAbsorbed
@@ -435,7 +438,7 @@
Fail
- -5
+ -30
$asker
QuestPawnLost
@@ -455,7 +458,7 @@
Fail
- -5
+ -30
$asker
ShuttleDestroyed
@@ -475,7 +478,7 @@
Fail
- -5
+ -30
$asker
QuestPawnLost
@@ -493,7 +496,7 @@
pickupShipThing.SentSatisfied
- WULA_GiveQuest_Colony_Promotion_UI_2
+ WULA_Colony_Promotion_UI_2
Success
@@ -513,7 +516,7 @@
Fail
- -5
+ -30
$asker
MemberMissedShuttle
@@ -544,7 +547,7 @@
- WULA_GiveQuest_Colony_Promotion_UI_2
+ WULA_Colony_Promotion_UI_2
Wula/Events/Portraits/WULA_Legion_2
「军团」,P.I.A
@@ -576,10 +579,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
diff --git a/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_NewColony.xml b/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_NewColony.xml
index 476d4bdd..945e7667 100644
--- a/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_NewColony.xml
+++ b/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_NewColony.xml
@@ -60,10 +60,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -78,10 +74,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -96,10 +88,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -125,10 +113,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -143,10 +127,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -161,10 +141,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -190,10 +166,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -208,10 +180,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -237,10 +205,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -255,10 +219,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -284,10 +244,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -302,10 +258,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -331,10 +283,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -349,10 +297,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -367,10 +311,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -396,10 +336,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
diff --git a/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_Spy.xml b/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_Spy.xml
index d2242a58..cea32bb2 100644
--- a/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_Spy.xml
+++ b/1.6/1.6/Defs/QuestScriptDefs/WULA_Intro_Spy.xml
@@ -418,10 +418,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -436,10 +432,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -454,10 +446,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -480,10 +468,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -509,10 +493,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -538,10 +518,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
@@ -595,10 +571,6 @@
false
- (255,255,255,255)
- (157,201,185,195)
- (255,255,255,255)
- (255,255,255,255)
diff --git a/1.6/1.6/Defs/SoundDefs/Wula_Sound_Weapons.xml b/1.6/1.6/Defs/SoundDefs/Wula_Sound_Weapons.xml
index 4098226e..b980f9ee 100644
--- a/1.6/1.6/Defs/SoundDefs/Wula_Sound_Weapons.xml
+++ b/1.6/1.6/Defs/SoundDefs/Wula_Sound_Weapons.xml
@@ -204,6 +204,76 @@
+
+
+ WULA_Firepower_Minigun_Fire_sound
+ MapOnly
+ 2
+
+
+
+
+ Wula/WULA_Basttleship_Shootingsound_S
+
+
+ 35
+ 0.9~1.1
+ True
+
+
+
+
+ WULA_Firepower_Cannon_Fire_sound
+ MapOnly
+ 2
+
+
+
+
+ Wula/WULA_Basttleship_Shootingsound_M
+
+
+ 45
+ 0.9~1.1
+ True
+
+
+
+
+ WULA_Firepower_Primary_Cannon_Fire_sound
+ MapOnly
+ 2
+
+
+
+
+ Wula/WULA_Basttleship_Shootingsound_L
+
+
+ 55
+ 0.9~1.1
+ True
+
+
+
+
+ WULA_MotherShip_Planet_Interdiction_IncomingSound
+ MapOnly
+ 2
+
+
+
+
+ Wula/WULA_MotherShip_Planet_Interdiction_IncomingSound
+
+
+ 55
+ 0.9~1.1
+ True
+
+
+
+
Pawn_Wula_AI_Heavy_Panzer_Call
diff --git a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Drop_Buildings.xml b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Drop_Buildings.xml
index 029fe8ef..2d522680 100644
--- a/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Drop_Buildings.xml
+++ b/1.6/1.6/Defs/ThingDefs_Buildings/WULA_Drop_Buildings.xml
@@ -996,7 +996,7 @@
CompPowerTrader
- 400
+ 100
diff --git a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml
index aad96a7b..1321317a 100644
--- a/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml
+++ b/1.6/1.6/Defs/ThingDefs_Misc/WULA_Flyover_Item.xml
@@ -768,58 +768,8 @@
MetaOverlays
-
- 60
- 全域封锁
- 全域封锁舰队已抵达,请自行寻找掩护!
- PositiveEvent
- true
- true
- false
-
-
- WULA_Striker_Escort
-
-
- 1000
- 30
- 2
-
-
- 0
- 100
- 5
- true
- 10
- 70
-
-
- 50
- 10
- false
-
-
- true
- false
- true
-
-
- true
-
-
-
- 0.3
- 0.6
-
-
-
- true
-
- 0.6
- 0.8
-
- (0.7,0.85,1.0,1.0)
- 1.3
+
+ WULA_MotherShip_Planet_Interdiction_IncomingSound
WULA_BattleShip_Planet_Interdiction
@@ -831,7 +781,7 @@
0
- 80
+ 70
5
true
30
@@ -865,6 +815,17 @@
(0.7,0.85,1.0,1.0)
1.3
+
+ 300
+ 300
+ 65
+ WULA_Firepower_Cannon_Salvo_Skyfaller
+ 12
+
+
+ true
+ true
+
@@ -912,6 +873,50 @@
false
MetaOverlays
+
+ WULA_Striker_Escort
+
+
+ 1000
+ 30
+ 2
+
+
+ 0
+ 100
+ 5
+ true
+ 10
+ 70
+
+
+ 10
+ 10
+ false
+
+
+ true
+ false
+ true
+
+
+ true
+
+
+
+ 0.3
+ 0.6
+
+
+
+ true
+
+ 0.6
+ 0.8
+
+ (0.7,0.85,1.0,1.0)
+ 1.3
+
300
300
@@ -1455,20 +1460,25 @@
1
- (0,180)
- (1, 181)
+ (0,150)
+ (1, 151)
- (0,0)
- (1, 1)
+ (0,-30)
+ (1, -31)
4
WULA_Firepower_Minigun_Strafe_Damage
1
+
+
+ WULA_Firepower_Minigun_Fire_sound
+
+
WULA_Firepower_Cannon_Salvo_Skyfaller
@@ -1493,20 +1503,25 @@
1
- (0,180)
- (1, 181)
+ (0,150)
+ (1, 151)
- (0,0)
- (1, 1)
+ (0,-30)
+ (1, -31)
6
- Bomb
- 0.85
+ WULA_GiantBomb
+ 0.28
+
+
+ WULA_Firepower_Cannon_Fire_sound
+
+
WULA_Firepower_Cannon_Surveillance_Skyfaller
@@ -1898,14 +1913,14 @@
1
- (0,180)
- (1, 181)
+ (0,150)
+ (1, 151)
- (0,0)
- (1, 1)
+ (0,-30)
+ (1, -31)
35
@@ -1913,6 +1928,11 @@
1
CraterLarge
+
+
+ WULA_Firepower_Primary_Cannon_Fire_sound
+
+
WULA_DarkMatterBomb_FlashStrong
@@ -2048,19 +2068,24 @@
1
- (0,180)
- (1, 181)
+ (0,150)
+ (1, 151)
- (0,0)
- (1, 1)
+ (0,-30)
+ (1, -31)
35
EMP
10
+
+
+ WULA_Firepower_Primary_Cannon_Fire_sound
+
+
\ No newline at end of file
diff --git a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml
index 3e3d8ae4..b693e256 100644
--- a/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml
+++ b/1.6/1.6/Defs/ThingDefs_Misc/Weapons/WULA_FE_Manpack_Weapon.xml
@@ -396,6 +396,8 @@
Graphic_Single
CutoutComplex
+ true
+ None
-65
Spacer
false
@@ -500,8 +502,8 @@
Bullet_WULA_RW_Base_AR
1
25
- 3
- 3
+ 5
+ 5
Shot_AssaultRifle
GunTail_Medium
7
@@ -513,7 +515,6 @@
Wula_Ranged_Weapon_T1
- Wula_Assault_Cat_Weapon
@@ -522,6 +523,59 @@
+
+
+ true
+ WULA_RW_Base_AR_For_Cat
+
+ 乌拉帝国的基础突击步枪,仍然使用可靠的导气式结构驱动自动射击构件,是一种便宜但好用的武器,通常派发给殖民地作自卫武器之用。
+ Normal
+ Spacer
+
+ Wula/Weapon/WULA_RW_Base_AR
+ Graphic_Single
+
+ Interact_Rifle
+ None
+
+
+ WULA_WeaponArmor_Productor
+
+ WULA_Synth_Weapon_1_Base_Technology
+ UnfinishedWeapon
+
+
+ 1300
+
+ 3.5
+ 0.75
+ 0.75
+ 0.65
+ 0.45
+ 1.2
+
+
+
+ Verb_Shoot
+ true
+ Bullet_WULA_RW_Base_AR
+ 1
+ 25
+ 5
+ 5
+ Shot_AssaultRifle
+ GunTail_Medium
+ 7
+
+
+
+ 40
+ 2
+
+
+ Wula_Assault_Cat_Weapon
+
+
Bullet_WULA_RW_Base_AR
@@ -2195,7 +2249,7 @@
WULA_MW_Cheat_Weapon_Ability
使得目标立刻被放逐——无视一切保护措施,将其从存档中永远擦除。
- Wula/UI/Abilities/WULA_RW_Auto_GL_Smoke_Ability
+ Wula/UI/Commands/Wula_Psi_Titan_AreaDamage
True
False
Misc11
diff --git a/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml
index 9506574f..be17452a 100644
--- a/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml
+++ b/1.6/1.6/Languages/ChineseSimplified (简体中文)/Keyed/Misc_Gameplay.xml
@@ -301,4 +301,9 @@
启用或禁用区域伤害效果
区域伤害:已启用
区域伤害:已禁用
+
+ 更换武器
+ 扔掉当前武器,并装备该单位的初始武器
+ {0} 更换了武器为 {1}
+ {0} 没有可用的武器类型
\ No newline at end of file
diff --git a/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_L.wav b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_L.wav
new file mode 100644
index 00000000..3df8dae4
Binary files /dev/null and b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_L.wav differ
diff --git a/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_M.wav b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_M.wav
new file mode 100644
index 00000000..91df9773
Binary files /dev/null and b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_M.wav differ
diff --git a/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_S.wav b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_S.wav
new file mode 100644
index 00000000..cec2f3b2
Binary files /dev/null and b/Content/Sounds/Wula/WULA_Basttleship_Shootingsound_S.wav differ
diff --git a/Content/Sounds/Wula/WULA_MotherShip_Planet_Interdiction_IncomingSound.wav b/Content/Sounds/Wula/WULA_MotherShip_Planet_Interdiction_IncomingSound.wav
new file mode 100644
index 00000000..02e4e83e
Binary files /dev/null and b/Content/Sounds/Wula/WULA_MotherShip_Planet_Interdiction_IncomingSound.wav differ
diff --git a/Content/Textures/Wula/UI/Abilities/WULA_ClearFlightPath.png b/Content/Textures/Wula/UI/Abilities/WULA_ClearFlightPath.png
new file mode 100644
index 00000000..196571b4
Binary files /dev/null and b/Content/Textures/Wula/UI/Abilities/WULA_ClearFlightPath.png differ
diff --git a/Source/WulaFallenEmpire/EventSystem/Condition.cs b/Source/WulaFallenEmpire/EventSystem/Condition/ConditionBase.cs
similarity index 96%
rename from Source/WulaFallenEmpire/EventSystem/Condition.cs
rename to Source/WulaFallenEmpire/EventSystem/Condition/ConditionBase.cs
index 4b8325da..4101f051 100644
--- a/Source/WulaFallenEmpire/EventSystem/Condition.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Condition/ConditionBase.cs
@@ -3,12 +3,12 @@ using RimWorld;
namespace WulaFallenEmpire
{
- public abstract class Condition
+ public abstract class ConditionBase
{
public abstract bool IsMet(out string reason);
}
- public class Condition_VariableEquals : Condition
+ public class Condition_VariableEquals : ConditionBase
{
public string name;
public string value;
@@ -75,7 +75,7 @@ namespace WulaFallenEmpire
}
}
- public abstract class Condition_CompareVariable : Condition
+ public abstract class Condition_CompareVariable : ConditionBase
{
public string name;
public float value;
@@ -145,7 +145,7 @@ namespace WulaFallenEmpire
protected override string GetOperatorString() => "<=";
}
- public class Condition_VariableNotEqual : Condition
+ public class Condition_VariableNotEqual : ConditionBase
{
public string name;
public string value;
@@ -213,7 +213,7 @@ namespace WulaFallenEmpire
}
}
- public class Condition_FactionExists : Condition
+ public class Condition_FactionExists : ConditionBase
{
public FactionDef factionDef;
diff --git a/Source/WulaFallenEmpire/EventSystem/Condition/Condition_FlagExists.cs b/Source/WulaFallenEmpire/EventSystem/Condition/Condition_FlagExists.cs
new file mode 100644
index 00000000..68bef5a7
--- /dev/null
+++ b/Source/WulaFallenEmpire/EventSystem/Condition/Condition_FlagExists.cs
@@ -0,0 +1,83 @@
+using Verse;
+using RimWorld;
+
+namespace WulaFallenEmpire
+{
+ public abstract class Condition
+ {
+ public abstract bool IsMet(out string reason);
+ }
+
+ public class Condition_FlagExists : ConditionBase
+ {
+ public string flagName;
+
+ public override bool IsMet(out string reason)
+ {
+ if (string.IsNullOrEmpty(flagName))
+ {
+ reason = "Flag name is not specified.";
+ return false;
+ }
+
+ var eventVarManager = Find.World.GetComponent();
+ bool flagExists = eventVarManager.HasFlag(flagName);
+
+ if (!flagExists)
+ {
+ reason = $"Flag '{flagName}' does not exist or has expired.";
+ }
+ else
+ {
+ int remainingTicks = eventVarManager.GetFlagRemainingTicks(flagName);
+ if (remainingTicks < 0)
+ {
+ reason = $"Flag '{flagName}' exists (permanent).";
+ }
+ else
+ {
+ reason = $"Flag '{flagName}' exists (expires in {remainingTicks} ticks).";
+ }
+ }
+
+ Log.Message($"[EventSystem] Condition_FlagExists check: Flag='{flagName}', Exists={flagExists}, Reason='{reason}'");
+ return flagExists;
+ }
+ }
+
+ public class Condition_FlagNotExists : ConditionBase
+ {
+ public string flagName;
+
+ public override bool IsMet(out string reason)
+ {
+ if (string.IsNullOrEmpty(flagName))
+ {
+ reason = "Flag name is not specified.";
+ return false;
+ }
+
+ var eventVarManager = Find.World.GetComponent();
+ bool flagExists = eventVarManager.HasFlag(flagName);
+
+ if (flagExists)
+ {
+ int remainingTicks = eventVarManager.GetFlagRemainingTicks(flagName);
+ if (remainingTicks < 0)
+ {
+ reason = $"Flag '{flagName}' exists (permanent).";
+ }
+ else
+ {
+ reason = $"Flag '{flagName}' exists (expires in {remainingTicks} ticks).";
+ }
+ return false;
+ }
+ else
+ {
+ reason = $"Flag '{flagName}' does not exist.";
+ return true;
+ }
+ }
+ }
+}
diff --git a/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs b/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
index 6df07b47..0f9cb584 100644
--- a/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Dialog_CustomDisplay.cs
@@ -572,7 +572,7 @@ namespace WulaFallenEmpire
}
}
- private bool AreConditionsMet(List conditions, out string reason)
+ private bool AreConditionsMet(List conditions, out string reason)
{
reason = "";
if (conditions.NullOrEmpty())
diff --git a/Source/WulaFallenEmpire/EventSystem/Effect/EffectBase.cs b/Source/WulaFallenEmpire/EventSystem/Effect/EffectBase.cs
index 7259cf66..db193374 100644
--- a/Source/WulaFallenEmpire/EventSystem/Effect/EffectBase.cs
+++ b/Source/WulaFallenEmpire/EventSystem/Effect/EffectBase.cs
@@ -68,7 +68,7 @@ namespace WulaFallenEmpire
}
}
- private bool AreConditionsMet(List conditions, out string reason)
+ private bool AreConditionsMet(List conditions, out string reason)
{
reason = "";
if (conditions.NullOrEmpty())
diff --git a/Source/WulaFallenEmpire/EventSystem/Effect/Effect_SetTimedFlag.cs b/Source/WulaFallenEmpire/EventSystem/Effect/Effect_SetTimedFlag.cs
new file mode 100644
index 00000000..94bfe80f
--- /dev/null
+++ b/Source/WulaFallenEmpire/EventSystem/Effect/Effect_SetTimedFlag.cs
@@ -0,0 +1,27 @@
+// 在 EffectBase.cs 中添加以下类
+using Verse;
+using RimWorld;
+
+namespace WulaFallenEmpire
+{
+ public class Effect_SetTimedFlag : EffectBase
+ {
+ public string flagName;
+ public int durationTicks; // 持续时间(tick),负数表示永久
+
+ public override void Execute(Window dialog = null)
+ {
+ if (string.IsNullOrEmpty(flagName))
+ {
+ Log.Error("[WulaFallenEmpire] Effect_SetTimedFlag has a null or empty flagName.");
+ return;
+ }
+
+ var eventVarManager = Find.World.GetComponent();
+ eventVarManager.SetTimedFlag(flagName, durationTicks);
+
+ string durationInfo = durationTicks < 0 ? "permanent" : $"{durationTicks} ticks";
+ Log.Message($"[EventSystem] Set timed flag '{flagName}' with duration: {durationInfo}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Source/WulaFallenEmpire/EventSystem/EventDef.cs b/Source/WulaFallenEmpire/EventSystem/EventDef.cs
index 829a13db..3fd17931 100644
--- a/Source/WulaFallenEmpire/EventSystem/EventDef.cs
+++ b/Source/WulaFallenEmpire/EventSystem/EventDef.cs
@@ -71,7 +71,7 @@ namespace WulaFallenEmpire
{
[MustTranslate]
public string label;
- public List conditions;
+ public List conditions;
[MustTranslate]
public string disabledReason;
public bool hideWhenDisabled = true;
@@ -102,7 +102,7 @@ namespace WulaFallenEmpire
public class ConditionalEffects
{
- public List conditions;
+ public List conditions;
public List effects;
public List randomlistEffects;
public List loopEffects;
@@ -164,7 +164,7 @@ namespace WulaFallenEmpire
public class ConditionalDescription
{
- public List conditions;
+ public List conditions;
[MustTranslate]
public string text;
}
diff --git a/Source/WulaFallenEmpire/EventSystem/EventVariableManager.cs b/Source/WulaFallenEmpire/EventSystem/EventVariableManager.cs
index de84903a..c64006e7 100644
--- a/Source/WulaFallenEmpire/EventSystem/EventVariableManager.cs
+++ b/Source/WulaFallenEmpire/EventSystem/EventVariableManager.cs
@@ -12,12 +12,17 @@ namespace WulaFallenEmpire
private Dictionary stringVars = new Dictionary();
private Dictionary pawnVars = new Dictionary();
private Dictionary> pawnListVars = new Dictionary>();
+
+ // 新增:有时限的flag字典
+ private Dictionary timedFlags = new Dictionary();
// 用于Scribe的辅助列表
private List pawnVarKeys;
private List pawnVarValues;
private List pawnListVarKeys;
private List> pawnListVarValues;
+ private List timedFlagKeys;
+ private List timedFlagValues;
// Required for WorldComponent
public EventVariableManager(World world) : base(world)
@@ -32,6 +37,7 @@ namespace WulaFallenEmpire
Scribe_Collections.Look(ref stringVars, "stringVars", LookMode.Value, LookMode.Value);
Scribe_Collections.Look(ref pawnVars, "pawnVars", LookMode.Value, LookMode.Reference, ref pawnVarKeys, ref pawnVarValues);
Scribe_Collections.Look(ref pawnListVars, "pawnListVars", LookMode.Value, LookMode.Reference, ref pawnListVarKeys, ref pawnListVarValues);
+ Scribe_Collections.Look(ref timedFlags, "timedFlags", LookMode.Value, LookMode.Value, ref timedFlagKeys, ref timedFlagValues);
// Ensure dictionaries are not null after loading
if (Scribe.mode == LoadSaveMode.PostLoadInit)
@@ -41,6 +47,43 @@ namespace WulaFallenEmpire
stringVars ??= new Dictionary();
pawnVars ??= new Dictionary();
pawnListVars ??= new Dictionary>();
+ timedFlags ??= new Dictionary();
+ }
+ }
+
+ public override void WorldComponentTick()
+ {
+ base.WorldComponentTick();
+
+ // 每60 tick检查一次过期flag
+ if (Find.TickManager.TicksGame % 60 == 0)
+ {
+ CheckExpiredFlags();
+ }
+ }
+
+ ///
+ /// 检查并清理过期的flag
+ ///
+ private void CheckExpiredFlags()
+ {
+ List flagsToRemove = new List();
+ int currentTick = Find.TickManager.TicksGame;
+
+ foreach (var kvp in timedFlags)
+ {
+ // 如果flag的过期时间不为负数且小于当前tick,则标记为需要移除
+ if (kvp.Value >= 0 && currentTick >= kvp.Value)
+ {
+ flagsToRemove.Add(kvp.Key);
+ Log.Message($"[EventSystem] Flag '{kvp.Key}' expired and will be removed.");
+ }
+ }
+
+ // 移除过期的flag
+ foreach (string flagName in flagsToRemove)
+ {
+ timedFlags.Remove(flagName);
}
}
@@ -81,6 +124,80 @@ namespace WulaFallenEmpire
}
}
+ ///
+ /// 设置有时限的flag
+ ///
+ /// flag名称
+ /// 持续时间(tick),负数表示永久
+ public void SetTimedFlag(string flagName, int durationTicks)
+ {
+ if (string.IsNullOrEmpty(flagName)) return;
+
+ int expiryTick;
+ if (durationTicks < 0)
+ {
+ // 负数表示永久flag
+ expiryTick = -1;
+ Log.Message($"[EventSystem] Setting permanent flag '{flagName}'.");
+ }
+ else
+ {
+ // 正数表示有时间限制的flag
+ expiryTick = Find.TickManager.TicksGame + durationTicks;
+ Log.Message($"[EventSystem] Setting timed flag '{flagName}' with duration {durationTicks} ticks (expires at tick {expiryTick}).");
+ }
+
+ timedFlags[flagName] = expiryTick;
+ }
+
+ ///
+ /// 检查flag是否存在且未过期
+ ///
+ public bool HasFlag(string flagName)
+ {
+ if (string.IsNullOrEmpty(flagName)) return false;
+
+ if (timedFlags.TryGetValue(flagName, out int expiryTick))
+ {
+ if (expiryTick < 0)
+ {
+ // 永久flag
+ return true;
+ }
+ else
+ {
+ // 检查是否过期
+ bool isActive = Find.TickManager.TicksGame < expiryTick;
+ if (!isActive)
+ {
+ // 如果过期了,移除它
+ timedFlags.Remove(flagName);
+ Log.Message($"[EventSystem] Flag '{flagName}' has expired and was removed.");
+ }
+ return isActive;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// 获取flag的剩余时间(tick)
+ ///
+ public int GetFlagRemainingTicks(string flagName)
+ {
+ if (string.IsNullOrEmpty(flagName) || !timedFlags.TryGetValue(flagName, out int expiryTick))
+ return 0;
+
+ if (expiryTick < 0)
+ {
+ // 永久flag
+ return -1;
+ }
+
+ int remaining = expiryTick - Find.TickManager.TicksGame;
+ return remaining > 0 ? remaining : 0;
+ }
+
public T GetVariable(string name, T defaultValue = default)
{
if (string.IsNullOrEmpty(name)) return defaultValue;
@@ -138,7 +255,8 @@ namespace WulaFallenEmpire
floatVars.ContainsKey(name) ||
stringVars.ContainsKey(name) ||
pawnVars.ContainsKey(name) ||
- pawnListVars.ContainsKey(name);
+ pawnListVars.ContainsKey(name) ||
+ timedFlags.ContainsKey(name);
}
public void ClearVariable(string name)
@@ -152,6 +270,7 @@ namespace WulaFallenEmpire
stringVars.Remove(name);
pawnVars.Remove(name);
pawnListVars.Remove(name);
+ timedFlags.Remove(name);
}
public void ClearAll()
@@ -161,6 +280,7 @@ namespace WulaFallenEmpire
stringVars.Clear();
pawnVars.Clear();
pawnListVars.Clear();
+ timedFlags.Clear();
}
public Dictionary GetAllVariables()
@@ -171,7 +291,8 @@ namespace WulaFallenEmpire
foreach (var kvp in stringVars) allVars[kvp.Key] = kvp.Value;
foreach (var kvp in pawnVars) allVars[kvp.Key] = kvp.Value;
foreach (var kvp in pawnListVars) allVars[kvp.Key] = kvp.Value;
+ foreach (var kvp in timedFlags) allVars[kvp.Key] = $"Flag (expires: {kvp.Value})";
return allVars;
}
}
-}
\ No newline at end of file
+}
diff --git a/Source/WulaFallenEmpire/Flyover/WULA_ShipArtillery/CompShipArtillery.cs b/Source/WulaFallenEmpire/Flyover/WULA_ShipArtillery/CompShipArtillery.cs
index 309e052f..0fe13585 100644
--- a/Source/WulaFallenEmpire/Flyover/WULA_ShipArtillery/CompShipArtillery.cs
+++ b/Source/WulaFallenEmpire/Flyover/WULA_ShipArtillery/CompShipArtillery.cs
@@ -24,20 +24,27 @@ namespace WulaFallenEmpire
// 目标跟踪
private List previousTargets = new List();
- // 新增:微追踪目标列表
- private List microTrackingTargets = new List();
- private List microTrackingWeights = new List(); // 新增:权重列表
+ // 优化:缓存目标列表,避免每帧重新计算
+ private List cachedTargets = new List();
+ private List cachedTargetWeights = new List();
+ private int lastTargetUpdateTick = -9999;
+ private const int TARGET_UPDATE_INTERVAL = 60; // 每60 ticks更新一次目标列表
- // 新增:目标类型权重配置
- 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倍
+ // 优化:一轮炮击的目标缓存
+ private IntVec3 currentVolleyCenter;
+ private List currentVolleyTargets = new List();
+ private int currentVolleyIndex = 0;
+
+ // 目标类型权重配置
+ private const float PAWN_WEIGHT = 5.0f;
+ private const float OWNED_BUILDING_WEIGHT = 1.0f;
+ private const float UNOWNED_BUILDING_WEIGHT = 0.01f;
+ private const float WALL_WEIGHT = 0.001f; // 墙的权重极低
+ private const float OTHER_WEIGHT = 1.0f;
public override void Initialize(CompProperties props)
{
base.Initialize(props);
-
ticksUntilNextAttack = Props.ticksBetweenAttacks;
Log.Message($"Ship Artillery initialized: {Props.ticksBetweenAttacks} ticks between attacks, {Props.attackRadius} radius");
@@ -51,10 +58,14 @@ namespace WulaFallenEmpire
if (parent is not FlyOver flyOver || !flyOver.Spawned || flyOver.Map == null)
return;
- // 更新微追踪目标列表(如果需要)
+ // 优化:减少目标更新频率
if (Props.useMicroTracking && Props.useFactionDiscrimination)
{
- UpdateMicroTrackingTargets(flyOver);
+ if (Find.TickManager.TicksGame - lastTargetUpdateTick > TARGET_UPDATE_INTERVAL)
+ {
+ UpdateTargetCache(flyOver);
+ lastTargetUpdateTick = Find.TickManager.TicksGame;
+ }
}
// 更新预热状态
@@ -82,103 +93,99 @@ namespace WulaFallenEmpire
}
}
- // 新增:更新微追踪目标列表
- private void UpdateMicroTrackingTargets(FlyOver flyOver)
+ // 优化:缓存目标列表
+ private void UpdateTargetCache(FlyOver flyOver)
{
- microTrackingTargets.Clear();
- microTrackingWeights.Clear();
+ cachedTargets.Clear();
+ cachedTargetWeights.Clear();
Faction targetFaction = GetTargetFaction(flyOver);
if (targetFaction == null) return;
- // 获取飞越物体当前位置
IntVec3 center = GetFlyOverPosition(flyOver);
- // 搜索范围内的所有潜在目标
- foreach (IntVec3 cell in GenRadial.RadialCellsAround(center, Props.attackRadius, true))
+ // 优化:使用更高效的目标搜索
+ var potentialTargets = GenRadial.RadialDistinctThingsAround(center, flyOver.Map, Props.attackRadius, true)
+ .Where(thing => IsValidMicroTrackingTarget(thing, targetFaction))
+ .Distinct(); // 避免重复
+
+ foreach (Thing thing in potentialTargets)
{
- 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 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);
- }
- }
+ cachedTargets.Add(new LocalTargetInfo(thing));
+ cachedTargetWeights.Add(GetTargetWeight(thing));
}
- // 移除重复目标(基于位置)
- for (int i = microTrackingTargets.Count - 1; i >= 0; i--)
+ if (DebugSettings.godMode && cachedTargets.Count > 0)
{
- 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}");
+ Log.Message($"Target Cache Updated: Found {cachedTargets.Count} targets");
+ var stats = GetTargetStatistics();
+ Log.Message($"Target Statistics - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
}
}
- // 新增:获取目标权重
+ // 优化:改进的目标有效性检查
+ private bool IsValidMicroTrackingTarget(Thing thing, Faction targetFaction)
+ {
+ if (thing == null || thing.Destroyed) return false;
+
+ // 修复1:无主建筑总是被排除
+ if (thing is Building building && building.Faction == null)
+ return false;
+
+ // 修复2:isWall的建筑总是不考虑
+ if (thing.def?.building?.isWall == true)
+ 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 float GetTargetWeight(Thing thing)
{
if (thing is Pawn)
- {
return PAWN_WEIGHT;
- }
else if (thing is Building building)
{
+ // 修复2:墙的权重极低
+ if (building.def?.building?.isWall == true)
+ return WALL_WEIGHT;
+
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()
+ private (int pawnCount, int ownedBuildingCount, int unownedBuildingCount, int wallCount, int otherCount) GetTargetStatistics()
{
int pawnCount = 0;
int ownedBuildingCount = 0;
int unownedBuildingCount = 0;
+ int wallCount = 0;
int otherCount = 0;
- for (int i = 0; i < microTrackingTargets.Count; i++)
+ foreach (var target in cachedTargets)
{
- Thing thing = microTrackingTargets[i].Thing;
+ Thing thing = target.Thing;
if (thing == null) continue;
if (thing is Pawn)
@@ -187,7 +194,11 @@ namespace WulaFallenEmpire
}
else if (thing is Building building)
{
- if (building.Faction == null)
+ if (building.def?.building?.isWall == true)
+ {
+ wallCount++;
+ }
+ else if (building.Faction == null)
{
unownedBuildingCount++;
}
@@ -202,50 +213,20 @@ namespace WulaFallenEmpire
}
}
- return (pawnCount, ownedBuildingCount, unownedBuildingCount, otherCount);
+ return (pawnCount, ownedBuildingCount, unownedBuildingCount, wallCount, 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;
}
@@ -266,11 +247,15 @@ namespace WulaFallenEmpire
Log.Message($"Ship Artillery starting attack on target area: {currentTarget} (attack radius: {Props.attackRadius})");
- // 开始预热
+ // 修复3:在一轮炮击中,只进行一次目标选择
+ currentVolleyCenter = currentTarget;
+ currentVolleyTargets.Clear();
+ currentVolleyIndex = 0;
+
+ // 预热阶段
isWarmingUp = true;
warmupTicksRemaining = Props.warmupTicks;
- // 启动预热效果
if (Props.warmupEffect != null)
{
warmupEffecter = Props.warmupEffect.Spawn();
@@ -282,19 +267,16 @@ namespace WulaFallenEmpire
{
warmupTicksRemaining--;
- // 维持预热效果
if (warmupEffecter != null)
{
warmupEffecter.EffectTick(new TargetInfo(currentTarget, flyOver.Map), new TargetInfo(currentTarget, flyOver.Map));
}
- // 生成预热粒子
if (Props.warmupFleck != null && Rand.MTBEventOccurs(0.1f, 1f, 1f))
{
FleckMaker.Static(currentTarget.ToVector3Shifted(), flyOver.Map, Props.warmupFleck);
}
- // 预热完成,开始攻击
if (warmupTicksRemaining <= 0)
{
StartFiring(flyOver);
@@ -307,11 +289,9 @@ namespace WulaFallenEmpire
isAttacking = true;
attackTicksRemaining = Props.attackDurationTicks;
- // 清理预热效果
warmupEffecter?.Cleanup();
warmupEffecter = null;
- // 启动攻击效果
if (Props.attackEffect != null)
{
attackEffecter = Props.attackEffect.Spawn();
@@ -333,26 +313,23 @@ namespace WulaFallenEmpire
{
attackTicksRemaining--;
- // 维持攻击效果
if (attackEffecter != null)
{
attackEffecter.EffectTick(new TargetInfo(currentTarget, flyOver.Map), new TargetInfo(currentTarget, flyOver.Map));
}
// 在攻击期间定期发射炮弹
- if (attackTicksRemaining % 60 == 0) // 每秒发射一次
+ if (attackTicksRemaining % 60 == 0)
{
ExecuteVolley(flyOver);
}
- // 生成攻击粒子
if (Props.attackFleck != null && Rand.MTBEventOccurs(0.2f, 1f, 1f))
{
Vector3 randomOffset = new Vector3(Rand.Range(-3f, 3f), 0f, Rand.Range(-3f, 3f));
FleckMaker.Static((currentTarget.ToVector3Shifted() + randomOffset), flyOver.Map, Props.attackFleck);
}
- // 攻击结束
if (attackTicksRemaining <= 0)
{
EndAttack(flyOver);
@@ -361,17 +338,66 @@ namespace WulaFallenEmpire
private void ExecuteVolley(FlyOver flyOver)
{
+ // 修复3:为这一轮炮击生成所有目标
+ if (currentVolleyTargets.Count == 0)
+ {
+ GenerateVolleyTargets(flyOver);
+ }
+
for (int i = 0; i < Props.shellsPerVolley; i++)
{
- FireShell(flyOver);
+ if (currentVolleyIndex < currentVolleyTargets.Count)
+ {
+ FireShell(flyOver, currentVolleyTargets[currentVolleyIndex]);
+ currentVolleyIndex++;
+ }
+ else
+ {
+ // 如果目标用完了,重新生成(对于持续攻击)
+ GenerateVolleyTargets(flyOver);
+ if (currentVolleyTargets.Count > 0)
+ {
+ FireShell(flyOver, currentVolleyTargets[0]);
+ currentVolleyIndex = 1;
+ }
+ }
}
}
- private void FireShell(FlyOver flyOver)
+ // 修复3:生成一轮炮击的所有目标
+ private void GenerateVolleyTargets(FlyOver flyOver)
+ {
+ currentVolleyTargets.Clear();
+ currentVolleyIndex = 0;
+
+ for (int i = 0; i < Props.shellsPerVolley * 3; i++) // 生成足够的目标
+ {
+ IntVec3 target;
+ if (Props.useMicroTracking && Props.useFactionDiscrimination && cachedTargets.Count > 0)
+ {
+ target = SelectTargetFromCache(flyOver);
+ }
+ else
+ {
+ target = SelectRandomTargetInRadius(currentVolleyCenter, flyOver.Map, Props.attackRadius);
+ }
+
+ if (target.IsValid && target.InBounds(flyOver.Map))
+ {
+ currentVolleyTargets.Add(target);
+ }
+ }
+
+ if (DebugSettings.godMode)
+ {
+ Log.Message($"Generated {currentVolleyTargets.Count} targets for volley around {currentVolleyCenter}");
+ }
+ }
+
+ private void FireShell(FlyOver flyOver, IntVec3 shellTarget)
{
try
{
- // 选择炮弹类型
ThingDef shellDef = SelectShellDef();
if (shellDef == null)
{
@@ -379,24 +405,14 @@ namespace WulaFallenEmpire
return;
}
- // 选择目标
- 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);
- float distanceFromCenter = shellTarget.DistanceTo(currentTarget);
- Log.Message($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})");
+ float distanceFromCenter = shellTarget.DistanceTo(currentVolleyCenter);
+ if (DebugSettings.godMode)
+ {
+ Log.Message($"Ship Artillery fired shell at {shellTarget} (distance from center: {distanceFromCenter:F1})");
+ }
- // 播放音效
if (Props.attackSound != null)
{
Props.attackSound.PlayOneShot(new TargetInfo(shellTarget, flyOver.Map));
@@ -408,16 +424,15 @@ namespace WulaFallenEmpire
}
}
- // 修改:微追踪目标选择 - 现在使用权重系统
- private IntVec3 SelectMicroTrackingTarget(FlyOver flyOver)
+ // 优化:从缓存中选择目标
+ private IntVec3 SelectTargetFromCache(FlyOver flyOver)
{
- if (microTrackingTargets.Count == 0)
+ if (cachedTargets.Count == 0)
{
Log.Warning("MicroTracking: No targets available, falling back to random target");
- return SelectRandomTarget(flyOver);
+ return SelectRandomTargetInRadius(currentVolleyCenter, flyOver.Map, Props.attackRadius);
}
- // 使用权重系统选择目标
LocalTargetInfo selectedTarget = SelectTargetByWeight();
IntVec3 targetCell = selectedTarget.Cell;
@@ -429,7 +444,6 @@ namespace WulaFallenEmpire
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;
@@ -448,37 +462,34 @@ namespace WulaFallenEmpire
return offsetTarget;
}
- // 新增:基于权重的目标选择
+ // 基于权重的目标选择
private LocalTargetInfo SelectTargetByWeight()
{
- if (microTrackingTargets.Count == 0)
+ if (cachedTargets.Count == 0)
return LocalTargetInfo.Invalid;
- if (microTrackingTargets.Count == 1)
- return microTrackingTargets[0];
+ if (cachedTargets.Count == 1)
+ return cachedTargets[0];
- // 计算总权重
float totalWeight = 0f;
- foreach (float weight in microTrackingWeights)
+ foreach (float weight in cachedTargetWeights)
{
totalWeight += weight;
}
- // 随机选择
float randomValue = Rand.Range(0f, totalWeight);
float currentSum = 0f;
- for (int i = 0; i < microTrackingTargets.Count; i++)
+ for (int i = 0; i < cachedTargets.Count; i++)
{
- currentSum += microTrackingWeights[i];
+ currentSum += cachedTargetWeights[i];
if (randomValue <= currentSum)
{
- return microTrackingTargets[i];
+ return cachedTargets[i];
}
}
- // 回退到最后一个目标
- return microTrackingTargets[microTrackingTargets.Count - 1];
+ return cachedTargets[cachedTargets.Count - 1];
}
private ThingDef SelectShellDef()
@@ -512,26 +523,18 @@ namespace WulaFallenEmpire
return launchPos;
}
- // 简化的目标选择 - 每次直接随机选择目标
- private IntVec3 SelectRandomTarget(FlyOver flyOver)
+ private IntVec3 SelectTarget(FlyOver flyOver)
{
IntVec3 center = GetFlyOverPosition(flyOver) + Props.targetOffset;
return FindRandomTargetInRadius(center, flyOver.Map, Props.attackRadius);
}
- private IntVec3 SelectTarget(FlyOver flyOver)
+ // 简化的目标选择 - 每次直接随机选择目标
+ private IntVec3 SelectRandomTargetInRadius(IntVec3 center, Map map, float radius)
{
- // 获取飞越物体当前位置作为基础中心
- IntVec3 flyOverPos = GetFlyOverPosition(flyOver);
- IntVec3 center = flyOverPos + Props.targetOffset;
-
- Log.Message($"FlyOver position: {flyOverPos}, Center for targeting: {center}");
-
- // 在攻击半径内选择随机目标
- return FindRandomTargetInRadius(center, flyOver.Map, Props.attackRadius);
+ return FindRandomTargetInRadius(center, map, radius);
}
- // 改进的飞越物体位置获取
private IntVec3 GetFlyOverPosition(FlyOver flyOver)
{
// 优先使用 DrawPos,因为它反映实际视觉位置
@@ -554,15 +557,13 @@ namespace WulaFallenEmpire
// 目标查找逻辑 - 基于攻击半径
private IntVec3 FindRandomTargetInRadius(IntVec3 center, Map map, float radius)
{
- Log.Message($"Finding target around {center} with radius {radius}");
-
- // 如果半径为0,直接返回中心
if (radius <= 0)
return center;
bool ignoreProtectionForThisTarget = Rand.Value < Props.ignoreProtectionChance;
- for (int i = 0; i < 30; i++)
+ // 优化:减少尝试次数
+ for (int i = 0; i < 15; i++)
{
// 在圆形区域内随机选择
float angle = Rand.Range(0f, 360f);
@@ -582,12 +583,15 @@ namespace WulaFallenEmpire
previousTargets.Add(potentialTarget);
- float actualDistance = potentialTarget.DistanceTo(center);
- Log.Message($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})");
-
- if (ignoreProtectionForThisTarget)
+ if (DebugSettings.godMode)
{
- Log.Warning($"Protection ignored for target selection! May target player assets.");
+ float actualDistance = potentialTarget.DistanceTo(center);
+ Log.Message($"Found valid target at {potentialTarget} (distance from center: {actualDistance:F1})");
+
+ if (ignoreProtectionForThisTarget)
+ {
+ Log.Warning($"Protection ignored for target selection! May target player assets.");
+ }
}
return potentialTarget;
@@ -598,7 +602,7 @@ namespace WulaFallenEmpire
// 回退:使用地图随机位置
Log.Warning("Could not find valid target in radius, using fallback");
CellRect mapRect = CellRect.WholeMap(map);
- for (int i = 0; i < 10; i++)
+ for (int i = 0; i < 5; i++)
{
IntVec3 fallbackTarget = mapRect.RandomCell;
if (IsValidTarget(fallbackTarget, map, ignoreProtectionForThisTarget))
@@ -731,6 +735,10 @@ namespace WulaFallenEmpire
attackEffecter?.Cleanup();
attackEffecter = null;
+ // 清理缓存
+ currentVolleyTargets.Clear();
+ currentVolleyIndex = 0;
+
// 重置计时器
if (Props.continuousAttack && !flyOver.hasCompleted)
{
@@ -773,9 +781,13 @@ namespace WulaFallenEmpire
Scribe_Values.Look(ref isAttacking, "isAttacking", false);
Scribe_Values.Look(ref isWarmingUp, "isWarmingUp", false);
Scribe_Values.Look(ref currentTarget, "currentTarget");
+ Scribe_Values.Look(ref currentVolleyCenter, "currentVolleyCenter");
+ Scribe_Values.Look(ref currentVolleyIndex, "currentVolleyIndex");
+ Scribe_Values.Look(ref lastTargetUpdateTick, "lastTargetUpdateTick", -9999);
Scribe_Collections.Look(ref previousTargets, "previousTargets", LookMode.Value);
- Scribe_Collections.Look(ref microTrackingTargets, "microTrackingTargets", LookMode.LocalTargetInfo);
- Scribe_Collections.Look(ref microTrackingWeights, "microTrackingWeights", LookMode.Value);
+ Scribe_Collections.Look(ref cachedTargets, "cachedTargets", LookMode.LocalTargetInfo);
+ Scribe_Collections.Look(ref cachedTargetWeights, "cachedTargetWeights", LookMode.Value);
+ Scribe_Collections.Look(ref currentVolleyTargets, "currentVolleyTargets", LookMode.Value);
}
public override IEnumerable CompGetGizmosExtra()
@@ -791,7 +803,14 @@ namespace WulaFallenEmpire
yield return new Command_Action
{
defaultLabel = "Dev: Fire Single Shell",
- action = () => FireShell(parent as FlyOver)
+ action = () =>
+ {
+ if (parent is FlyOver flyOver)
+ {
+ IntVec3 target = SelectRandomTargetInRadius(GetFlyOverPosition(flyOver), flyOver.Map, Props.attackRadius);
+ FireShell(flyOver, target);
+ }
+ }
};
yield return new Command_Action
@@ -814,11 +833,14 @@ namespace WulaFallenEmpire
// 显示派系甄别信息
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}");
+ Log.Message($"Micro Tracking: {Props.useMicroTracking}, Targets Found: {cachedTargets.Count}");
// 显示目标统计
var stats = GetTargetStatistics();
- Log.Message($"Target Stats - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Others: {stats.otherCount}");
+ Log.Message($"Target Stats - Pawns: {stats.pawnCount}, Owned Buildings: {stats.ownedBuildingCount}, Unowned Buildings: {stats.unownedBuildingCount}, Walls: {stats.wallCount}, Others: {stats.otherCount}");
+
+ // 显示炮击信息
+ Log.Message($"Volley - Center: {currentVolleyCenter}, Targets: {currentVolleyTargets.Count}, Index: {currentVolleyIndex}");
}
}
};
@@ -828,26 +850,56 @@ namespace WulaFallenEmpire
{
yield return new Command_Action
{
- defaultLabel = $"Dev: Show Micro Targets ({microTrackingTargets.Count})",
+ defaultLabel = $"Dev: Show Cached Targets ({cachedTargets.Count})",
action = () =>
{
if (parent is FlyOver flyOver)
{
- for (int i = 0; i < microTrackingTargets.Count; i++)
+ for (int i = 0; i < cachedTargets.Count; i++)
{
- var target = microTrackingTargets[i];
- float weight = microTrackingWeights[i];
+ var target = cachedTargets[i];
+ float weight = cachedTargetWeights[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}");
+ Log.Message($"Cached Target: {thing?.Label ?? "Unknown"} ({type}) at {target.Cell}, Weight: {weight:F2}");
}
}
}
};
}
+
+ // 显示当前炮击目标
+ if (currentVolleyTargets.Count > 0)
+ {
+ yield return new Command_Action
+ {
+ defaultLabel = $"Dev: Show Volley Targets ({currentVolleyTargets.Count})",
+ action = () =>
+ {
+ for (int i = 0; i < currentVolleyTargets.Count; i++)
+ {
+ Log.Message($"Volley Target {i}: {currentVolleyTargets[i]} ({(i == currentVolleyIndex ? "NEXT" : "queued")})");
+ }
+ }
+ };
+ }
+
+ // 强制更新目标缓存
+ yield return new Command_Action
+ {
+ defaultLabel = "Dev: Force Update Target Cache",
+ action = () =>
+ {
+ if (parent is FlyOver flyOver)
+ {
+ UpdateTargetCache(flyOver);
+ Log.Message($"Force updated target cache: {cachedTargets.Count} targets found");
+ }
+ }
+ };
}
}
@@ -863,5 +915,21 @@ namespace WulaFallenEmpire
{
currentTarget = target;
}
+
+ // 新增:获取当前状态信息
+ public string GetStatusString()
+ {
+ if (parent is not FlyOver flyOver)
+ return "Invalid parent";
+
+ string status = isWarmingUp ? $"Warming up ({warmupTicksRemaining} ticks)" :
+ isAttacking ? $"Attacking ({attackTicksRemaining} ticks)" :
+ $"Next attack in {ticksUntilNextAttack} ticks";
+
+ string targetInfo = currentTarget.IsValid ? $"Target: {currentTarget}" : "No target";
+ string volleyInfo = currentVolleyTargets.Count > 0 ? $", Volley: {currentVolleyIndex}/{currentVolleyTargets.Count}" : "";
+
+ return $"{status}, {targetInfo}{volleyInfo}";
+ }
}
}
diff --git a/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs b/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs
index 80fcdee1..31ff8394 100644
--- a/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs
+++ b/Source/WulaFallenEmpire/Pawn/WULA_AutonomousMech/CompAutonomousMech.cs
@@ -207,6 +207,112 @@ namespace WulaFallenEmpire
{
yield return new DroneGizmo(this);
}
+
+ // 更换武器按钮(仅当有装备武器时显示)
+ if (MechPawn.equipment?.Primary != null)
+ {
+ yield return CreateWeaponSwitchGizmo();
+ }
+ }
+
+ ///
+ /// 创建更换武器的Gizmo
+ ///
+ private Gizmo CreateWeaponSwitchGizmo()
+ {
+ Command_Action switchWeaponCommand = new Command_Action
+ {
+ defaultLabel = "WULA_SwitchWeapon".Translate(),
+ defaultDesc = "WULA_SwitchWeapon_Desc".Translate(),
+ icon = ContentFinder.Get("Wula/UI/Abilities/WULA_WeaponSwitchAbility", false) ?? BaseContent.BadTex,
+ action = SwitchWeapon
+ };
+
+ return switchWeaponCommand;
+ }
+
+ ///
+ /// 更换武器逻辑
+ ///
+ private void SwitchWeapon()
+ {
+ if (MechPawn == null || MechPawn.Destroyed || !MechPawn.Spawned)
+ return;
+
+ try
+ {
+ // 1. 扔掉当前武器
+ ThingWithComps currentWeapon = MechPawn.equipment?.Primary;
+ if (currentWeapon != null)
+ {
+ // 将武器扔在地上
+ MechPawn.equipment.TryDropEquipment(currentWeapon, out ThingWithComps droppedWeapon, MechPawn.Position, true);
+
+ if (Prefs.DevMode)
+ {
+ Log.Message($"[CompAutonomousMech] {MechPawn.LabelCap} dropped weapon: {currentWeapon.LabelCap}");
+ }
+ }
+
+ // 2. 从PawnKind允许的武器中生成新武器
+ ThingDef newWeaponDef = GetRandomWeaponFromPawnKind();
+ if (newWeaponDef != null)
+ {
+ // 生成新武器
+ Thing newWeapon = ThingMaker.MakeThing(newWeaponDef);
+ if (newWeapon is ThingWithComps newWeaponWithComps)
+ {
+ // 使用 AddEquipment 方法装备新武器
+ MechPawn.equipment.AddEquipment(newWeaponWithComps);
+
+ Messages.Message("WULA_WeaponSwitched".Translate(MechPawn.LabelCap, newWeaponDef.LabelCap),
+ MechPawn, MessageTypeDefOf.PositiveEvent);
+
+ if (Prefs.DevMode)
+ {
+ Log.Message($"[CompAutonomousMech] {MechPawn.LabelCap} equipped new weapon: {newWeaponDef.LabelCap}");
+ }
+ }
+ }
+ else
+ {
+ Messages.Message("WULA_NoWeaponAvailable".Translate(MechPawn.LabelCap),
+ MechPawn, MessageTypeDefOf.NegativeEvent);
+ }
+ }
+ catch (System.Exception ex)
+ {
+ Log.Error($"[CompAutonomousMech] Error switching weapon for {MechPawn?.LabelCap}: {ex}");
+ }
+ }
+
+ ///
+ /// 从PawnKind允许的武器中随机获取一个武器定义
+ ///
+ private ThingDef GetRandomWeaponFromPawnKind()
+ {
+ if (MechPawn.kindDef?.weaponTags == null || MechPawn.kindDef.weaponTags.Count == 0)
+ return null;
+
+ // 收集所有匹配的武器
+ List availableWeapons = new List();
+
+ foreach (string weaponTag in MechPawn.kindDef.weaponTags)
+ {
+ foreach (ThingDef thingDef in DefDatabase.AllDefs)
+ {
+ if (thingDef.IsWeapon && thingDef.weaponTags != null && thingDef.weaponTags.Contains(weaponTag))
+ {
+ availableWeapons.Add(thingDef);
+ }
+ }
+ }
+
+ if (availableWeapons.Count == 0)
+ return null;
+
+ // 随机选择一个武器
+ return availableWeapons.RandomElement();
}
public void SetWorkMode(DroneWorkModeDef mode)
diff --git a/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompPlaySoundOnSpawn.cs b/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompPlaySoundOnSpawn.cs
new file mode 100644
index 00000000..85f641e9
--- /dev/null
+++ b/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompPlaySoundOnSpawn.cs
@@ -0,0 +1,187 @@
+using RimWorld;
+using Verse;
+using Verse.Sound;
+using System.Collections.Generic;
+
+namespace WulaFallenEmpire
+{
+ public class CompPlaySoundOnSpawn : ThingComp
+ {
+ private CompProperties_PlaySoundOnSpawn Props => (CompProperties_PlaySoundOnSpawn)props;
+
+ private bool soundPlayed = false;
+ private int delayTicksRemaining = 0;
+
+ public override void Initialize(CompProperties props)
+ {
+ base.Initialize(props);
+
+ // 计算延迟的 ticks
+ if (Props.delaySeconds > 0)
+ {
+ delayTicksRemaining = (int)(Props.delaySeconds * 60f);
+ }
+ }
+
+ public override void PostSpawnSetup(bool respawningAfterLoad)
+ {
+ base.PostSpawnSetup(respawningAfterLoad);
+
+ // 如果是重新加载存档,不播放声音
+ if (respawningAfterLoad)
+ return;
+
+ // 检查播放条件
+ if (!ShouldPlaySound())
+ return;
+
+ // 如果有延迟,设置延迟计数器
+ if (Props.delaySeconds > 0)
+ {
+ delayTicksRemaining = (int)(Props.delaySeconds * 60f);
+ }
+ else
+ {
+ // 立即播放声音
+ PlaySound();
+ }
+ }
+
+ public override void CompTick()
+ {
+ base.CompTick();
+
+ // 处理延迟播放
+ if (delayTicksRemaining > 0 && !soundPlayed)
+ {
+ delayTicksRemaining--;
+ if (delayTicksRemaining <= 0)
+ {
+ PlaySound();
+ }
+ }
+ }
+
+ private bool ShouldPlaySound()
+ {
+ if (soundPlayed)
+ return false;
+
+ if (Props.sound == null)
+ return false;
+
+ // 检查派系条件
+ if (parent.Faction != null)
+ {
+ if (Props.onlyIfPlayerFaction && parent.Faction != Faction.OfPlayer)
+ return false;
+
+ if (Props.onlyIfHostileFaction && parent.Faction.RelationKindWith(Faction.OfPlayer) != FactionRelationKind.Hostile)
+ return false;
+
+ if (Props.onlyIfNeutralFaction && parent.Faction.RelationKindWith(Faction.OfPlayer) != FactionRelationKind.Neutral)
+ return false;
+ }
+ else
+ {
+ // 如果没有派系,检查是否要求特定派系
+ if (Props.onlyIfPlayerFaction || Props.onlyIfHostileFaction || Props.onlyIfNeutralFaction)
+ return false;
+ }
+
+ return true;
+ }
+
+ private void PlaySound()
+ {
+ if (soundPlayed || Props.sound == null)
+ return;
+
+ try
+ {
+ SoundInfo soundInfo;
+
+ if (Props.playOnCamera)
+ {
+ // 在摄像机位置播放
+ soundInfo = SoundInfo.OnCamera();
+ }
+ else if (Props.playAtThingPosition)
+ {
+ // 在物体位置播放
+ soundInfo = SoundInfo.InMap(new TargetInfo(parent.Position, parent.Map));
+ }
+ else
+ {
+ // 默认在物体位置播放
+ soundInfo = SoundInfo.InMap(new TargetInfo(parent.Position, parent.Map));
+ }
+
+ // 应用音量和音调设置
+ if (Props.volume != 1f)
+ soundInfo.volumeFactor = Props.volume;
+
+ if (Props.pitch != 1f)
+ soundInfo.pitchFactor = Props.pitch;
+
+ // 播放声音
+ Props.sound.PlayOneShot(soundInfo);
+ soundPlayed = true;
+
+ // 调试日志
+ if (Prefs.DevMode)
+ {
+ Log.Message($"Played spawn sound: {Props.sound.defName} for {parent.Label} at {parent.Position}");
+ }
+ }
+ catch (System.Exception ex)
+ {
+ Log.Error($"Error playing spawn sound for {parent.Label}: {ex}");
+ }
+ }
+
+ public override void PostExposeData()
+ {
+ base.PostExposeData();
+ Scribe_Values.Look(ref soundPlayed, "soundPlayed", false);
+ Scribe_Values.Look(ref delayTicksRemaining, "delayTicksRemaining", 0);
+ }
+
+ // 调试工具
+ public override IEnumerable CompGetGizmosExtra()
+ {
+ if (DebugSettings.ShowDevGizmos)
+ {
+ yield return new Command_Action
+ {
+ defaultLabel = "Dev: Test Spawn Sound",
+ defaultDesc = $"Play sound: {Props.sound?.defName ?? "None"}",
+ action = () =>
+ {
+ if (Props.sound != null)
+ {
+ PlaySound();
+ }
+ else
+ {
+ Log.Warning("No sound defined for CompPlaySoundOnSpawn");
+ }
+ }
+ };
+
+ yield return new Command_Action
+ {
+ defaultLabel = $"Dev: Sound Status - Played: {soundPlayed}, Delay: {delayTicksRemaining}",
+ action = () => {}
+ };
+ }
+ }
+
+ // 重置状态(用于重新播放)
+ public void Reset()
+ {
+ soundPlayed = false;
+ delayTicksRemaining = Props.delaySeconds > 0 ? (int)(Props.delaySeconds * 60f) : 0;
+ }
+ }
+}
diff --git a/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompProperties_PlaySoundOnSpawn.cs b/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompProperties_PlaySoundOnSpawn.cs
new file mode 100644
index 00000000..90760f61
--- /dev/null
+++ b/Source/WulaFallenEmpire/ThingComp/WULA_PlaySoundOnSpawn/CompProperties_PlaySoundOnSpawn.cs
@@ -0,0 +1,31 @@
+using RimWorld;
+using Verse;
+
+namespace WulaFallenEmpire
+{
+ public class CompProperties_PlaySoundOnSpawn : CompProperties
+ {
+ public SoundDef sound;
+
+ // 可选:延迟播放声音(秒)
+ public float delaySeconds = 0f;
+
+ // 可选:只在特定条件下播放
+ public bool onlyIfPlayerFaction = false;
+ public bool onlyIfHostileFaction = false;
+ public bool onlyIfNeutralFaction = false;
+
+ // 可选:音量控制
+ public float volume = 1f;
+ public float pitch = 1f;
+
+ // 可选:播放位置
+ public bool playOnCamera = false; // 在摄像机位置播放
+ public bool playAtThingPosition = true; // 在物体位置播放
+
+ public CompProperties_PlaySoundOnSpawn()
+ {
+ compClass = typeof(CompPlaySoundOnSpawn);
+ }
+ }
+}
diff --git a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj
index 994afeb9..3a98a251 100644
--- a/Source/WulaFallenEmpire/WulaFallenEmpire.csproj
+++ b/Source/WulaFallenEmpire/WulaFallenEmpire.csproj
@@ -117,13 +117,15 @@
-
+
+
+
@@ -266,6 +268,8 @@
+
+