Implemented mana regeneration
This commit is contained in:
46
forge/effects/RManaRegen.cs
Normal file
46
forge/effects/RManaRegen.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Effects.Duration;
|
||||
using Gamesmiths.Forge.Effects.Magnitudes;
|
||||
using Gamesmiths.Forge.Effects.Modifiers;
|
||||
using Gamesmiths.Forge.Effects.Periodic;
|
||||
using Godot;
|
||||
|
||||
namespace Movementtests.tools.effects;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_liquid.png")]
|
||||
public partial class RManaRegen(float manaRegenRate, float frequency) : Resource
|
||||
{
|
||||
[Export(PropertyHint.Range, "0,100,0.1,or_greater")]
|
||||
public float ManaRegenRate { get; set; } = manaRegenRate;
|
||||
|
||||
[Export(PropertyHint.Range, "0.01,1,0.1,or_greater")]
|
||||
public float Frequency { get; set; } = frequency;
|
||||
|
||||
public RManaRegen() : this(1.0f, 0.1f)
|
||||
{
|
||||
}
|
||||
|
||||
public EffectData ManaRegen()
|
||||
{
|
||||
return new EffectData(
|
||||
"Mana Regen",
|
||||
durationData: new DurationData(
|
||||
DurationType.Infinite
|
||||
),
|
||||
modifiers: [
|
||||
new Modifier(
|
||||
"PlayerAttributeSet.Mana",
|
||||
ModifierOperation.FlatBonus,
|
||||
new ModifierMagnitude(
|
||||
MagnitudeCalculationType.ScalableFloat,
|
||||
new ScalableFloat(ManaRegenRate * Frequency))
|
||||
)
|
||||
],
|
||||
periodicData: new PeriodicData(
|
||||
Period: new ScalableFloat(Frequency),
|
||||
ExecuteOnApplication: true,
|
||||
PeriodInhibitionRemovedPolicy: PeriodInhibitionRemovedPolicy.ResetPeriod
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
1
forge/effects/RManaRegen.cs.uid
Normal file
1
forge/effects/RManaRegen.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://di04jvuqp0h7m
|
||||
Reference in New Issue
Block a user