Implemented mana regeneration
This commit is contained in:
@@ -125,7 +125,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="addons\" />
|
<Folder Include="addons\" />
|
||||||
<Folder Include="forge\" />
|
|
||||||
<Folder Include="tests\" />
|
<Folder Include="tests\" />
|
||||||
<Folder Include="tools\" />
|
<Folder Include="tools\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using Godot;
|
|||||||
namespace Movementtests.forge.abilities;
|
namespace Movementtests.forge.abilities;
|
||||||
|
|
||||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_animation.png")]
|
[GlobalClass, Icon("res://assets/ui/IconGodotNode/white/icon_animation.png")]
|
||||||
public partial class REmpoweredAction(float cost, float cooldown) : Resource
|
public partial class REmpoweredAction(float cost, float cooldown, float manaRegenPause) : Resource
|
||||||
{
|
{
|
||||||
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
[Export(PropertyHint.Range, "0,100,1,or_greater")]
|
||||||
public float Cost { get; set; } = cost;
|
public float Cost { get; set; } = cost;
|
||||||
@@ -18,7 +18,10 @@ public partial class REmpoweredAction(float cost, float cooldown) : Resource
|
|||||||
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||||
public float Cooldown { get; set; } = cooldown;
|
public float Cooldown { get; set; } = cooldown;
|
||||||
|
|
||||||
public REmpoweredAction() : this(20.0f, 1.0f)
|
[Export(PropertyHint.Range, "0,10,0.1,or_greater")]
|
||||||
|
public float ManaRegenPause { get; set; } = manaRegenPause;
|
||||||
|
|
||||||
|
public REmpoweredAction() : this(20.0f, 1.0f, 3.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
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
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://scenes/components/damage/RDamage.cs" id="2_x835q"]
|
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://scenes/components/damage/RDamage.cs" id="2_x835q"]
|
||||||
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://scenes/components/knockback/RKnockback.cs" id="3_cb2lu"]
|
[ext_resource type="Script" uid="uid://b44cse62qru7j" path="res://scenes/components/knockback/RKnockback.cs" id="3_cb2lu"]
|
||||||
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://inputs/base_mode/base_mode.tres" id="3_cresl"]
|
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://inputs/base_mode/base_mode.tres" id="3_cresl"]
|
||||||
|
[ext_resource type="Resource" uid="uid://dtmhtlix2amme" path="res://scenes/player_controller/resources/player_mana_regen.tres" id="3_n24vh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c4ikbhojckpnc" path="res://scenes/components/health/CHealth.tscn" id="3_q7bng"]
|
[ext_resource type="PackedScene" uid="uid://c4ikbhojckpnc" path="res://scenes/components/health/CHealth.tscn" id="3_q7bng"]
|
||||||
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://scenes/components/health/RHealth.cs" id="4_abfq8"]
|
[ext_resource type="Script" uid="uid://baiapod3csndf" path="res://scenes/components/health/RHealth.cs" id="4_abfq8"]
|
||||||
[ext_resource type="Resource" uid="uid://bjyd801wvverk" path="res://scenes/player_controller/resources/player_health.tres" id="4_m8gvy"]
|
[ext_resource type="Resource" uid="uid://bjyd801wvverk" path="res://scenes/player_controller/resources/player_health.tres" id="4_m8gvy"]
|
||||||
@@ -113,6 +114,8 @@ blend_mode = 1
|
|||||||
[node name="Player" type="CharacterBody3D" unique_id=709076448]
|
[node name="Player" type="CharacterBody3D" unique_id=709076448]
|
||||||
collision_mask = 272
|
collision_mask = 272
|
||||||
script = ExtResource("1_poq2x")
|
script = ExtResource("1_poq2x")
|
||||||
|
EmpoweredAction = ExtResource("7_qheee")
|
||||||
|
ManaRegen = ExtResource("3_n24vh")
|
||||||
AimAssistStrength = 0.3
|
AimAssistStrength = 0.3
|
||||||
AimAssistReductionWhenCloseToTarget = 0.1
|
AimAssistReductionWhenCloseToTarget = 0.1
|
||||||
AimAssistReductionStartDistance = 8.0
|
AimAssistReductionStartDistance = 8.0
|
||||||
@@ -163,7 +166,6 @@ MinimumWallRunUpwardSpeed = 4.0
|
|||||||
MinimumWallRunHorizontalSpeed = 8.0
|
MinimumWallRunHorizontalSpeed = 8.0
|
||||||
WallRunAltitudeLossSpeed = 8.0
|
WallRunAltitudeLossSpeed = 8.0
|
||||||
WallRunSpeedThreshold = 1.0
|
WallRunSpeedThreshold = 1.0
|
||||||
EmpoweredAction = ExtResource("7_qheee")
|
|
||||||
|
|
||||||
[node name="CHealth" parent="." unique_id=1244478698 instance=ExtResource("3_q7bng")]
|
[node name="CHealth" parent="." unique_id=1244478698 instance=ExtResource("3_q7bng")]
|
||||||
RHealth = ExtResource("4_m8gvy")
|
RHealth = ExtResource("4_m8gvy")
|
||||||
|
|||||||
@@ -6,4 +6,5 @@
|
|||||||
script = ExtResource("1_1rxoq")
|
script = ExtResource("1_1rxoq")
|
||||||
Cost = 50.0
|
Cost = 50.0
|
||||||
Cooldown = 1.0
|
Cooldown = 1.0
|
||||||
|
ManaRegenPause = 3.0
|
||||||
metadata/_custom_type_script = "uid://d0l07gcx1ef18"
|
metadata/_custom_type_script = "uid://d0l07gcx1ef18"
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
[gd_resource type="Resource" script_class="RManaRegen" format=3 uid="uid://dtmhtlix2amme"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://di04jvuqp0h7m" path="res://forge/effects/RManaRegen.cs" id="1_ecb1p"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_ecb1p")
|
||||||
|
ManaRegenRate = 20.0
|
||||||
|
Frequency = 0.1
|
||||||
|
metadata/_custom_type_script = "uid://di04jvuqp0h7m"
|
||||||
@@ -3,9 +3,6 @@ using System.Collections.Generic;
|
|||||||
using Gamesmiths.Forge.Abilities;
|
using Gamesmiths.Forge.Abilities;
|
||||||
using Gamesmiths.Forge.Core;
|
using Gamesmiths.Forge.Core;
|
||||||
using Gamesmiths.Forge.Effects;
|
using Gamesmiths.Forge.Effects;
|
||||||
using Gamesmiths.Forge.Effects.Components;
|
|
||||||
using Gamesmiths.Forge.Effects.Duration;
|
|
||||||
using Gamesmiths.Forge.Effects.Magnitudes;
|
|
||||||
using Gamesmiths.Forge.Events;
|
using Gamesmiths.Forge.Events;
|
||||||
using Gamesmiths.Forge.Tags;
|
using Gamesmiths.Forge.Tags;
|
||||||
|
|
||||||
@@ -19,7 +16,7 @@ using Movementtests.player_controller.Scripts;
|
|||||||
using Movementtests.scenes.player_controller.scripts;
|
using Movementtests.scenes.player_controller.scripts;
|
||||||
using Movementtests.tools;
|
using Movementtests.tools;
|
||||||
using Movementtests.forge.abilities;
|
using Movementtests.forge.abilities;
|
||||||
|
using Movementtests.tools.effects;
|
||||||
using RustyOptions;
|
using RustyOptions;
|
||||||
|
|
||||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png")]
|
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png")]
|
||||||
@@ -100,6 +97,12 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
[Export] public bool HasSword { get; set; } = true;
|
[Export] public bool HasSword { get; set; } = true;
|
||||||
[Export] public bool HasParry { get; set; } = true;
|
[Export] public bool HasParry { get; set; } = true;
|
||||||
|
|
||||||
|
// Forge stuff
|
||||||
|
[ExportCategory("Forge")]
|
||||||
|
[ExportGroup("General")]
|
||||||
|
[Export] public REmpoweredAction EmpoweredAction = null!;
|
||||||
|
[Export] public RManaRegen ManaRegen = null!;
|
||||||
|
|
||||||
// Combat stuff
|
// Combat stuff
|
||||||
[ExportCategory("Combat")]
|
[ExportCategory("Combat")]
|
||||||
[ExportGroup("General")]
|
[ExportGroup("General")]
|
||||||
@@ -408,8 +411,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
private Camera3D _camera = null!;
|
private Camera3D _camera = null!;
|
||||||
|
|
||||||
private AbilityHandle? _empoweredActionHandle;
|
private AbilityHandle? _empoweredActionHandle;
|
||||||
|
private ActiveEffectHandle? _manaRegenEffectHandle;
|
||||||
[Export] public REmpoweredAction EmpoweredAction = null!;
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -454,6 +456,9 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
abilityLevel: 1,
|
abilityLevel: 1,
|
||||||
levelOverridePolicy: LevelComparison.None,
|
levelOverridePolicy: LevelComparison.None,
|
||||||
sourceEntity: this);
|
sourceEntity: this);
|
||||||
|
|
||||||
|
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(), new EffectOwnership(this, this));
|
||||||
|
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
|
||||||
|
|
||||||
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
|
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
|
||||||
var mana = Attributes["PlayerAttributeSet.Mana"].CurrentValue; // 100
|
var mana = Attributes["PlayerAttributeSet.Mana"].CurrentValue; // 100
|
||||||
@@ -1967,6 +1972,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
public void PerformEmpoweredAction()
|
public void PerformEmpoweredAction()
|
||||||
{
|
{
|
||||||
if(_empoweredActionHandle == null) return;
|
if(_empoweredActionHandle == null) return;
|
||||||
|
|
||||||
var canActivate = _empoweredActionHandle.Activate(out var failures);
|
var canActivate = _empoweredActionHandle.Activate(out var failures);
|
||||||
if (!canActivate)
|
if (!canActivate)
|
||||||
{
|
{
|
||||||
@@ -1979,6 +1985,11 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
GD.Print($"Remaining mana: {Attributes["PlayerAttributeSet.Mana"].CurrentValue}");
|
GD.Print($"Remaining mana: {Attributes["PlayerAttributeSet.Mana"].CurrentValue}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inhibit Mana Regeneration for a while after using an empowered action
|
||||||
|
// TODO: Use Forge events instead of relying on direct referencing
|
||||||
|
_manaRegenEffectHandle!.SetInhibit(true);
|
||||||
|
GetTree().CreateTimer(EmpoweredAction.ManaRegenPause).Timeout += () => {_manaRegenEffectHandle!.SetInhibit(false);};
|
||||||
|
|
||||||
_isWallJumpAvailable = true;
|
_isWallJumpAvailable = true;
|
||||||
_canDashAirborne = true;
|
_canDashAirborne = true;
|
||||||
EmpoweredActionsLeft--;
|
EmpoweredActionsLeft--;
|
||||||
@@ -2304,6 +2315,7 @@ public partial class PlayerController : CharacterBody3D,
|
|||||||
LookAround(delta);
|
LookAround(delta);
|
||||||
|
|
||||||
EffectsManager.UpdateEffects(delta);
|
EffectsManager.UpdateEffects(delta);
|
||||||
|
GD.Print(Attributes["PlayerAttributeSet.Mana"].CurrentValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user