添加爆炸射线武器系统
This commit is contained in:
Binary file not shown.
Binary file not shown.
204
1.6/Defs/ThingDefs_Misc/Weapons/WULA_ExplosiveBeamWeapons.xml
Normal file
204
1.6/Defs/ThingDefs_Misc/Weapons/WULA_ExplosiveBeamWeapons.xml
Normal file
@@ -0,0 +1,204 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Defs>
|
||||
|
||||
<!-- 示例1:轻型爆炸射线武器 - 每发都爆炸 -->
|
||||
<ThingDef ParentName="BaseHumanMakeableGun">
|
||||
<defName>WULA_LightExplosiveBeam</defName>
|
||||
<label>CLa-15"蓝爆"轻型</label>
|
||||
<description>乌拉帝国的轻型爆炸射线武器,每发射线都会在目标位置产生小型爆炸。适合对付轻装甲目标。</description>
|
||||
<techLevel>Ultra</techLevel>
|
||||
<graphicData>
|
||||
<texPath>Wula/Weapon/WULA_RW_Fractal_AR</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<drawSize>1.35</drawSize>
|
||||
</graphicData>
|
||||
<soundInteract>Interact_ChargeRifle</soundInteract>
|
||||
<weaponClasses>
|
||||
<li>LongShots</li>
|
||||
<li>RangedHeavy</li>
|
||||
</weaponClasses>
|
||||
<statBases>
|
||||
<WorkToMake>15000</WorkToMake>
|
||||
<Mass>2.8</Mass>
|
||||
<AccuracyTouch>0.6</AccuracyTouch>
|
||||
<AccuracyShort>0.85</AccuracyShort>
|
||||
<AccuracyMedium>0.7</AccuracyMedium>
|
||||
<AccuracyLong>0.45</AccuracyLong>
|
||||
<RangedWeapon_Cooldown>1.2</RangedWeapon_Cooldown>
|
||||
</statBases>
|
||||
<costList Inherit="False">
|
||||
<Steel>120</Steel>
|
||||
<Plasteel>25</Plasteel>
|
||||
<ComponentSpacer>2</ComponentSpacer>
|
||||
</costList>
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>0.3</warmupTime>
|
||||
<range>25</range>
|
||||
<burstShotCount>4</burstShotCount>
|
||||
<ticksBetweenBurstShots>8</ticksBetweenBurstShots>
|
||||
<beamWidth>2</beamWidth>
|
||||
<beamDamageDef>Burn</beamDamageDef>
|
||||
<soundCastBeam>BeamGraser_Shooting</soundCastBeam>
|
||||
<beamMoteDef>Mote_GraserBeamBase</beamMoteDef>
|
||||
|
||||
<!-- 每发都爆炸 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>1.8</explosionRadius>
|
||||
<explosionDamageDef>Flame</explosionDamageDef>
|
||||
<explosionDamage>15</explosionDamage>
|
||||
<explosionSound>Explosion_Small</explosionSound>
|
||||
<chanceToStartFire>0.6</chanceToStartFire>
|
||||
</li>
|
||||
</verbs>
|
||||
<recipeMaker>
|
||||
<recipeUsers Inherit="False">
|
||||
<li>WULA_Cube_Productor_Energy</li>
|
||||
</recipeUsers>
|
||||
<researchPrerequisite>WULA_Synth_Weapon_2_Stun_Technology</researchPrerequisite>
|
||||
<skillRequirements>
|
||||
<Crafting>4</Crafting>
|
||||
</skillRequirements>
|
||||
</recipeMaker>
|
||||
</ThingDef>
|
||||
|
||||
<!-- 示例2:重型爆炸射线武器 - 每3发爆炸一次,威力更大 -->
|
||||
<ThingDef ParentName="BaseHumanMakeableGun">
|
||||
<defName>WULA_HeavyExplosiveBeam</defName>
|
||||
<label>CLa-16"蓝爆"重型</label>
|
||||
<description>乌拉帝国的重型爆炸射线武器,每三发射线会触发一次大威力爆炸,并在爆炸区域留下燃料污渍。</description>
|
||||
<techLevel>Ultra</techLevel>
|
||||
<graphicData>
|
||||
<texPath>Wula/Weapon/WULA_RW_Fractal_AR</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<drawSize>1.75</drawSize>
|
||||
</graphicData>
|
||||
<soundInteract>Interact_ChargeRifle</soundInteract>
|
||||
<weaponClasses>
|
||||
<li>LongShots</li>
|
||||
<li>RangedHeavy</li>
|
||||
</weaponClasses>
|
||||
<statBases>
|
||||
<WorkToMake>35000</WorkToMake>
|
||||
<Mass>4.2</Mass>
|
||||
<AccuracyTouch>0.45</AccuracyTouch>
|
||||
<AccuracyShort>0.8</AccuracyShort>
|
||||
<AccuracyMedium>0.65</AccuracyMedium>
|
||||
<AccuracyLong>0.4</AccuracyLong>
|
||||
<RangedWeapon_Cooldown>2.1</RangedWeapon_Cooldown>
|
||||
</statBases>
|
||||
<costList Inherit="False">
|
||||
<Steel>200</Steel>
|
||||
<Plasteel>60</Plasteel>
|
||||
<ComponentSpacer>6</ComponentSpacer>
|
||||
<Uranium>15</Uranium>
|
||||
</costList>
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>0.8</warmupTime>
|
||||
<range>35</range>
|
||||
<burstShotCount>9</burstShotCount>
|
||||
<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
|
||||
<beamWidth>4</beamWidth>
|
||||
<beamDamageDef>Stun</beamDamageDef>
|
||||
<soundCastBeam>BeamGraser_Shooting</soundCastBeam>
|
||||
<beamMoteDef>Mote_GraserBeamBase</beamMoteDef>
|
||||
<beamEndEffecterDef>GraserBeam_End</beamEndEffecterDef>
|
||||
|
||||
<!-- 每3发爆炸一次 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>3</explosionShotInterval>
|
||||
<explosionRadius>3.2</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>35</explosionDamage>
|
||||
<explosionArmorPenetration>0.4</explosionArmorPenetration>
|
||||
<explosionSound>Explosion_Bomb</explosionSound>
|
||||
<chanceToStartFire>0.4</chanceToStartFire>
|
||||
<postExplosionSpawnThingDef>Filth_Fuel</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.25</postExplosionSpawnChance>
|
||||
<postExplosionSpawnThingCount>2</postExplosionSpawnThingCount>
|
||||
</li>
|
||||
</verbs>
|
||||
<recipeMaker>
|
||||
<recipeUsers Inherit="False">
|
||||
<li>WULA_Cube_Productor_Energy</li>
|
||||
</recipeUsers>
|
||||
<researchPrerequisite>WULA_Synth_Weapon_2_Stun_Technology</researchPrerequisite>
|
||||
<skillRequirements>
|
||||
<Crafting>6</Crafting>
|
||||
</skillRequirements>
|
||||
</recipeMaker>
|
||||
</ThingDef>
|
||||
|
||||
<!-- 示例3:毒气爆炸射线武器 - 产生毒气效果 -->
|
||||
<ThingDef ParentName="BaseHumanMakeableGun">
|
||||
<defName>WULA_ToxicExplosiveBeam</defName>
|
||||
<label>CLa-17"蓝毒"</label>
|
||||
<description>乌拉帝国的毒气射线武器,每两发射线会触发毒气爆炸,在目标区域释放有毒气体。</description>
|
||||
<techLevel>Ultra</techLevel>
|
||||
<graphicData>
|
||||
<texPath>Wula/Weapon/WULA_RW_Fractal_AR</texPath>
|
||||
<graphicClass>Graphic_Single</graphicClass>
|
||||
<drawSize>1.55</drawSize>
|
||||
</graphicData>
|
||||
<soundInteract>Interact_ChargeRifle</soundInteract>
|
||||
<weaponClasses>
|
||||
<li>LongShots</li>
|
||||
<li>RangedHeavy</li>
|
||||
</weaponClasses>
|
||||
<statBases>
|
||||
<WorkToMake>28000</WorkToMake>
|
||||
<Mass>3.6</Mass>
|
||||
<AccuracyTouch>0.55</AccuracyTouch>
|
||||
<AccuracyShort>0.85</AccuracyShort>
|
||||
<AccuracyMedium>0.7</AccuracyMedium>
|
||||
<AccuracyLong>0.5</AccuracyLong>
|
||||
<RangedWeapon_Cooldown>1.8</RangedWeapon_Cooldown>
|
||||
</statBases>
|
||||
<costList Inherit="False">
|
||||
<Steel>150</Steel>
|
||||
<Plasteel>40</Plasteel>
|
||||
<ComponentSpacer>4</ComponentSpacer>
|
||||
<Chemfuel>25</Chemfuel>
|
||||
</costList>
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>0.6</warmupTime>
|
||||
<range>28</range>
|
||||
<burstShotCount>6</burstShotCount>
|
||||
<ticksBetweenBurstShots>7</ticksBetweenBurstShots>
|
||||
<beamWidth>2.5</beamWidth>
|
||||
<beamDamageDef>ToxGas</beamDamageDef>
|
||||
<soundCastBeam>BeamGraser_Shooting</soundCastBeam>
|
||||
<beamMoteDef>Mote_GraserBeamBase</beamMoteDef>
|
||||
|
||||
<!-- 每2发爆炸一次,产生毒气 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>2.8</explosionRadius>
|
||||
<explosionDamageDef>ToxGas</explosionDamageDef>
|
||||
<explosionDamage>20</explosionDamage>
|
||||
<explosionSound>Explosion_Gas</explosionSound>
|
||||
<postExplosionGasType>ToxGas</postExplosionGasType>
|
||||
<chanceToStartFire>0.1</chanceToStartFire>
|
||||
</li>
|
||||
</verbs>
|
||||
<recipeMaker>
|
||||
<recipeUsers Inherit="False">
|
||||
<li>WULA_Cube_Productor_Energy</li>
|
||||
</recipeUsers>
|
||||
<researchPrerequisite>WULA_Synth_Weapon_2_Stun_Technology</researchPrerequisite>
|
||||
<skillRequirements>
|
||||
<Crafting>5</Crafting>
|
||||
</skillRequirements>
|
||||
</recipeMaker>
|
||||
</ThingDef>
|
||||
|
||||
</Defs>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Defs>
|
||||
<!-- 简易武器 -->
|
||||
<ThingDef ParentName="BaseMeleeWeapon_Blunt">
|
||||
|
||||
259
Documentation/ExplosiveBeamWeapons/开发指南.md
Normal file
259
Documentation/ExplosiveBeamWeapons/开发指南.md
Normal file
@@ -0,0 +1,259 @@
|
||||
# 爆炸射线武器开发指南
|
||||
|
||||
## 架构概述
|
||||
|
||||
爆炸射线武器系统基于RimWorld原版的射线武器系统,通过继承和扩展实现爆炸功能。
|
||||
|
||||
### 核心类结构
|
||||
|
||||
```
|
||||
Verb (RimWorld原版)
|
||||
└── Verb_ShootBeam (RimWorld原版)
|
||||
└── Verb_ShootBeamExplosive (自定义)
|
||||
|
||||
VerbProperties (RimWorld原版)
|
||||
└── VerbPropertiesExplosiveBeam (自定义)
|
||||
```
|
||||
|
||||
## 代码架构
|
||||
|
||||
### 1. Verb_ShootBeamExplosive.cs
|
||||
|
||||
#### 核心字段
|
||||
```csharp
|
||||
private int explosionShotCounter = 0; // 爆炸计数器
|
||||
```
|
||||
|
||||
#### 关键方法
|
||||
- `TryCastShot()`: 重写射击方法,添加爆炸逻辑
|
||||
- `TriggerExplosion()`: 触发爆炸的核心方法
|
||||
- `ExposeData()`: 保存/加载数据
|
||||
|
||||
#### 工作流程
|
||||
1. 调用基类的 `TryCastShot()`
|
||||
2. 如果射击成功且启用爆炸,递增计数器
|
||||
3. 当计数器达到间隔值时,触发爆炸并重置计数器
|
||||
|
||||
### 2. VerbPropertiesExplosiveBeam.cs
|
||||
|
||||
#### 配置属性分类
|
||||
- **基础控制**: `enableExplosion`, `explosionShotInterval`
|
||||
- **伤害属性**: `explosionRadius`, `explosionDamage`, `explosionDamageDef`
|
||||
- **效果属性**: `explosionSound`, `explosionEffecter`
|
||||
- **后续效果**: `postExplosionSpawn*`, `postExplosionGasType`
|
||||
|
||||
## 扩展开发
|
||||
|
||||
### 添加新的爆炸类型
|
||||
|
||||
1. **在VerbPropertiesExplosiveBeam中添加新属性**
|
||||
```csharp
|
||||
public bool enableChainExplosion = false;
|
||||
public int chainExplosionCount = 3;
|
||||
public float chainExplosionDelay = 0.5f;
|
||||
```
|
||||
|
||||
2. **在Verb_ShootBeamExplosive中实现逻辑**
|
||||
```csharp
|
||||
private void TriggerChainExplosion(VerbPropertiesExplosiveBeam props)
|
||||
{
|
||||
// 实现连锁爆炸逻辑
|
||||
}
|
||||
```
|
||||
|
||||
### 添加条件爆炸
|
||||
|
||||
```csharp
|
||||
// 基于目标类型的条件爆炸
|
||||
private bool ShouldExplodeForTarget(Thing target)
|
||||
{
|
||||
if (target is Pawn pawn)
|
||||
{
|
||||
return pawn.RaceProps.Humanlike;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
### 添加爆炸延迟
|
||||
|
||||
```csharp
|
||||
private void ScheduleDelayedExplosion(IntVec3 pos, float delay)
|
||||
{
|
||||
Find.TickManager.ScheduleCallback(() => {
|
||||
TriggerExplosion(explosiveProps);
|
||||
}, (int)(delay * 60)); // 转换为ticks
|
||||
}
|
||||
```
|
||||
|
||||
## 性能优化
|
||||
|
||||
### 1. 爆炸频率控制
|
||||
- 避免每发都爆炸的设计
|
||||
- 使用合理的 `explosionShotInterval`
|
||||
- 考虑武器的射速和爆炸威力平衡
|
||||
|
||||
### 2. 效果缓存
|
||||
```csharp
|
||||
private static Dictionary<string, Effecter> cachedEffecters = new Dictionary<string, Effecter>();
|
||||
|
||||
private Effecter GetCachedEffecter(EffecterDef def)
|
||||
{
|
||||
string key = def.defName;
|
||||
if (!cachedEffecters.ContainsKey(key))
|
||||
{
|
||||
cachedEffecters[key] = def.Spawn();
|
||||
}
|
||||
return cachedEffecters[key];
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 范围检查优化
|
||||
```csharp
|
||||
private bool IsValidExplosionPosition(IntVec3 pos)
|
||||
{
|
||||
return pos.InBounds(caster.Map) &&
|
||||
pos.GetThingList(caster.Map).Any(t => t.def.category == ThingCategory.Pawn);
|
||||
}
|
||||
```
|
||||
|
||||
## 调试技巧
|
||||
|
||||
### 1. 日志输出
|
||||
```csharp
|
||||
if (Prefs.DevMode)
|
||||
{
|
||||
Log.Message($"[ExplosiveBeam] Shot {explosionShotCounter}/{explosiveProps.explosionShotInterval}");
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 可视化调试
|
||||
```csharp
|
||||
if (DebugSettings.godMode)
|
||||
{
|
||||
// 在爆炸位置显示调试信息
|
||||
MoteMaker.ThrowText(explosionCell.ToVector3(), caster.Map,
|
||||
$"Explosion: {explosiveProps.explosionDamage}", Color.red);
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 性能监控
|
||||
```csharp
|
||||
private static Stopwatch explosionTimer = new Stopwatch();
|
||||
|
||||
private void TriggerExplosion(VerbPropertiesExplosiveBeam explosiveProps)
|
||||
{
|
||||
explosionTimer.Start();
|
||||
// ... 爆炸逻辑
|
||||
explosionTimer.Stop();
|
||||
|
||||
if (explosionTimer.ElapsedMilliseconds > 5)
|
||||
{
|
||||
Log.Warning($"Explosion took {explosionTimer.ElapsedMilliseconds}ms");
|
||||
}
|
||||
explosionTimer.Reset();
|
||||
}
|
||||
```
|
||||
|
||||
## 兼容性考虑
|
||||
|
||||
### 1. 模组兼容性
|
||||
- 使用命名空间避免冲突
|
||||
- 检查其他模组的Harmony补丁
|
||||
- 提供配置选项禁用功能
|
||||
|
||||
### 2. 版本兼容性
|
||||
```csharp
|
||||
#if VERSION_1_4
|
||||
// 1.4版本特定代码
|
||||
#elif VERSION_1_5
|
||||
// 1.5版本特定代码
|
||||
#endif
|
||||
```
|
||||
|
||||
### 3. 保存兼容性
|
||||
```csharp
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
|
||||
// 向后兼容的数据保存
|
||||
if (Scribe.mode == LoadSaveMode.LoadingVars)
|
||||
{
|
||||
// 处理旧版本数据
|
||||
}
|
||||
|
||||
Scribe_Values.Look(ref explosionShotCounter, "explosionShotCounter", 0);
|
||||
}
|
||||
```
|
||||
|
||||
## 测试框架
|
||||
|
||||
### 单元测试示例
|
||||
```csharp
|
||||
[Test]
|
||||
public void TestExplosionInterval()
|
||||
{
|
||||
var verb = new Verb_ShootBeamExplosive();
|
||||
var props = new VerbPropertiesExplosiveBeam
|
||||
{
|
||||
enableExplosion = true,
|
||||
explosionShotInterval = 3
|
||||
};
|
||||
|
||||
// 模拟3次射击
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
bool shouldExplode = (i == 2); // 第3发应该爆炸
|
||||
Assert.AreEqual(shouldExplode, verb.ShouldTriggerExplosion());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
### 1. 配置验证
|
||||
```csharp
|
||||
public override void PostLoad()
|
||||
{
|
||||
base.PostLoad();
|
||||
|
||||
if (explosionShotInterval <= 0)
|
||||
{
|
||||
Log.Error($"Invalid explosionShotInterval: {explosionShotInterval}");
|
||||
explosionShotInterval = 1;
|
||||
}
|
||||
|
||||
if (explosionRadius < 0)
|
||||
{
|
||||
Log.Warning($"Negative explosion radius: {explosionRadius}");
|
||||
explosionRadius = 0;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 错误处理
|
||||
```csharp
|
||||
private void TriggerExplosion(VerbPropertiesExplosiveBeam explosiveProps)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 爆炸逻辑
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"Error in explosion: {e}");
|
||||
// 优雅降级,不影响基础射击功能
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. 资源管理
|
||||
```csharp
|
||||
public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
|
||||
{
|
||||
// 清理资源
|
||||
cachedEffecters.Clear();
|
||||
base.Destroy(mode);
|
||||
}
|
||||
```
|
||||
157
Documentation/ExplosiveBeamWeapons/测试说明.md
Normal file
157
Documentation/ExplosiveBeamWeapons/测试说明.md
Normal file
@@ -0,0 +1,157 @@
|
||||
# 爆炸射线武器测试说明
|
||||
|
||||
## 已实现的功能
|
||||
|
||||
### 1. 核心功能
|
||||
- ✅ 继承自原版 Verb_ShootBeam 的所有功能
|
||||
- ✅ 可配置的爆炸触发间隔
|
||||
- ✅ 可配置的爆炸伤害、范围、类型
|
||||
- ✅ 可配置的音效和特效
|
||||
- ✅ 可配置的爆炸后效果(生成物品、气体等)
|
||||
|
||||
### 2. 配置选项
|
||||
- `enableExplosion`: 爆炸开关
|
||||
- `explosionShotInterval`: 爆炸间隔(每x发触发一次)
|
||||
- `explosionRadius`: 爆炸半径
|
||||
- `explosionDamageDef`: 爆炸伤害类型
|
||||
- `explosionDamage`: 爆炸伤害值
|
||||
- `explosionSound`: 爆炸音效
|
||||
- `chanceToStartFire`: 点燃概率
|
||||
- `postExplosionSpawnThingDef`: 爆炸后生成物品
|
||||
|
||||
### 3. 示例武器
|
||||
已创建三个示例武器:
|
||||
1. **CLa-15"蓝爆"轻型**: 每发都爆炸,火焰伤害
|
||||
2. **CLa-16"蓝爆"重型**: 每3发爆炸,炸弹伤害+燃料污渍
|
||||
3. **CLa-17"蓝毒"**: 每2发爆炸,毒气伤害+毒气云
|
||||
|
||||
## 测试步骤
|
||||
|
||||
### 1. 编译测试
|
||||
```bash
|
||||
dotnet build "Source\WulaFallenEmpire\WulaFallenEmpire.csproj"
|
||||
```
|
||||
✅ 编译成功
|
||||
|
||||
### 2. 游戏内测试准备
|
||||
1. 启动RimWorld
|
||||
2. 启用开发者模式 (Options -> Dev mode)
|
||||
3. 加载包含此模组的存档或创建新游戏
|
||||
4. 按 `~` 键打开开发者控制台
|
||||
|
||||
### 3. 生成测试武器
|
||||
使用以下命令生成测试武器:
|
||||
```
|
||||
Thing.Spawn WULA_RW_Fractal_AR 1
|
||||
Thing.Spawn WULA_LightExplosiveBeam 1
|
||||
Thing.Spawn WULA_HeavyExplosiveBeam 1
|
||||
Thing.Spawn WULA_ToxicExplosiveBeam 1
|
||||
```
|
||||
|
||||
### 4. 功能验证清单
|
||||
|
||||
#### 基础射线功能
|
||||
- [ ] 射线正常发射和显示
|
||||
- [ ] 射线宽度和颜色正确
|
||||
- [ ] 射线伤害正常造成
|
||||
- [ ] 音效和视觉效果正常
|
||||
|
||||
#### 爆炸功能
|
||||
- [ ] 爆炸按配置间隔触发
|
||||
- [ ] 爆炸位置在射线命中点
|
||||
- [ ] 爆炸半径和伤害正确
|
||||
- [ ] 爆炸音效正常播放
|
||||
- [ ] 爆炸视觉效果正常
|
||||
|
||||
#### 特殊效果
|
||||
- [ ] 点燃效果正常工作
|
||||
- [ ] 爆炸后生成物品(燃料污渍等)
|
||||
- [ ] 毒气云正常生成和扩散
|
||||
- [ ] 护甲穿透计算正确
|
||||
|
||||
### 5. 性能测试
|
||||
- [ ] 连续射击时帧率稳定
|
||||
- [ ] 多个单位同时使用时无卡顿
|
||||
- [ ] 内存使用正常,无内存泄漏
|
||||
|
||||
### 6. 平衡性测试
|
||||
- [ ] 武器伤害与成本匹配
|
||||
- [ ] 爆炸威力不会过于强大
|
||||
- [ ] AI正确使用武器
|
||||
- [ ] 友伤风险合理
|
||||
|
||||
## 测试场景
|
||||
|
||||
### 场景1:单目标测试
|
||||
1. 生成一个敌对的人形目标
|
||||
2. 装备测试武器
|
||||
3. 射击并观察:
|
||||
- 射线效果
|
||||
- 爆炸触发时机
|
||||
- 伤害数值
|
||||
- 特殊效果
|
||||
|
||||
### 场景2:群体目标测试
|
||||
1. 生成多个敌对目标(5-10个)
|
||||
2. 测试爆炸范围伤害
|
||||
3. 观察连锁效果(点燃、毒气扩散等)
|
||||
|
||||
### 场景3:建筑物测试
|
||||
1. 建造一些墙壁和家具
|
||||
2. 测试爆炸对建筑物的影响
|
||||
3. 验证射线穿透和爆炸破坏
|
||||
|
||||
### 场景4:友军测试
|
||||
1. 在友军附近使用武器
|
||||
2. 验证友伤机制
|
||||
3. 测试AI的使用策略
|
||||
|
||||
## 常见问题排查
|
||||
|
||||
### 问题1:爆炸不触发
|
||||
- 检查 `enableExplosion` 是否为 true
|
||||
- 检查 `explosionShotInterval` 设置
|
||||
- 确认射击确实命中目标
|
||||
|
||||
### 问题2:爆炸位置错误
|
||||
- 检查射线的 `InterpolatedPosition` 计算
|
||||
- 确认目标位置在地图范围内
|
||||
|
||||
### 问题3:音效不播放
|
||||
- 检查 `explosionSound` 定义是否正确
|
||||
- 确认音效文件存在
|
||||
|
||||
### 问题4:特效不显示
|
||||
- 检查 `explosionEffecter` 定义
|
||||
- 确认特效资源文件存在
|
||||
|
||||
## 调试工具
|
||||
|
||||
### 开发者命令
|
||||
```
|
||||
# 生成特定武器
|
||||
Thing.Spawn [武器DefName] [数量]
|
||||
|
||||
# 生成敌对目标
|
||||
Pawn.Spawn Raider 5
|
||||
|
||||
# 治疗所有伤害
|
||||
Heal.All
|
||||
|
||||
# 清除所有火焰
|
||||
Fire.Clear
|
||||
```
|
||||
|
||||
### 日志监控
|
||||
监控游戏日志文件中的错误信息:
|
||||
- `Player.log` (Windows)
|
||||
- 搜索 "WulaFallenEmpire" 相关错误
|
||||
|
||||
## 报告问题
|
||||
|
||||
如果发现问题,请记录:
|
||||
1. 具体的复现步骤
|
||||
2. 预期行为 vs 实际行为
|
||||
3. 相关的日志错误信息
|
||||
4. 游戏版本和模组版本
|
||||
5. 其他加载的模组列表
|
||||
262
Documentation/ExplosiveBeamWeapons/示例武器.md
Normal file
262
Documentation/ExplosiveBeamWeapons/示例武器.md
Normal file
@@ -0,0 +1,262 @@
|
||||
# 爆炸射线武器示例
|
||||
|
||||
本文档展示了不同类型的爆炸射线武器配置示例,涵盖各种使用场景。
|
||||
|
||||
## 基础示例
|
||||
|
||||
### 1. 简单爆炸射线
|
||||
最基础的爆炸射线武器配置:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<range>25</range>
|
||||
<burstShotCount>3</burstShotCount>
|
||||
<beamWidth>2</beamWidth>
|
||||
<beamDamageDef>Burn</beamDamageDef>
|
||||
|
||||
<!-- 爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>2.0</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>20</explosionDamage>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
## 进阶示例
|
||||
|
||||
### 2. 延迟爆炸射线
|
||||
每3发触发一次大威力爆炸:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>0.8</warmupTime>
|
||||
<range>30</range>
|
||||
<burstShotCount>9</burstShotCount>
|
||||
<ticksBetweenBurstShots>5</ticksBetweenBurstShots>
|
||||
<beamWidth>3</beamWidth>
|
||||
<beamDamageDef>Stun</beamDamageDef>
|
||||
|
||||
<!-- 延迟爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>3</explosionShotInterval>
|
||||
<explosionRadius>3.5</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>40</explosionDamage>
|
||||
<explosionArmorPenetration>0.5</explosionArmorPenetration>
|
||||
<explosionSound>Explosion_Bomb</explosionSound>
|
||||
<chanceToStartFire>0.4</chanceToStartFire>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
### 3. 火焰爆炸射线
|
||||
专注于点燃和火焰伤害:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<range>28</range>
|
||||
<burstShotCount>6</burstShotCount>
|
||||
<beamWidth>2.5</beamWidth>
|
||||
<beamDamageDef>Flame</beamDamageDef>
|
||||
|
||||
<!-- 火焰爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>2.8</explosionRadius>
|
||||
<explosionDamageDef>Flame</explosionDamageDef>
|
||||
<explosionDamage>25</explosionDamage>
|
||||
<explosionSound>Explosion_Fire</explosionSound>
|
||||
<chanceToStartFire>0.8</chanceToStartFire>
|
||||
<postExplosionSpawnThingDef>Filth_Fuel</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.3</postExplosionSpawnChance>
|
||||
<postExplosionSpawnThingCount>3</postExplosionSpawnThingCount>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
## 特殊效果示例
|
||||
|
||||
### 4. 毒气爆炸射线
|
||||
产生毒气云的射线武器:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<range>26</range>
|
||||
<burstShotCount>4</burstShotCount>
|
||||
<beamWidth>2</beamWidth>
|
||||
<beamDamageDef>ToxGas</beamDamageDef>
|
||||
|
||||
<!-- 毒气爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>3.0</explosionRadius>
|
||||
<explosionDamageDef>ToxGas</explosionDamageDef>
|
||||
<explosionDamage>18</explosionDamage>
|
||||
<explosionSound>Explosion_Gas</explosionSound>
|
||||
<postExplosionGasType>ToxGas</postExplosionGasType>
|
||||
<chanceToStartFire>0.1</chanceToStartFire>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
### 5. 冰冻爆炸射线
|
||||
造成冰冻效果的射线武器:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<range>24</range>
|
||||
<burstShotCount>5</burstShotCount>
|
||||
<beamWidth>2.2</beamWidth>
|
||||
<beamDamageDef>Frostbite</beamDamageDef>
|
||||
|
||||
<!-- 冰冻爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>2.5</explosionRadius>
|
||||
<explosionDamageDef>Frostbite</explosionDamageDef>
|
||||
<explosionDamage>22</explosionDamage>
|
||||
<explosionSound>Explosion_Ice</explosionSound>
|
||||
<chanceToStartFire>0.0</chanceToStartFire>
|
||||
<postExplosionSpawnThingDef>Filth_Water</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.4</postExplosionSpawnChance>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
## 高级配置示例
|
||||
|
||||
### 6. 多效果爆炸射线
|
||||
结合多种效果的复杂武器:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>1.2</warmupTime>
|
||||
<range>35</range>
|
||||
<burstShotCount>12</burstShotCount>
|
||||
<ticksBetweenBurstShots>4</ticksBetweenBurstShots>
|
||||
<beamWidth>4</beamWidth>
|
||||
<beamDamageDef>Bomb</beamDamageDef>
|
||||
|
||||
<!-- 复合爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>4</explosionShotInterval>
|
||||
<explosionRadius>4.0</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>50</explosionDamage>
|
||||
<explosionArmorPenetration>0.6</explosionArmorPenetration>
|
||||
<explosionSound>Explosion_Bomb</explosionSound>
|
||||
|
||||
<!-- 多重后续效果 -->
|
||||
<chanceToStartFire>0.5</chanceToStartFire>
|
||||
<postExplosionSpawnThingDef>Filth_Fuel</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.3</postExplosionSpawnChance>
|
||||
<postExplosionSpawnThingCount>4</postExplosionSpawnThingCount>
|
||||
<preExplosionSpawnThingDef>Mote_ExplosionFlash</preExplosionSpawnThingDef>
|
||||
<preExplosionSpawnChance>1.0</preExplosionSpawnChance>
|
||||
<postExplosionGasType>BlindSmoke</postExplosionGasType>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
### 7. 精确爆炸射线
|
||||
高精度、低频率爆炸的狙击型武器:
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>2.0</warmupTime>
|
||||
<range>45</range>
|
||||
<burstShotCount>1</burstShotCount>
|
||||
<beamWidth>1</beamWidth>
|
||||
<beamDamageDef>Bullet</beamDamageDef>
|
||||
<beamMaxDeviation>0.05</beamMaxDeviation>
|
||||
|
||||
<!-- 精确爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>2.2</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>60</explosionDamage>
|
||||
<explosionArmorPenetration>0.8</explosionArmorPenetration>
|
||||
<explosionSound>Explosion_Sharp</explosionSound>
|
||||
<damageFalloff>false</damageFalloff>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
## 平衡性考虑
|
||||
|
||||
### 轻型武器平衡
|
||||
- 爆炸半径:1.5-2.5
|
||||
- 爆炸伤害:15-25
|
||||
- 射击间隔:1-2发
|
||||
- 成本:低-中等
|
||||
|
||||
### 中型武器平衡
|
||||
- 爆炸半径:2.5-3.5
|
||||
- 爆炸伤害:25-40
|
||||
- 射击间隔:2-3发
|
||||
- 成本:中等-高
|
||||
|
||||
### 重型武器平衡
|
||||
- 爆炸半径:3.5-5.0
|
||||
- 爆炸伤害:40-70
|
||||
- 射击间隔:3-5发
|
||||
- 成本:高-极高
|
||||
|
||||
## 使用建议
|
||||
|
||||
### 1. 近战防御武器
|
||||
```xml
|
||||
<!-- 短射程、高爆炸频率 -->
|
||||
<range>15</range>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>3.0</explosionRadius>
|
||||
```
|
||||
|
||||
### 2. 中距离支援武器
|
||||
```xml
|
||||
<!-- 中等射程、适中爆炸频率 -->
|
||||
<range>28</range>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>2.5</explosionRadius>
|
||||
```
|
||||
|
||||
### 3. 远程狙击武器
|
||||
```xml
|
||||
<!-- 长射程、低爆炸频率、高威力 -->
|
||||
<range>40</range>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>2.0</explosionRadius>
|
||||
<explosionDamage>50</explosionDamage>
|
||||
```
|
||||
|
||||
### 4. 区域控制武器
|
||||
```xml
|
||||
<!-- 大范围、特殊效果 -->
|
||||
<explosionRadius>4.0</explosionRadius>
|
||||
<postExplosionGasType>BlindSmoke</postExplosionGasType>
|
||||
<chanceToStartFire>0.6</chanceToStartFire>
|
||||
```
|
||||
116
Documentation/ExplosiveBeamWeapons/配置说明.md
Normal file
116
Documentation/ExplosiveBeamWeapons/配置说明.md
Normal file
@@ -0,0 +1,116 @@
|
||||
# 爆炸射线武器配置说明
|
||||
|
||||
## 概述
|
||||
新的 `Verb_ShootBeamExplosive` 类扩展了原版的 `Verb_ShootBeam`,添加了可配置的爆炸效果。
|
||||
|
||||
## 配置属性
|
||||
|
||||
### 基础爆炸控制
|
||||
- `enableExplosion` (bool): 是否启用爆炸效果,默认 false
|
||||
- `explosionShotInterval` (int): 每x发射击触发一次爆炸,默认 1
|
||||
|
||||
### 爆炸伤害属性
|
||||
- `explosionRadius` (float): 爆炸半径,默认 2.9
|
||||
- `explosionDamageDef` (DamageDef): 爆炸伤害类型,null时使用 Bomb
|
||||
- `explosionDamage` (int): 爆炸伤害值,-1时使用武器默认伤害
|
||||
- `explosionArmorPenetration` (float): 爆炸护甲穿透,-1时使用武器默认值
|
||||
|
||||
### 音效和特效
|
||||
- `explosionSound` (SoundDef): 爆炸音效
|
||||
- `explosionEffecter` (EffecterDef): 爆炸特效
|
||||
|
||||
### 爆炸后效果
|
||||
- `postExplosionSpawnThingDef` (ThingDef): 爆炸后生成的物品
|
||||
- `postExplosionSpawnChance` (float): 生成概率 (0-1)
|
||||
- `postExplosionSpawnThingCount` (int): 生成数量
|
||||
|
||||
### 爆炸前效果
|
||||
- `preExplosionSpawnThingDef` (ThingDef): 爆炸前生成的物品
|
||||
- `preExplosionSpawnChance` (float): 生成概率 (0-1)
|
||||
- `preExplosionSpawnThingCount` (int): 生成数量
|
||||
|
||||
### 其他属性
|
||||
- `postExplosionGasType` (GasType?): 爆炸后的气体类型
|
||||
- `applyDamageToExplosionCellsNeighbors` (bool): 是否对邻近格子造成伤害
|
||||
- `chanceToStartFire` (float): 点燃概率 (0-1)
|
||||
- `damageFalloff` (bool): 是否有伤害衰减
|
||||
|
||||
## 使用示例
|
||||
|
||||
```xml
|
||||
<verbs>
|
||||
<li Class="WulaFallenEmpire.VerbPropertiesExplosiveBeam">
|
||||
<verbClass>WulaFallenEmpire.Verb_ShootBeamExplosive</verbClass>
|
||||
|
||||
<!-- 基础射线属性 -->
|
||||
<hasStandardCommand>true</hasStandardCommand>
|
||||
<warmupTime>0.5</warmupTime>
|
||||
<range>30</range>
|
||||
<burstShotCount>6</burstShotCount>
|
||||
<beamWidth>3</beamWidth>
|
||||
<beamDamageDef>Stun</beamDamageDef>
|
||||
|
||||
<!-- 爆炸配置 -->
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>3</explosionShotInterval> <!-- 每3发触发一次爆炸 -->
|
||||
<explosionRadius>2.5</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>25</explosionDamage>
|
||||
<explosionSound>Explosion_Bomb</explosionSound>
|
||||
<chanceToStartFire>0.3</chanceToStartFire>
|
||||
<postExplosionSpawnThingDef>Filth_Fuel</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.15</postExplosionSpawnChance>
|
||||
</li>
|
||||
</verbs>
|
||||
```
|
||||
|
||||
## 工作原理
|
||||
|
||||
1. 武器正常进行射线攻击
|
||||
2. 每次成功射击后,计数器递增
|
||||
3. 当计数器达到 `explosionShotInterval` 时:
|
||||
- 在当前射线位置触发爆炸
|
||||
- 播放爆炸音效和特效
|
||||
- 重置计数器
|
||||
4. 爆炸使用配置的参数进行伤害计算
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 爆炸位置基于射线的插值位置
|
||||
- 如果爆炸位置超出地图边界,爆炸不会触发
|
||||
- 音效和特效是可选的,可以设置为 null
|
||||
- 伤害值为 -1 时会尝试使用武器的默认伤害
|
||||
- 这个功能完全向后兼容,不启用爆炸时行为与原版相同
|
||||
|
||||
## 配置模板
|
||||
|
||||
### 轻型爆炸武器
|
||||
```xml
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>1</explosionShotInterval>
|
||||
<explosionRadius>1.8</explosionRadius>
|
||||
<explosionDamageDef>Flame</explosionDamageDef>
|
||||
<explosionDamage>15</explosionDamage>
|
||||
<chanceToStartFire>0.6</chanceToStartFire>
|
||||
```
|
||||
|
||||
### 重型爆炸武器
|
||||
```xml
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>3</explosionShotInterval>
|
||||
<explosionRadius>3.2</explosionRadius>
|
||||
<explosionDamageDef>Bomb</explosionDamageDef>
|
||||
<explosionDamage>35</explosionDamage>
|
||||
<explosionArmorPenetration>0.4</explosionArmorPenetration>
|
||||
<postExplosionSpawnThingDef>Filth_Fuel</postExplosionSpawnThingDef>
|
||||
<postExplosionSpawnChance>0.25</postExplosionSpawnChance>
|
||||
```
|
||||
|
||||
### 毒气武器
|
||||
```xml
|
||||
<enableExplosion>true</enableExplosion>
|
||||
<explosionShotInterval>2</explosionShotInterval>
|
||||
<explosionRadius>2.8</explosionRadius>
|
||||
<explosionDamageDef>ToxGas</explosionDamageDef>
|
||||
<postExplosionGasType>ToxGas</postExplosionGasType>
|
||||
```
|
||||
30
Documentation/README.md
Normal file
30
Documentation/README.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 乌拉帝国模组文档
|
||||
|
||||
本文件夹包含乌拉帝国模组的所有技术文档和说明。
|
||||
|
||||
## 文档结构
|
||||
|
||||
### 📁 ExplosiveBeamWeapons/
|
||||
爆炸射线武器系统的相关文档
|
||||
- 配置说明
|
||||
- 测试指南
|
||||
- 使用示例
|
||||
|
||||
### 📁 Features/
|
||||
各种功能特性的文档(未来扩展)
|
||||
|
||||
### 📁 API/
|
||||
API文档和开发者指南(未来扩展)
|
||||
|
||||
## 快速导航
|
||||
|
||||
### 爆炸射线武器系统
|
||||
- [📋 配置说明](ExplosiveBeamWeapons/配置说明.md) - 详细的配置参数说明
|
||||
- [🧪 测试指南](ExplosiveBeamWeapons/测试说明.md) - 测试步骤和验证清单
|
||||
- [👨💻 开发指南](ExplosiveBeamWeapons/开发指南.md) - 代码架构和扩展开发
|
||||
- [⚔️ 示例武器](ExplosiveBeamWeapons/示例武器.md) - 各种类型的武器配置示例
|
||||
|
||||
## 版本历史
|
||||
|
||||
- v1.0: 初始版本,包含基础乌拉帝国内容
|
||||
- v1.1: 添加爆炸射线武器系统
|
||||
49
Source/WulaFallenEmpire/VerbPropertiesExplosiveBeam.cs
Normal file
49
Source/WulaFallenEmpire/VerbPropertiesExplosiveBeam.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.Sound;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class VerbPropertiesExplosiveBeam : VerbProperties
|
||||
{
|
||||
// 爆炸开关
|
||||
public bool enableExplosion = false;
|
||||
|
||||
// 每x个shotcount触发一次爆炸
|
||||
public int explosionShotInterval = 1;
|
||||
|
||||
// 爆炸基础属性
|
||||
public float explosionRadius = 2.9f;
|
||||
public DamageDef explosionDamageDef = null; // null时使用默认的Bomb
|
||||
public int explosionDamage = -1; // -1时使用武器默认伤害
|
||||
public float explosionArmorPenetration = -1f; // -1时使用武器默认穿甲
|
||||
|
||||
// 爆炸音效和特效
|
||||
public SoundDef explosionSound = null;
|
||||
public EffecterDef explosionEffecter = null;
|
||||
|
||||
// 爆炸后生成物品
|
||||
public ThingDef postExplosionSpawnThingDef = null;
|
||||
public float postExplosionSpawnChance = 0f;
|
||||
public int postExplosionSpawnThingCount = 1;
|
||||
|
||||
// 爆炸前生成物品
|
||||
public ThingDef preExplosionSpawnThingDef = null;
|
||||
public float preExplosionSpawnChance = 0f;
|
||||
public int preExplosionSpawnThingCount = 1;
|
||||
|
||||
// 气体效果
|
||||
public GasType? postExplosionGasType = null;
|
||||
|
||||
// 其他爆炸属性
|
||||
public bool applyDamageToExplosionCellsNeighbors = true;
|
||||
public float chanceToStartFire = 0f;
|
||||
public bool damageFalloff = true;
|
||||
|
||||
public VerbPropertiesExplosiveBeam()
|
||||
{
|
||||
// 设置默认值
|
||||
verbClass = typeof(Verb_ShootBeamExplosive);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
Source/WulaFallenEmpire/Verb_ShootBeamExplosive.cs
Normal file
92
Source/WulaFallenEmpire/Verb_ShootBeamExplosive.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using RimWorld;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
using Verse.Sound;
|
||||
|
||||
namespace WulaFallenEmpire
|
||||
{
|
||||
public class Verb_ShootBeamExplosive : Verse.Verb_ShootBeam
|
||||
{
|
||||
private int explosionShotCounter = 0;
|
||||
|
||||
protected override bool TryCastShot()
|
||||
{
|
||||
bool result = base.TryCastShot();
|
||||
|
||||
if (result && verbProps is VerbPropertiesExplosiveBeam explosiveProps && explosiveProps.enableExplosion)
|
||||
{
|
||||
explosionShotCounter++;
|
||||
|
||||
if (explosionShotCounter >= explosiveProps.explosionShotInterval)
|
||||
{
|
||||
explosionShotCounter = 0;
|
||||
TriggerExplosion(explosiveProps);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void TriggerExplosion(VerbPropertiesExplosiveBeam explosiveProps)
|
||||
{
|
||||
Vector3 explosionPos = InterpolatedPosition;
|
||||
IntVec3 explosionCell = explosionPos.ToIntVec3();
|
||||
|
||||
if (!explosionCell.InBounds(caster.Map))
|
||||
return;
|
||||
|
||||
// 播放爆炸音效
|
||||
if (explosiveProps.explosionSound != null)
|
||||
{
|
||||
explosiveProps.explosionSound.PlayOneShot(new TargetInfo(explosionCell, caster.Map));
|
||||
}
|
||||
|
||||
// 生成爆炸
|
||||
GenExplosion.DoExplosion(
|
||||
center: explosionCell,
|
||||
map: caster.Map,
|
||||
radius: explosiveProps.explosionRadius,
|
||||
damType: explosiveProps.explosionDamageDef ?? DamageDefOf.Bomb,
|
||||
instigator: caster,
|
||||
damAmount: explosiveProps.explosionDamage > 0 ? explosiveProps.explosionDamage : verbProps.defaultProjectile?.projectile?.GetDamageAmount(EquipmentSource) ?? 20,
|
||||
armorPenetration: explosiveProps.explosionArmorPenetration >= 0 ? explosiveProps.explosionArmorPenetration : verbProps.defaultProjectile?.projectile?.GetArmorPenetration(EquipmentSource) ?? 0.3f,
|
||||
explosionSound: null, // 我们已经手动播放了音效
|
||||
weapon: base.EquipmentSource?.def,
|
||||
projectile: null,
|
||||
intendedTarget: currentTarget.Thing,
|
||||
postExplosionSpawnThingDef: explosiveProps.postExplosionSpawnThingDef,
|
||||
postExplosionSpawnChance: explosiveProps.postExplosionSpawnChance,
|
||||
postExplosionSpawnThingCount: explosiveProps.postExplosionSpawnThingCount,
|
||||
postExplosionGasType: explosiveProps.postExplosionGasType,
|
||||
applyDamageToExplosionCellsNeighbors: explosiveProps.applyDamageToExplosionCellsNeighbors,
|
||||
preExplosionSpawnThingDef: explosiveProps.preExplosionSpawnThingDef,
|
||||
preExplosionSpawnChance: explosiveProps.preExplosionSpawnChance,
|
||||
preExplosionSpawnThingCount: explosiveProps.preExplosionSpawnThingCount,
|
||||
chanceToStartFire: explosiveProps.chanceToStartFire,
|
||||
damageFalloff: explosiveProps.damageFalloff,
|
||||
direction: null,
|
||||
ignoredThings: null,
|
||||
affectedAngle: null,
|
||||
doVisualEffects: true,
|
||||
propagationSpeed: 0.6f,
|
||||
excludeRadius: 0f,
|
||||
doSoundEffects: false // 我们手动处理音效
|
||||
);
|
||||
|
||||
// 生成额外的视觉效果
|
||||
if (explosiveProps.explosionEffecter != null)
|
||||
{
|
||||
Effecter effecter = explosiveProps.explosionEffecter.Spawn(explosionCell, caster.Map);
|
||||
effecter.Trigger(new TargetInfo(explosionCell, caster.Map), TargetInfo.Invalid);
|
||||
effecter.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExposeData()
|
||||
{
|
||||
base.ExposeData();
|
||||
Scribe_Values.Look(ref explosionShotCounter, "explosionShotCounter", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,8 @@
|
||||
<Compile Include="JobDriver_FeedWulaPatient.cs" />
|
||||
<Compile Include="WulaStatDefOf.cs" />
|
||||
<Compile Include="CompUseEffect_WulaSkillTrainer.cs" />
|
||||
<Compile Include="Verb_ShootBeamExplosive.cs" />
|
||||
<Compile Include="VerbPropertiesExplosiveBeam.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user