暂存
This commit is contained in:
Binary file not shown.
42
1.6/1.6/Defs/HediffDefs/Hediffs_WulaFallenEmpire.xml
Normal file
42
1.6/1.6/Defs/HediffDefs/Hediffs_WulaFallenEmpire.xml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Defs>
|
||||||
|
<HediffDef>
|
||||||
|
<defName>WULA_WeaponStealEffect</defName>
|
||||||
|
<label>磁力吸附</label>
|
||||||
|
<description>被磁力光束命中,磁力光束将会夺走当前所装备的武器.</description>
|
||||||
|
<hediffClass>HediffWithComps</hediffClass>
|
||||||
|
<defaultLabelColor>(1,0,0.5)</defaultLabelColor>
|
||||||
|
<maxSeverity>1.0</maxSeverity>
|
||||||
|
<initialSeverity>0.0</initialSeverity>
|
||||||
|
<isBad>true</isBad>
|
||||||
|
<comps>
|
||||||
|
<li Class="HediffCompProperties_Disappears">
|
||||||
|
<disappearsAfterTicks>30000</disappearsAfterTicks> <!-- 2 RimWorld days -->
|
||||||
|
</li>
|
||||||
|
</comps>
|
||||||
|
<stages>
|
||||||
|
<li>
|
||||||
|
<label>微弱</label>
|
||||||
|
<minSeverity>0</minSeverity>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>较弱</label>
|
||||||
|
<minSeverity>0.3</minSeverity>
|
||||||
|
<capMods>
|
||||||
|
</capMods>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>较强</label>
|
||||||
|
<minSeverity>0.6</minSeverity>
|
||||||
|
<capMods>
|
||||||
|
</capMods>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>极强</label>
|
||||||
|
<minSeverity>0.9</minSeverity>
|
||||||
|
<capMods>
|
||||||
|
</capMods>
|
||||||
|
</li>
|
||||||
|
</stages>
|
||||||
|
</HediffDef>
|
||||||
|
</Defs>
|
||||||
224
1.6/1.6/Defs/ThingDefs_Races/Races_WulaFlyMech.xml
Normal file
224
1.6/1.6/Defs/ThingDefs_Races/Races_WulaFlyMech.xml
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Defs>
|
||||||
|
|
||||||
|
<!-- Lancer - fast mid-range shooter -->
|
||||||
|
|
||||||
|
<ThingDef Name="LancerMechanoidWalker" ParentName="BaseMechanoidWalker">
|
||||||
|
<defName>WULA_Mech_Flyer</defName>
|
||||||
|
<label>乌拉小镰</label>
|
||||||
|
<description>乌拉帝国小型机械体</description>
|
||||||
|
<tools>
|
||||||
|
<li>
|
||||||
|
<label>left fist</label>
|
||||||
|
<labelNoLocation>fist</labelNoLocation>
|
||||||
|
<capacities>
|
||||||
|
<li>Blunt</li>
|
||||||
|
</capacities>
|
||||||
|
<power>12.0</power>
|
||||||
|
<cooldownTime>2</cooldownTime>
|
||||||
|
<linkedBodyPartsGroup>LeftHand</linkedBodyPartsGroup>
|
||||||
|
<alwaysTreatAsWeapon>true</alwaysTreatAsWeapon>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>right fist</label>
|
||||||
|
<labelNoLocation>fist</labelNoLocation>
|
||||||
|
<capacities>
|
||||||
|
<li>Blunt</li>
|
||||||
|
</capacities>
|
||||||
|
<power>12.0</power>
|
||||||
|
<cooldownTime>2</cooldownTime>
|
||||||
|
<linkedBodyPartsGroup>RightHand</linkedBodyPartsGroup>
|
||||||
|
<alwaysTreatAsWeapon>true</alwaysTreatAsWeapon>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label>head</label>
|
||||||
|
<capacities>
|
||||||
|
<li>Blunt</li>
|
||||||
|
</capacities>
|
||||||
|
<power>8.5</power>
|
||||||
|
<cooldownTime>2</cooldownTime>
|
||||||
|
<linkedBodyPartsGroup>HeadAttackTool</linkedBodyPartsGroup>
|
||||||
|
<ensureLinkedBodyPartsGroupAlwaysUsable>true</ensureLinkedBodyPartsGroupAlwaysUsable>
|
||||||
|
<chanceFactor>0.2</chanceFactor>
|
||||||
|
</li>
|
||||||
|
</tools>
|
||||||
|
<race>
|
||||||
|
<body>Lancer</body>
|
||||||
|
<baseHealthScale>0.72</baseHealthScale>
|
||||||
|
<detritusLeavings>
|
||||||
|
<li>
|
||||||
|
<def>ChunkMechanoidSlag</def>
|
||||||
|
<texOverrideIndex>11</texOverrideIndex>
|
||||||
|
<spawnChance>0.1</spawnChance>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<def>ChunkMechanoidSlag</def>
|
||||||
|
<texOverrideIndex>12</texOverrideIndex>
|
||||||
|
<spawnChance>0.1</spawnChance>
|
||||||
|
</li>
|
||||||
|
</detritusLeavings>
|
||||||
|
<flightStartChanceOnJobStart>0.5</flightStartChanceOnJobStart>
|
||||||
|
</race>
|
||||||
|
<statBases>
|
||||||
|
<BandwidthCost MayRequire="Ludeon.RimWorld.Biotech">0</BandwidthCost>
|
||||||
|
<MaxFlightTime>30</MaxFlightTime>
|
||||||
|
<FlightCooldown>10</FlightCooldown>
|
||||||
|
</statBases>
|
||||||
|
<comps>
|
||||||
|
<!--加上这个组件的机械体会直接跳过原版指挥范围判定-->
|
||||||
|
<li Class="WulaFallenEmpire.CompProperties_GlobalMechCommand" />
|
||||||
|
<!--加上这个组件的机械体可以更换武器-->
|
||||||
|
<li Class="WulaFallenEmpire.CompProperties_MechWeapon" />
|
||||||
|
|
||||||
|
<li Class="CompProperties_TurretGun">
|
||||||
|
<turretDef>WULA_MechFlyerTurretGun</turretDef>
|
||||||
|
<angleOffset>-90</angleOffset>
|
||||||
|
<autoAttack>false</autoAttack>
|
||||||
|
<renderNodeProperties>
|
||||||
|
<li>
|
||||||
|
<nodeClass>PawnRenderNode_TurretGun</nodeClass>
|
||||||
|
<workerClass>PawnRenderNodeWorker_TurretGun</workerClass>
|
||||||
|
<parentTagDef>Body</parentTagDef>
|
||||||
|
<overrideMeshSize>(1, 1)</overrideMeshSize>
|
||||||
|
<baseLayer>20</baseLayer>
|
||||||
|
<pawnType>Any</pawnType>
|
||||||
|
<drawData>
|
||||||
|
<dataWest>
|
||||||
|
<rotationOffset>180</rotationOffset>
|
||||||
|
<offset>(0, 0, 0)</offset>
|
||||||
|
</dataWest>
|
||||||
|
</drawData>
|
||||||
|
</li>
|
||||||
|
</renderNodeProperties>
|
||||||
|
</li>
|
||||||
|
</comps>
|
||||||
|
</ThingDef>
|
||||||
|
|
||||||
|
<PawnKindDef ParentName="BaseMechanoidKind">
|
||||||
|
<defName>WULA_Mech_Flyer</defName>
|
||||||
|
<label>乌拉小镰</label>
|
||||||
|
<race>WULA_Mech_Flyer</race>
|
||||||
|
<combatPower>190</combatPower>
|
||||||
|
<flyingAnimationFramePathPrefix>Things/Pawn/Animal/Goose/Goose_Flying_</flyingAnimationFramePathPrefix>
|
||||||
|
<flyingAnimationFrameCount>8</flyingAnimationFrameCount>
|
||||||
|
<flyingAnimationTicksPerFrame>2</flyingAnimationTicksPerFrame>
|
||||||
|
<flyingAnimationDrawSize>1.35</flyingAnimationDrawSize>
|
||||||
|
<flyingAnimationInheritColors>false</flyingAnimationInheritColors>
|
||||||
|
<lifeStages>
|
||||||
|
<li MayRequire="Ludeon.RimWorld.Biotech">
|
||||||
|
<bodyGraphicData>
|
||||||
|
<texPath>Things/Pawn/Mechanoid/LancerClean</texPath>
|
||||||
|
<maskPath>Things/Pawn/Mechanoid/AllegianceOverlays/Mech_Lancer</maskPath>
|
||||||
|
<shaderType>CutoutWithOverlay</shaderType>
|
||||||
|
<graphicClass>Graphic_Multi</graphicClass>
|
||||||
|
<drawSize>1.5</drawSize>
|
||||||
|
<shadowData>
|
||||||
|
<volume>(0.4, 0.8, 0.4)</volume>
|
||||||
|
</shadowData>
|
||||||
|
</bodyGraphicData>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<bodyGraphicData>
|
||||||
|
<texPath>Things/Pawn/Mechanoid/Lancer</texPath>
|
||||||
|
<maskPath>Things/Pawn/Mechanoid/AllegianceOverlays/Mech_Lancer</maskPath>
|
||||||
|
<shaderType>CutoutWithOverlay</shaderType>
|
||||||
|
<graphicClass>Graphic_Multi</graphicClass>
|
||||||
|
<drawSize>1.5</drawSize>
|
||||||
|
<shadowData>
|
||||||
|
<volume>(0.4, 0.8, 0.4)</volume>
|
||||||
|
</shadowData>
|
||||||
|
</bodyGraphicData>
|
||||||
|
</li>
|
||||||
|
</lifeStages>
|
||||||
|
<weaponMoney>9999~9999</weaponMoney>
|
||||||
|
<weaponTags>
|
||||||
|
<li>MechanoidGunMedium</li>
|
||||||
|
</weaponTags>
|
||||||
|
<techHediffsChance>1</techHediffsChance>
|
||||||
|
<techHediffsMoney>9999~9999</techHediffsMoney>
|
||||||
|
</PawnKindDef>
|
||||||
|
|
||||||
|
<ThingDef ParentName="BaseWeaponTurret">
|
||||||
|
<defName>WULA_MechFlyerTurretGun</defName>
|
||||||
|
<label>乌拉小镰炮塔</label>
|
||||||
|
<description>乌拉小镰的内置炮塔。</description>
|
||||||
|
<tradeability>None</tradeability>
|
||||||
|
<destroyOnDrop>true</destroyOnDrop>
|
||||||
|
<graphicData>
|
||||||
|
<texPath>Things/Building/TacticalTurret/TacticalTurret_Top</texPath>
|
||||||
|
<graphicClass>Graphic_Single</graphicClass>
|
||||||
|
</graphicData>
|
||||||
|
<statBases>
|
||||||
|
<Mass>2.6</Mass>
|
||||||
|
<AccuracyTouch>0.60</AccuracyTouch>
|
||||||
|
<AccuracyShort>0.80</AccuracyShort>
|
||||||
|
<AccuracyMedium>0.90</AccuracyMedium>
|
||||||
|
<AccuracyLong>0.85</AccuracyLong>
|
||||||
|
</statBases>
|
||||||
|
<verbs>
|
||||||
|
<li Class="WulaFallenEmpire.VerbProperties_WeaponStealBeam">
|
||||||
|
<verbClass>WulaFallenEmpire.Verb_ShootWeaponStealBeam</verbClass>
|
||||||
|
<hediffToApply>WULA_WeaponStealEffect</hediffToApply>
|
||||||
|
<hediffSeverityPerHit>0.1</hediffSeverityPerHit>
|
||||||
|
<hediffMaxSeverity>1.0</hediffMaxSeverity>
|
||||||
|
<removeHediffOnSteal>true</removeHediffOnSteal>
|
||||||
|
<!-- 基础射线参数 -->
|
||||||
|
<hasStandardCommand>true</hasStandardCommand>
|
||||||
|
<warmupTime>0</warmupTime>
|
||||||
|
<range>10</range>
|
||||||
|
<burstShotCount>5</burstShotCount>
|
||||||
|
<ticksBetweenBurstShots>50</ticksBetweenBurstShots>
|
||||||
|
<beamDamageDef>Wula_Dark_Matter_Beam</beamDamageDef>
|
||||||
|
<beamTotalDamage>3</beamTotalDamage>
|
||||||
|
|
||||||
|
<!-- 消除射线偏移的参数 -->
|
||||||
|
<beamFullWidthRange>1000</beamFullWidthRange>
|
||||||
|
<beamWidth>-1</beamWidth>
|
||||||
|
<beamMaxDeviation>0</beamMaxDeviation>
|
||||||
|
<beamCurvature>0</beamCurvature>
|
||||||
|
<beamStartOffset>0</beamStartOffset>
|
||||||
|
|
||||||
|
<!-- 视觉和音效 -->
|
||||||
|
<muzzleFlashScale>0</muzzleFlashScale>
|
||||||
|
<soundCastBeam>BeamGraser_Shooting</soundCastBeam>
|
||||||
|
<beamGroundFleckDef>Fleck_BeamBurn</beamGroundFleckDef>
|
||||||
|
<beamFleckChancePerTick>0.32</beamFleckChancePerTick>
|
||||||
|
<beamMoteDef>Mote_Wula_Dark_Matter_Beam</beamMoteDef>
|
||||||
|
<beamEndEffecterDef>GraserBeam_End</beamEndEffecterDef>
|
||||||
|
|
||||||
|
<screenShakeFactor>0.35</screenShakeFactor>
|
||||||
|
|
||||||
|
<!-- 火焰效果 -->
|
||||||
|
<beamChanceToStartFire>0.6</beamChanceToStartFire>
|
||||||
|
<beamChanceToAttachFire>0.6</beamChanceToAttachFire>
|
||||||
|
<beamFireSizeRange>0.25</beamFireSizeRange>
|
||||||
|
|
||||||
|
<!-- 其他射线属性 -->
|
||||||
|
<beamHitsNeighborCells>true</beamHitsNeighborCells>
|
||||||
|
<beamLineFleckChanceCurve>
|
||||||
|
<points>
|
||||||
|
<li>(0, 0)</li>
|
||||||
|
<li>(0.65, 0.4)</li>
|
||||||
|
<li>(1, 0.75)</li>
|
||||||
|
</points>
|
||||||
|
</beamLineFleckChanceCurve>
|
||||||
|
|
||||||
|
<!-- 攻击目标设置 -->
|
||||||
|
<targetParams>
|
||||||
|
<canTargetLocations>true</canTargetLocations>
|
||||||
|
</targetParams>
|
||||||
|
|
||||||
|
<!-- 每发都爆炸 -->
|
||||||
|
<enableExplosion>false</enableExplosion>
|
||||||
|
<!--<explosionShotInterval>1</explosionShotInterval>
|
||||||
|
<explosionRadius>1.8</explosionRadius>
|
||||||
|
<explosionDamageDef>Wula_Dark_Matter_Flame</explosionDamageDef>
|
||||||
|
<explosionDamage>15</explosionDamage>
|
||||||
|
<explosionSound>Explosion_Bomb</explosionSound>
|
||||||
|
<chanceToStartFire>0.6</chanceToStartFire>-->
|
||||||
|
</li>
|
||||||
|
</verbs>
|
||||||
|
|
||||||
|
</ThingDef>
|
||||||
|
|
||||||
|
</Defs>
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "../../../../../../workshop/content/294100/3534748687"
|
"path": "../../../../../../workshop/content/294100/3534748687"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../../../../../../workshop/content/294100/3550544871"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {}
|
"settings": {}
|
||||||
|
|||||||
19
Source/WulaFallenEmpire/MechWeapon/CompMechWeapon.cs
Normal file
19
Source/WulaFallenEmpire/MechWeapon/CompMechWeapon.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
public class CompMechWeapon : ThingComp
|
||||||
|
{
|
||||||
|
// You can add custom logic or fields here if needed for this component.
|
||||||
|
// For now, it primarily serves as a marker for mechanical units that can use MechWeapon features.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class CompProperties_MechWeapon : CompProperties
|
||||||
|
{
|
||||||
|
public CompProperties_MechWeapon()
|
||||||
|
{
|
||||||
|
compClass = typeof(CompMechWeapon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
35
Source/WulaFallenEmpire/MechWeapon/FloatMenuProvider_Mech.cs
Normal file
35
Source/WulaFallenEmpire/MechWeapon/FloatMenuProvider_Mech.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using Verse.AI;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
public class FloatMenuProvider_Mech : FloatMenuOptionProvider
|
||||||
|
{
|
||||||
|
protected override bool Drafted => true;
|
||||||
|
|
||||||
|
protected override bool Undrafted => true;
|
||||||
|
|
||||||
|
protected override bool Multiselect => false;
|
||||||
|
|
||||||
|
protected override bool MechanoidCanDo => true;
|
||||||
|
|
||||||
|
public override bool SelectedPawnValid(Pawn pawn, FloatMenuContext context)
|
||||||
|
{
|
||||||
|
return base.SelectedPawnValid(pawn, context) && pawn.HasComp<CompMechWeapon>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<FloatMenuOption> GetOptionsFor(Thing clickedThing, FloatMenuContext context)
|
||||||
|
{
|
||||||
|
Pawn pawn = context.FirstSelectedPawn;
|
||||||
|
if (clickedThing.def.IsWeapon && pawn.CanReserveAndReach(clickedThing, PathEndMode.Touch, Danger.Deadly))
|
||||||
|
{
|
||||||
|
yield return new FloatMenuOption("Equip".Translate(clickedThing.Label), delegate
|
||||||
|
{
|
||||||
|
pawn.jobs.StartJob(JobMaker.MakeJob(JobDefOf.Equip, clickedThing));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
19
Source/WulaFallenEmpire/MechWeapon/Patch_MissingWeapon.cs
Normal file
19
Source/WulaFallenEmpire/MechWeapon/Patch_MissingWeapon.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(MechRepairUtility), "IsMissingWeapon")]
|
||||||
|
public class Patch_MissingWeapon
|
||||||
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void PostFix(ref bool __result, Pawn mech)
|
||||||
|
{
|
||||||
|
if (mech.HasComp<CompMechWeapon>())
|
||||||
|
{
|
||||||
|
__result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
Source/WulaFallenEmpire/MechWeapon/Patch_WeaponDrop.cs
Normal file
53
Source/WulaFallenEmpire/MechWeapon/Patch_WeaponDrop.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(Pawn), "DropAndForbidEverything")]
|
||||||
|
public class Patch_WeaponDrop
|
||||||
|
{
|
||||||
|
[HarmonyPrefix]
|
||||||
|
private static bool PreFix(ref Pawn __instance, bool keepInventoryAndEquipmentIfInBed, bool rememberPrimary)
|
||||||
|
{
|
||||||
|
if (__instance.HasComp<CompMechWeapon>())
|
||||||
|
{
|
||||||
|
if (!__instance.InContainerEnclosed)
|
||||||
|
{
|
||||||
|
if (__instance.SpawnedOrAnyParentSpawned)
|
||||||
|
{
|
||||||
|
if (__instance.carryTracker?.CarriedThing != null)
|
||||||
|
{
|
||||||
|
__instance.carryTracker.TryDropCarriedThing(__instance.PositionHeld, ThingPlaceMode.Near, out var _);
|
||||||
|
}
|
||||||
|
if (!keepInventoryAndEquipmentIfInBed || !__instance.InBed())
|
||||||
|
{
|
||||||
|
__instance.equipment?.DropAllEquipment(__instance.PositionHeld, forbid: true, rememberPrimary);
|
||||||
|
if (__instance.inventory != null && __instance.inventory.innerContainer.TotalStackCount > 0)
|
||||||
|
{
|
||||||
|
__instance.inventory.DropAllNearPawn(__instance.PositionHeld, forbid: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (__instance.carryTracker?.CarriedThing != null)
|
||||||
|
{
|
||||||
|
__instance.carryTracker.innerContainer.TryTransferToContainer(__instance.carryTracker.CarriedThing, __instance.holdingOwner);
|
||||||
|
}
|
||||||
|
if (__instance.equipment?.Primary != null)
|
||||||
|
{
|
||||||
|
__instance.equipment.TryTransferEquipmentToContainer(__instance.equipment.Primary, __instance.holdingOwner);
|
||||||
|
}
|
||||||
|
Pawn_InventoryTracker inventory = __instance.inventory;
|
||||||
|
if (inventory == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inventory.innerContainer.TryTransferAllToContainer(__instance.holdingOwner);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
public class VerbProperties_WeaponStealBeam : VerbPropertiesExplosiveBeam
|
||||||
|
{
|
||||||
|
public HediffDef hediffToApply;
|
||||||
|
public float hediffSeverityPerHit = 0.1f; // 每次命中增加的严重性百分比
|
||||||
|
public float hediffMaxSeverity = 1.0f; // 达到此严重性时触发抢夺
|
||||||
|
public bool removeHediffOnSteal = true; // 抢夺后是否移除hediff
|
||||||
|
|
||||||
|
public VerbProperties_WeaponStealBeam()
|
||||||
|
{
|
||||||
|
verbClass = typeof(Verb_ShootWeaponStealBeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
167
Source/WulaFallenEmpire/Verb/Verb_ShootWeaponStealBeam.cs
Normal file
167
Source/WulaFallenEmpire/Verb/Verb_ShootWeaponStealBeam.cs
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
using RimWorld;
|
||||||
|
using Verse;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine; // For Vector3
|
||||||
|
using Verse.Sound; // For SoundDef.PlayOneShot
|
||||||
|
using Verse.AI; // For JobQueue
|
||||||
|
|
||||||
|
namespace WulaFallenEmpire
|
||||||
|
{
|
||||||
|
public class Verb_ShootWeaponStealBeam : Verse.Verb_ShootBeam
|
||||||
|
{
|
||||||
|
private int explosionShotCounter = 0;
|
||||||
|
|
||||||
|
protected VerbProperties_WeaponStealBeam StealBeamVerbProps => (VerbProperties_WeaponStealBeam)verbProps;
|
||||||
|
|
||||||
|
protected override bool TryCastShot()
|
||||||
|
{
|
||||||
|
bool result = base.TryCastShot();
|
||||||
|
|
||||||
|
// 如果光束命中,对目标Pawn施加Hediff并检查是否抢夺武器
|
||||||
|
if (result && currentTarget.Thing is Pawn targetPawn && targetPawn.RaceProps.Humanlike) // 只对人形Pawn生效
|
||||||
|
{
|
||||||
|
ApplyHediffAndCheckForSteal(targetPawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
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, // 我们手动处理音效
|
||||||
|
screenShakeFactor: explosiveProps.screenShakeFactor // 新增:屏幕震动因子
|
||||||
|
);
|
||||||
|
|
||||||
|
// 在这里添加武器抢夺和Hediff施加的逻辑(爆炸命中目标时)
|
||||||
|
if (currentTarget.Thing is Pawn targetPawn && targetPawn.RaceProps.Humanlike) // 只对人形Pawn生效
|
||||||
|
{
|
||||||
|
ApplyHediffAndCheckForSteal(targetPawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成额外的视觉效果
|
||||||
|
if (explosiveProps.explosionEffecter != null)
|
||||||
|
{
|
||||||
|
Effecter effecter = explosiveProps.explosionEffecter.Spawn(explosionCell, caster.Map);
|
||||||
|
effecter.Trigger(new TargetInfo(explosionCell, caster.Map), TargetInfo.Invalid);
|
||||||
|
effecter.Cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyHediffAndCheckForSteal(Pawn targetPawn)
|
||||||
|
{
|
||||||
|
if (StealBeamVerbProps.hediffToApply == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hediff hediff = targetPawn.health.hediffSet.GetFirstHediffOfDef(StealBeamVerbProps.hediffToApply);
|
||||||
|
|
||||||
|
if (hediff == null)
|
||||||
|
{
|
||||||
|
hediff = HediffMaker.MakeHediff(StealBeamVerbProps.hediffToApply, targetPawn);
|
||||||
|
targetPawn.health.AddHediff(hediff);
|
||||||
|
}
|
||||||
|
|
||||||
|
hediff.Severity += StealBeamVerbProps.hediffSeverityPerHit;
|
||||||
|
|
||||||
|
if (hediff.Severity >= StealBeamVerbProps.hediffMaxSeverity)
|
||||||
|
{
|
||||||
|
TryStealWeapon(targetPawn);
|
||||||
|
if (StealBeamVerbProps.removeHediffOnSteal)
|
||||||
|
{
|
||||||
|
targetPawn.health.RemoveHediff(hediff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TryStealWeapon(Pawn targetPawn)
|
||||||
|
{
|
||||||
|
if (!CasterIsPawn || CasterPawn == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取目标Pawn的装备武器
|
||||||
|
ThingWithComps targetWeapon = targetPawn.equipment?.Primary;
|
||||||
|
|
||||||
|
if (targetWeapon != null)
|
||||||
|
{
|
||||||
|
// 将武器从目标Pawn身上移除
|
||||||
|
targetPawn.equipment.Remove(targetWeapon);
|
||||||
|
|
||||||
|
// 将武器添加到发射者(宿主)的库存中
|
||||||
|
if (!CasterPawn.inventory.innerContainer.TryAdd(targetWeapon))
|
||||||
|
{
|
||||||
|
// 如果无法添加到库存,则尝试丢弃在地上
|
||||||
|
GenPlace.TryPlaceThing(targetWeapon, CasterPawn.Position, CasterPawn.Map, ThingPlaceMode.Near);
|
||||||
|
return; // 如果丢弃了,就不尝试装备了
|
||||||
|
}
|
||||||
|
|
||||||
|
// 让发射者装备该武器
|
||||||
|
if (CasterPawn.equipment.Primary == null || CasterPawn.equipment.Primary.def != targetWeapon.def)
|
||||||
|
{
|
||||||
|
CasterPawn.jobs.StartJob(JobMaker.MakeJob(JobDefOf.Equip, targetWeapon), JobCondition.InterruptForced);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ExposeData()
|
||||||
|
{
|
||||||
|
base.ExposeData();
|
||||||
|
Scribe_Values.Look(ref explosionShotCounter, "explosionShotCounter", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<LangVersion>8.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>false</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
@@ -170,6 +170,12 @@
|
|||||||
<Compile Include="WULA_Shuttle\ArmedShuttleIncoming.cs" />
|
<Compile Include="WULA_Shuttle\ArmedShuttleIncoming.cs" />
|
||||||
<Compile Include="WULA_Shuttle\Building_ArmedShuttle.cs" />
|
<Compile Include="WULA_Shuttle\Building_ArmedShuttle.cs" />
|
||||||
<Compile Include="HarmonyPatches\Patch_DropCellFinder_SkyfallerCanLandAt.cs" />
|
<Compile Include="HarmonyPatches\Patch_DropCellFinder_SkyfallerCanLandAt.cs" />
|
||||||
|
<Compile Include="MechWeapon\FloatMenuProvider_Mech.cs" />
|
||||||
|
<Compile Include="MechWeapon\Patch_MissingWeapon.cs" />
|
||||||
|
<Compile Include="MechWeapon\Patch_WeaponDrop.cs" />
|
||||||
|
<Compile Include="MechWeapon\CompMechWeapon.cs" />
|
||||||
|
<Compile Include="Verb\VerbProperties_WeaponStealBeam.cs" />
|
||||||
|
<Compile Include="Verb\Verb_ShootWeaponStealBeam.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|||||||
Reference in New Issue
Block a user