Setup the base for abilities and events
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
[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="Script" uid="uid://rux15j7q78e8" path="res://forge/abilities/RExplodingSwordThrow.cs" id="4_11013"]
|
||||
[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://cpdaw41ah5gic" path="res://inputs/base_mode/rotate_y.tres" id="4_rxwoh"]
|
||||
@@ -18,7 +19,7 @@
|
||||
[ext_resource type="Resource" uid="uid://t612lts1wi1s" path="res://inputs/base_mode/move_right.tres" id="6_q7bng"]
|
||||
[ext_resource type="Script" uid="uid://cwbvxlfvmocc1" path="res://scenes/player_controller/scripts/StairsSystem.cs" id="7_bmt5a"]
|
||||
[ext_resource type="Resource" uid="uid://brswsknpgwal2" path="res://inputs/base_mode/move_front.tres" id="7_m8gvy"]
|
||||
[ext_resource type="Resource" uid="uid://7dpkk5rk3di5" path="res://scenes/player_controller/resources/forge_empowered_action.tres" id="7_qheee"]
|
||||
[ext_resource type="Resource" uid="uid://7dpkk5rk3di5" path="res://scenes/player_controller/resources/forge/empowered_action.tres" id="7_qheee"]
|
||||
[ext_resource type="PackedScene" uid="uid://bctpe34ddamg5" path="res://scenes/components/knockback/CKnockback.tscn" id="7_x835q"]
|
||||
[ext_resource type="Resource" uid="uid://s1l0n1iitc6m" path="res://inputs/base_mode/move_back.tres" id="8_jb43f"]
|
||||
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://inputs/base_mode/aim_release.tres" id="8_lhb11"]
|
||||
@@ -55,6 +56,12 @@
|
||||
[ext_resource type="Texture2D" uid="uid://c40orhfdgsim" path="res://assets/ui/IconGodotNode/white/icon_circle.png" id="45_u8rdp"]
|
||||
[ext_resource type="PackedScene" uid="uid://cyw8p0p6a78tl" path="res://scenes/ui/healthbar/healthbar.tscn" id="47_76kmc"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5b7hb"]
|
||||
script = ExtResource("4_11013")
|
||||
Explosion = ExtResource("5_ue7xq")
|
||||
Cost = 10.0
|
||||
metadata/_custom_type_script = "uid://rux15j7q78e8"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_cb2lu"]
|
||||
script = ExtResource("2_x835q")
|
||||
DamageDealt = 10.0
|
||||
@@ -119,6 +126,7 @@ collision_mask = 272
|
||||
script = ExtResource("1_poq2x")
|
||||
EmpoweredAction = ExtResource("7_qheee")
|
||||
ManaRegen = ExtResource("3_n24vh")
|
||||
AbilityLoadout = [SubResource("Resource_5b7hb")]
|
||||
AimAssistStrength = 0.3
|
||||
AimAssistReductionWhenCloseToTarget = 0.1
|
||||
AimAssistReductionStartDistance = 8.0
|
||||
|
||||
@@ -93,32 +93,25 @@ public partial class PlayerUi : Control, ICueHandler
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Gamesmiths.Forge.Attributes;
|
||||
|
||||
namespace Movementtests.scenes.player_controller.components.weapon;
|
||||
|
||||
public class WeaponAttributeSet : AttributeSet
|
||||
{
|
||||
public EntityAttribute Level { get; }
|
||||
|
||||
public WeaponAttributeSet()
|
||||
{
|
||||
Level = InitializeAttribute(nameof(Level), 1, 1, 10);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://mvc3bv0p021
|
||||
@@ -1,13 +1,21 @@
|
||||
using System;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Events;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
using GodotStateCharts;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.scenes.player_controller.components.weapon;
|
||||
using Movementtests.systems.damage;
|
||||
using Movementtests.tools;
|
||||
|
||||
namespace Movementtests.systems;
|
||||
|
||||
public record struct WeaponLandPayload(int Damage, bool IsCritical);
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_sword.png")]
|
||||
public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
{
|
||||
[Signal]
|
||||
public delegate void WeaponThrownEventHandler();
|
||||
@@ -22,6 +30,12 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
public float StraightThrowDuration { get; set; } = 0.1f;
|
||||
|
||||
public EntityAttributes Attributes { get; set; } = null!;
|
||||
public EntityTags Tags { get; set; } = null!;
|
||||
public EffectsManager EffectsManager { get; set; } = null!;
|
||||
public EntityAbilities Abilities { get; set; } = null!;
|
||||
public EventManager Events { get; set; } = null!;
|
||||
|
||||
private StateChart _weaponState = null!;
|
||||
public StateChartState InHandState = null!;
|
||||
public StateChartState FlyingState = null!;
|
||||
@@ -40,6 +54,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; } = null!;
|
||||
public MeshInstance3D WeaponMesh { get; set; } = null!;
|
||||
|
||||
public Tag WeaponLandTag;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_weaponState = StateChart.Of(GetNode("StateChart"));
|
||||
@@ -57,6 +73,22 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
_startTransform = Transform;
|
||||
Freeze = true;
|
||||
Visible = false;
|
||||
|
||||
var tagsManager = ForgeManager.GetTagsManager(this);
|
||||
var cuesManager = ForgeManager.GetCuesManager(this);
|
||||
var baseTags = new TagContainer(
|
||||
tagsManager,
|
||||
[
|
||||
Tag.RequestTag(tagsManager, "weapon")
|
||||
]);
|
||||
|
||||
Attributes = new EntityAttributes(new WeaponAttributeSet());
|
||||
Tags = new EntityTags(baseTags);
|
||||
EffectsManager = new EffectsManager(this, cuesManager);
|
||||
Abilities = new(this);
|
||||
Events = new();
|
||||
|
||||
WeaponLandTag = Tag.RequestTag(tagsManager, "events.weapon.land");
|
||||
|
||||
BodyEntered += OnThrownWeaponReachesGround;
|
||||
|
||||
@@ -109,11 +141,26 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
tween.Finished += ThrowWeaponOnCurve;
|
||||
}
|
||||
|
||||
public void RaiseWeaponLandEvent(IForgeEntity? victim = null)
|
||||
{
|
||||
Events.Raise(new EventData<WeaponLandPayload>
|
||||
{
|
||||
EventTags = WeaponLandTag.GetSingleTagContainer(),
|
||||
Source = this,
|
||||
Target = victim,
|
||||
EventMagnitude = 25f,
|
||||
Payload = new WeaponLandPayload(Damage: 25, IsCritical: true)
|
||||
});
|
||||
}
|
||||
|
||||
public void PlantInEnemy(Node3D enemy)
|
||||
{
|
||||
GetTree().GetRoot().CallDeferred(Node.MethodName.RemoveChild, this);
|
||||
enemy.CallDeferred(Node.MethodName.AddChild, this);
|
||||
|
||||
if (enemy is IForgeEntity victim) RaiseWeaponLandEvent(victim);
|
||||
else RaiseWeaponLandEvent();
|
||||
|
||||
if (enemy is IDamageable damageable)
|
||||
{
|
||||
damageable.TakeDamage(new DamageRecord(GlobalPosition, RDamage));
|
||||
@@ -145,6 +192,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer
|
||||
{
|
||||
PlantInEnemy(node);
|
||||
}
|
||||
else RaiseWeaponLandEvent();
|
||||
|
||||
CallDeferred(Node3D.MethodName.SetGlobalPosition, PlantLocation);
|
||||
CallDeferred(Node3D.MethodName.LookAt, GlobalTransform.Origin + PlantNormal, Vector3.Up, true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="RExplodingSwordThrow" format=3 uid="uid://cdxbwirfiaipi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rux15j7q78e8" path="res://forge/abilities/RExplodingSwordThrow.cs" id="1_5iq8v"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_5iq8v")
|
||||
Cost = 20.0
|
||||
metadata/_custom_type_script = "uid://rux15j7q78e8"
|
||||
@@ -3,6 +3,9 @@ using System.Collections.Generic;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Core;
|
||||
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.Tags;
|
||||
|
||||
@@ -102,6 +105,10 @@ public partial class PlayerController : CharacterBody3D,
|
||||
[ExportGroup("General")]
|
||||
[Export] public REmpoweredAction EmpoweredAction = null!;
|
||||
[Export] public RManaRegen ManaRegen = null!;
|
||||
|
||||
[ExportGroup("Abilities")]
|
||||
[ExportSubgroup("WeaponThrow")]
|
||||
[Export] public RAbilityBase[] AbilityLoadout = [];
|
||||
|
||||
// Combat stuff
|
||||
[ExportCategory("Combat")]
|
||||
@@ -429,26 +436,21 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_aimAssisRayCast.TargetPosition = _aimAssisRayCast.TargetPosition.Normalized() * (TargetingDistance*1.5f);
|
||||
|
||||
// Forge stuff
|
||||
var forgeManager = GetTree().Root.GetNode<ForgeManager>("ForgeManager")!;
|
||||
var tagsManager = ForgeManager.GetTagsManager(this);
|
||||
var cuesManager = ForgeManager.GetCuesManager(this);
|
||||
var baseTags = new TagContainer(
|
||||
forgeManager.TagsManager,
|
||||
tagsManager,
|
||||
[
|
||||
Tag.RequestTag(forgeManager.TagsManager, "character.player")
|
||||
Tag.RequestTag(tagsManager, "character.player")
|
||||
]);
|
||||
|
||||
Attributes = new EntityAttributes(new PlayerAttributeSet());
|
||||
Tags = new EntityTags(baseTags);
|
||||
EffectsManager = new EffectsManager(this, forgeManager.CuesManager);
|
||||
EffectsManager = new EffectsManager(this, cuesManager);
|
||||
Abilities = new(this);
|
||||
Events = new();
|
||||
|
||||
var empoweredActionData = new AbilityData(
|
||||
name: "Empowered Action",
|
||||
costEffect: EmpoweredAction.CostEffect(forgeManager.TagsManager),
|
||||
cooldownEffects: [EmpoweredAction.CooldownEffect(forgeManager.TagsManager)],
|
||||
instancingPolicy: AbilityInstancingPolicy.PerEntity,
|
||||
behaviorFactory: () => new EmpoweredActionBehavior());
|
||||
|
||||
var empoweredActionData = EmpoweredAction.Ability(tagsManager);
|
||||
// Grant permanently
|
||||
_empoweredActionHandle = Abilities.GrantAbilityPermanently(
|
||||
empoweredActionData,
|
||||
@@ -456,7 +458,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
levelOverridePolicy: LevelComparison.None,
|
||||
sourceEntity: this);
|
||||
|
||||
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(forgeManager.TagsManager), new EffectOwnership(this, this));
|
||||
var manaRegenEffect = new Effect(ManaRegen.ManaRegen(tagsManager), new EffectOwnership(this, this));
|
||||
_manaRegenEffectHandle = EffectsManager.ApplyEffect(manaRegenEffect);
|
||||
|
||||
var health = Attributes["PlayerAttributeSet.Health"].CurrentValue; // 100
|
||||
@@ -702,9 +704,47 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_attackDash.StateEntered += OnDashAttackStarted;
|
||||
_parryStandard.StateEntered += OnStandardParryStarted;
|
||||
_parryDash.StateEntered += OnDashParryStarted;
|
||||
|
||||
foreach (var weaponLandAbility in AbilityLoadout)
|
||||
{
|
||||
var grantAbilityConfig = new GrantAbilityConfig(
|
||||
weaponLandAbility.Ability(tagsManager, WeaponSystem),
|
||||
ScalableLevel: new ScalableInt(1),
|
||||
RemovalPolicy: AbilityDeactivationPolicy.CancelImmediately,
|
||||
InhibitionPolicy: AbilityDeactivationPolicy.CancelImmediately,
|
||||
TryActivateOnGrant: false,
|
||||
TryActivateOnEnable: false,
|
||||
LevelOverridePolicy: LevelComparison.Higher);
|
||||
|
||||
var grantComponent = new GrantAbilityEffectComponent([grantAbilityConfig]);
|
||||
var grantEffect = new EffectData(
|
||||
"Grant Weapon Land Ability",
|
||||
new DurationData(DurationType.Infinite),
|
||||
effectComponents: [grantComponent]);
|
||||
EffectsManager.ApplyEffect(new Effect(grantEffect, new EffectOwnership(this, this)));
|
||||
}
|
||||
|
||||
// Testing out kill
|
||||
// GetTree().CreateTimer(2).Timeout += () => Kill(this);
|
||||
// Forge events
|
||||
EventSubscriptionToken token = WeaponSystem.Events.Subscribe<WeaponLandPayload>(WeaponSystem.WeaponLandTag, OnWeaponLanded);
|
||||
}
|
||||
|
||||
public void OnWeaponLanded(EventData<WeaponLandPayload> data)
|
||||
{
|
||||
var source = data.Source;
|
||||
var target = data.Target;
|
||||
var magnitude = data.EventMagnitude;
|
||||
var weaponLandPayload = data.Payload;
|
||||
|
||||
var tagsManager = ForgeManager.GetTagsManager(this);
|
||||
var weaponLandTag = Tag.RequestTag(tagsManager, "abilities.weapon.land").GetSingleTagContainer();
|
||||
if (weaponLandTag == null) return;
|
||||
var anyActivated = Abilities.TryActivateAbilitiesByTag(
|
||||
weaponLandTag,
|
||||
target,
|
||||
out var failures);
|
||||
if (anyActivated)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user