updating mana through cues
This commit is contained in:
@@ -10,13 +10,10 @@ public partial class ForgeManager : Node
|
|||||||
public TagsManager TagsManager { get; private set; } = new TagsManager(
|
public TagsManager TagsManager { get; private set; } = new TagsManager(
|
||||||
[
|
[
|
||||||
"character.player",
|
"character.player",
|
||||||
"class.warrior",
|
|
||||||
"status.stunned",
|
"status.stunned",
|
||||||
"status.burning",
|
|
||||||
"status.immune.fire",
|
|
||||||
"cues.damage.fire",
|
|
||||||
"events.combat.damage",
|
"events.combat.damage",
|
||||||
"events.combat.hit",
|
"events.combat.hit",
|
||||||
"cooldown.empoweredAction",
|
"cooldown.empoweredAction",
|
||||||
|
"cues.resources.mana",
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Gamesmiths.Forge.Abilities;
|
using Gamesmiths.Forge.Abilities;
|
||||||
|
using Gamesmiths.Forge.Cues;
|
||||||
using Gamesmiths.Forge.Effects;
|
using Gamesmiths.Forge.Effects;
|
||||||
using Gamesmiths.Forge.Effects.Components;
|
using Gamesmiths.Forge.Effects.Components;
|
||||||
using Gamesmiths.Forge.Effects.Duration;
|
using Gamesmiths.Forge.Effects.Duration;
|
||||||
@@ -25,7 +26,7 @@ public partial class REmpoweredAction(float cost, float cooldown, float manaRege
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EffectData CostEffect()
|
public EffectData CostEffect(TagsManager tagsManager)
|
||||||
{
|
{
|
||||||
return new(
|
return new(
|
||||||
"Empowered Action Mana Cost",
|
"Empowered Action Mana Cost",
|
||||||
@@ -40,6 +41,16 @@ public partial class REmpoweredAction(float cost, float cooldown, float manaRege
|
|||||||
new ScalableFloat(-Cost)
|
new ScalableFloat(-Cost)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
},
|
||||||
|
cues: new []
|
||||||
|
{
|
||||||
|
new CueData(
|
||||||
|
CueTags: Tag.RequestTag(tagsManager, "cues.resources.mana").GetSingleTagContainer(),
|
||||||
|
MinValue: 0,
|
||||||
|
MaxValue: 100,
|
||||||
|
MagnitudeType: CueMagnitudeType.AttributeValueChange,
|
||||||
|
MagnitudeAttribute: "PlayerAttributeSet.Mana"
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
using Gamesmiths.Forge.Cues;
|
||||||
using Gamesmiths.Forge.Effects;
|
using Gamesmiths.Forge.Effects;
|
||||||
using Gamesmiths.Forge.Effects.Duration;
|
using Gamesmiths.Forge.Effects.Duration;
|
||||||
using Gamesmiths.Forge.Effects.Magnitudes;
|
using Gamesmiths.Forge.Effects.Magnitudes;
|
||||||
using Gamesmiths.Forge.Effects.Modifiers;
|
using Gamesmiths.Forge.Effects.Modifiers;
|
||||||
using Gamesmiths.Forge.Effects.Periodic;
|
using Gamesmiths.Forge.Effects.Periodic;
|
||||||
|
using Gamesmiths.Forge.Tags;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Movementtests.tools.effects;
|
namespace Movementtests.tools.effects;
|
||||||
@@ -20,7 +22,7 @@ public partial class RManaRegen(float manaRegenRate, float frequency) : Resource
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EffectData ManaRegen()
|
public EffectData ManaRegen(TagsManager tagsManager)
|
||||||
{
|
{
|
||||||
return new EffectData(
|
return new EffectData(
|
||||||
"Mana Regen",
|
"Mana Regen",
|
||||||
@@ -36,6 +38,16 @@ public partial class RManaRegen(float manaRegenRate, float frequency) : Resource
|
|||||||
new ScalableFloat(ManaRegenRate * Frequency))
|
new ScalableFloat(ManaRegenRate * Frequency))
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
cues: new []
|
||||||
|
{
|
||||||
|
new CueData(
|
||||||
|
CueTags: Tag.RequestTag(tagsManager, "cues.resources.mana").GetSingleTagContainer(),
|
||||||
|
MinValue: 0,
|
||||||
|
MaxValue: 100,
|
||||||
|
MagnitudeType: CueMagnitudeType.AttributeValueChange,
|
||||||
|
MagnitudeAttribute: "PlayerAttributeSet.Mana"
|
||||||
|
)
|
||||||
|
},
|
||||||
periodicData: new PeriodicData(
|
periodicData: new PeriodicData(
|
||||||
Period: new ScalableFloat(Frequency),
|
Period: new ScalableFloat(Frequency),
|
||||||
ExecuteOnApplication: true,
|
ExecuteOnApplication: true,
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using Gamesmiths.Forge.Core;
|
||||||
|
using Gamesmiths.Forge.Cues;
|
||||||
|
using Gamesmiths.Forge.Tags;
|
||||||
using Movementtests.interfaces;
|
using Movementtests.interfaces;
|
||||||
|
using Movementtests.tools;
|
||||||
|
|
||||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
[GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_text_panel.png")]
|
||||||
public partial class PlayerUi : Control
|
public partial class PlayerUi : Control, ICueHandler
|
||||||
{
|
{
|
||||||
internal TextureRect[] DashIcons = new TextureRect[3];
|
internal TextureRect[] DashIcons = new TextureRect[3];
|
||||||
private TextureRect _enemyTarget = null!;
|
private TextureRect _enemyTarget = null!;
|
||||||
@@ -33,11 +37,17 @@ public partial class PlayerUi : Control
|
|||||||
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
|
_enemyTarget = GetNode<TextureRect>("%EnemyTarget");
|
||||||
_healthbar = GetNode<Healthbar>("%Healthbar");
|
_healthbar = GetNode<Healthbar>("%Healthbar");
|
||||||
_manabar = GetNode<Healthbar>("%Manabar");
|
_manabar = GetNode<Healthbar>("%Manabar");
|
||||||
|
|
||||||
|
var forgeManager = GetTree().Root.GetNode<ForgeManager>("ForgeManager")!;
|
||||||
|
var tagsManager = forgeManager.TagsManager;
|
||||||
|
var cuesManager = forgeManager.CuesManager;
|
||||||
|
cuesManager.RegisterCue(Tag.RequestTag(tagsManager, "cues.resources.mana"), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize(float initialHealth)
|
public void Initialize(float initialHealth, float initialMana)
|
||||||
{
|
{
|
||||||
_healthbar.Initialize(initialHealth);
|
_healthbar.Initialize(initialHealth);
|
||||||
|
_manabar.Initialize(initialMana);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetEnemyTargetProperties(TargetProperties targetProperties)
|
public void SetEnemyTargetProperties(TargetProperties targetProperties)
|
||||||
@@ -77,4 +87,38 @@ public partial class PlayerUi : Control
|
|||||||
{
|
{
|
||||||
_manabar.CurrentHealth = newValue;
|
_manabar.CurrentHealth = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnExecute(IForgeEntity? target, CueParameters? parameters)
|
||||||
|
{
|
||||||
|
// One-shot effect (like impact)
|
||||||
|
// Called when an instant effect with this cue is applied
|
||||||
|
// Also called when a periodic effect with this cue executes its period
|
||||||
|
|
||||||
|
if (target == null || !parameters.HasValue) return;
|
||||||
|
|
||||||
|
// Extract parameters
|
||||||
|
float magnitude = parameters.Value.Magnitude;
|
||||||
|
float normalizedMagnitude = parameters.Value.NormalizedMagnitude;
|
||||||
|
|
||||||
|
// Play effects scaled by magnitude
|
||||||
|
// PlayFireImpactSound(normalizedMagnitude);
|
||||||
|
// SpawnFireImpactParticles(target, magnitude);
|
||||||
|
GD.Print(_manabar.CurrentHealth);
|
||||||
|
_manabar.CurrentHealth += magnitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnApply(IForgeEntity? target, CueParameters? parameters)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnRemove(IForgeEntity? target, bool interrupted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnUpdate(IForgeEntity? target, CueParameters? parameters)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -433,8 +433,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
var baseTags = new TagContainer(
|
var baseTags = new TagContainer(
|
||||||
forgeManager.TagsManager,
|
forgeManager.TagsManager,
|
||||||
[
|
[
|
||||||
Tag.RequestTag(forgeManager.TagsManager, "character.player"),
|
Tag.RequestTag(forgeManager.TagsManager, "character.player")
|
||||||
Tag.RequestTag(forgeManager.TagsManager, "class.warrior")
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Attributes = new EntityAttributes(new PlayerAttributeSet());
|
Attributes = new EntityAttributes(new PlayerAttributeSet());
|
||||||
@@ -445,7 +444,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
|
|
||||||
var empoweredActionData = new AbilityData(
|
var empoweredActionData = new AbilityData(
|
||||||
name: "Empowered Action",
|
name: "Empowered Action",
|
||||||
costEffect: EmpoweredAction.CostEffect(),
|
costEffect: EmpoweredAction.CostEffect(forgeManager.TagsManager),
|
||||||
cooldownEffects: [EmpoweredAction.CooldownEffect(forgeManager.TagsManager)],
|
cooldownEffects: [EmpoweredAction.CooldownEffect(forgeManager.TagsManager)],
|
||||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||||
behaviorFactory: () => new EmpoweredActionBehavior());
|
behaviorFactory: () => new EmpoweredActionBehavior());
|
||||||
@@ -457,7 +456,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
levelOverridePolicy: LevelComparison.None,
|
levelOverridePolicy: LevelComparison.None,
|
||||||
sourceEntity: this);
|
sourceEntity: this);
|
||||||
|
|
||||||
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(), new EffectOwnership(this, this));
|
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(forgeManager.TagsManager), new EffectOwnership(this, this));
|
||||||
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
|
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
|
||||||
|
|
||||||
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
|
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
|
||||||
@@ -529,7 +528,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
}
|
}
|
||||||
if (RKnockback != null) CKnockback!.RKnockback = RKnockback;
|
if (RKnockback != null) CKnockback!.RKnockback = RKnockback;
|
||||||
|
|
||||||
PlayerUi.Initialize(CHealth.CurrentHealth);
|
PlayerUi.Initialize(CHealth.CurrentHealth, Attributes["PlayerAttributeSet.Mana"].BaseValue);
|
||||||
CDamageable.DamageTaken += (damageable, record) => ReduceHealth(damageable, record);
|
CDamageable.DamageTaken += (damageable, record) => ReduceHealth(damageable, record);
|
||||||
CDamageable.DamageTaken += (_, record) => RegisterKnockback(new KnockbackRecord(record));
|
CDamageable.DamageTaken += (_, record) => RegisterKnockback(new KnockbackRecord(record));
|
||||||
CHealth.HealthChanged += PlayerUi.OnHealthChanged;
|
CHealth.HealthChanged += PlayerUi.OnHealthChanged;
|
||||||
@@ -765,7 +764,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
{
|
{
|
||||||
RHealth.StartingHealth = newHealthValue;
|
RHealth.StartingHealth = newHealthValue;
|
||||||
CHealth!.CurrentHealth = newHealthValue;
|
CHealth!.CurrentHealth = newHealthValue;
|
||||||
PlayerUi.Initialize(CHealth.CurrentHealth);
|
PlayerUi.Initialize(CHealth.CurrentHealth, Attributes["PlayerAttributeSet.Mana"].BaseValue);
|
||||||
}
|
}
|
||||||
public void SetPlayerDamageOverride(float newDamageValue)
|
public void SetPlayerDamageOverride(float newDamageValue)
|
||||||
{
|
{
|
||||||
@@ -2309,7 +2308,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
HandleEnemyTargeting();
|
HandleEnemyTargeting();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float _oldMana = 100;
|
// private float _oldMana = 100;
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
// Manage head and camera movement
|
// Manage head and camera movement
|
||||||
@@ -2317,10 +2316,10 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
|
|
||||||
EffectsManager.UpdateEffects(delta);
|
EffectsManager.UpdateEffects(delta);
|
||||||
// TODO: change for actual Cue
|
// TODO: change for actual Cue
|
||||||
var currentMana = Attributes["PlayerAttributeSet.Mana"].CurrentValue;
|
// var currentMana = Attributes["PlayerAttributeSet.Mana"].CurrentValue;
|
||||||
if (Mathf.Abs(currentMana - _oldMana) > Mathf.Epsilon)
|
// if (Mathf.Abs(currentMana - _oldMana) > Mathf.Epsilon)
|
||||||
PlayerUi.OnManaChanged(currentMana);
|
// PlayerUi.OnManaChanged(currentMana);
|
||||||
_oldMana = currentMana;
|
// _oldMana = currentMana;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user