Setup the base for abilities and events
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 24s
Create tag and build when new code gets to main / Export (push) Successful in 5m6s

This commit is contained in:
2026-03-22 16:28:57 +01:00
parent d1f83525b1
commit 7bf19868e7
17 changed files with 341 additions and 24 deletions

View File

@@ -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)
{
}
}
///////////////////////////