Inventory management of granted abilities

This commit is contained in:
2026-04-21 11:38:04 +02:00
parent 667d6b2588
commit b0fe2549ea
18 changed files with 322 additions and 92 deletions

View File

@@ -717,7 +717,8 @@ public partial class PlayerController : CharacterBody3D,
_parryDash.StateEntered += OnDashParryStarted;
// Inventory Management
InventoryManager.Instance.WeaponEventInventoryChanged += OnWeaponEventInventoryChanged;
InventoryManager.Instance.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
InventoryManager.Instance.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
// Forge events
var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStartedFlyingEventTag, OnWeaponLeft);
@@ -751,9 +752,18 @@ public partial class PlayerController : CharacterBody3D,
out var failures);
}
public void OnWeaponEventInventoryChanged(WeaponEventInventoryChangedData data)
public void OnWeaponEventAbilityAdded(WeaponEventAbilityData data)
{
WeaponSystem.GrantNewAbilityForEvent(data.ForEvent, WeaponExplosionBehavior);
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
WeaponSystem.GrantNewAbilityForEvent(data.ForEvent, abilityBehavior);
}
public void OnWeaponEventAbilityRemoved(WeaponEventAbilityData data)
{
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
WeaponSystem.RemoveAbilityForEvent(data.ForEvent, abilityBehavior);
}
///////////////////////////
@@ -1162,7 +1172,7 @@ public partial class PlayerController : CharacterBody3D,
var tween = GetTree().CreateTween();
tween.SetParallel();
tween.SetTrans(Tween.TransitionType.Cubic);
tween.SetEase(Tween.EaseType.InOut);
tween.SetEase(Tween.EaseType.In);
tween.TweenProperty(this, "global_position", targetLocation, tweenTime);
return tween;
@@ -2024,8 +2034,8 @@ public partial class PlayerController : CharacterBody3D,
public void OnAimingEntered()
{
if (!CanPerformEmpoweredAction())
return;
// if (!CanPerformEmpoweredAction())
// return;
// DashIndicatorMesh.Visible = true;
if (!isOnFloorCustom())
@@ -2039,8 +2049,8 @@ public partial class PlayerController : CharacterBody3D,
// DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
// DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
if (CanPerformEmpoweredAction())
DashSystem.PrepareDash();
// if (CanPerformEmpoweredAction())
DashSystem.PrepareDash();
}
public void OnAimingExited()
{
@@ -2490,22 +2500,23 @@ public partial class PlayerController : CharacterBody3D,
if (!HasSword) return;
if (_onWallHanging.Active) return;
if (_aiming.Active && WeaponSystem.InHandState.Active && CanPerformEmpoweredAction())
if (_aiming.Active && WeaponSystem.InHandState.Active)
{
ThrowWeapon();
return;
}
if (WeaponSystem.FlyingState.Active)
if (WeaponSystem.FlyingState.Active && CanPerformEmpoweredAction())
{
DashToFlyingWeapon();
return;
}
if (WeaponSystem.PlantedState.Active)
if (WeaponSystem.PlantedState.Active && CanPerformEmpoweredAction())
{
DashToPlantedWeapon();
return;
}
if (!WeaponSystem.InHandState.Active) return;
var attackToDo = _isEnemyInDashAttackRange ? "dash_attack" : "standard_attack";
_playerState.SendEvent(attackToDo);