This commit is contained in:
2025-09-24 12:08:27 +08:00
parent ae4a2e0f99
commit a76355fd83
10 changed files with 505 additions and 133 deletions

View File

@@ -0,0 +1,41 @@
using RimWorld;
using Verse;
namespace ArachnaeSwarm
{
public class Verb_ShootConsumeNutrition : Verb_Shoot
{
public override bool Available()
{
if (!base.Available())
{
return false;
}
if (verbProps.consumeFuelPerShot > 0f)
{
CompRefuelableNutrition comp = caster.TryGetComp<CompRefuelableNutrition>();
if (comp != null && comp.Fuel < verbProps.consumeFuelPerShot)
{
return false;
}
}
return true;
}
public override void WarmupComplete()
{
// This is a bit of a workaround. The base WarmupComplete calls TryCastNextBurstShot,
// which in turn calls the base Verb's fuel consumption logic before we can intervene.
// So we consume fuel here, and the base call will find it already consumed.
// This relies on the fact that TryCastNextBurstShot in the base Verb class checks fuel again.
if (verbProps.consumeFuelPerShot > 0f)
{
caster.TryGetComp<CompRefuelableNutrition>()?.ConsumeFuel(verbProps.consumeFuelPerShot);
}
base.WarmupComplete();
}
}
}