暂存
This commit is contained in:
41
Source/ArachnaeSwarm/Verbs/Verb_ShootConsumeNutrition.cs
Normal file
41
Source/ArachnaeSwarm/Verbs/Verb_ShootConsumeNutrition.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user