dependency injection test
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Attributes;
|
||||
using Gamesmiths.Forge.Core;
|
||||
@@ -35,7 +37,8 @@ using Node = Godot.Node;
|
||||
|
||||
public record struct EmpoweredActionPayload;
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png")]
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_character.png"), Meta(typeof(IAutoNode))]
|
||||
public partial class PlayerController : CharacterBody3D,
|
||||
IDamageable,
|
||||
IDamageDealer,
|
||||
@@ -43,6 +46,11 @@ public partial class PlayerController : CharacterBody3D,
|
||||
IKnockbackable,
|
||||
IForgeEntity
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency]
|
||||
public InventoryManager InventoryManager => this.DependOn<InventoryManager>();
|
||||
|
||||
// Enums
|
||||
public enum AllowedInputs
|
||||
{
|
||||
@@ -426,7 +434,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
private AbilityHandle? _empoweredActionHandle;
|
||||
|
||||
public override void _Ready()
|
||||
public void OnReady()
|
||||
{
|
||||
LoadSettings();
|
||||
|
||||
@@ -716,14 +724,20 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_parryStandard.StateEntered += OnStandardParryStarted;
|
||||
_parryDash.StateEntered += OnDashParryStarted;
|
||||
|
||||
// Inventory Management
|
||||
InventoryManager.Instance.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
||||
InventoryManager.Instance.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
||||
|
||||
// Forge events
|
||||
var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStartedFlyingEventTag, OnWeaponLeft);
|
||||
var weaponLandedToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStoppedFlyingEventTag, OnWeaponLanded);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
// All of my dependencies are now available! Do whatever you want with
|
||||
// them here.
|
||||
|
||||
// Inventory Management
|
||||
InventoryManager.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
||||
InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
||||
}
|
||||
|
||||
public void OnWeaponLeft(EventData data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user