diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml
index d73d1e21..31574596 100644
--- a/.gitea/workflows/main.yaml
+++ b/.gitea/workflows/main.yaml
@@ -38,22 +38,30 @@ jobs:
PRERELEASE: false
INITIAL_VERSION: 0.1.0
DEFAULT_BUMP: patch
-
+
# Test:
# runs-on: godot
-## env:
-## RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
+# env:
+# RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
# steps:
# - name: Checkout with LFS
# uses: https://git.game-dev.space/minimata/checkout-with-lfs.git@main
-#
+#
# - name: Setup Godot
# id: setup-godot
# uses: https://git.game-dev.space/minimata/setup-godot.git@main
# with:
# godot-version: ${GODOT_VERSION}
# dotnet-version: ${DOTNET_VERSION}
-#
+#
+# - name: 🔬 Verify Setup
+# run: |
+# dotnet --version
+# ${{ steps.setup-godot.outputs.godot_bin }} --version
+#
+# - name: 🧑🔬 Generate .NET Bindings
+# run: ${{ steps.setup-godot.outputs.godot_bin }} --headless --build-solutions --quit || exit 0
+#
# - name: Run C# Tests
# env:
# GODOT_BIN: ${{ steps.setup-godot.outputs.godot_bin }}
@@ -61,19 +69,74 @@ jobs:
# run: |
# dotnet test --no-build --settings .runsettings --results-directory ./reports --logger "console;verbosity=normal" --logger "trx;LogFileName=results.xml" -- GdUnit4.Parameters="--verbose --headless --import"
#
-## - name: Run tests
-## uses: godot-gdunit-labs/gdUnit4-action@v1
-## with:
-## godot-version: ${GODOT_VERSION}
-## godot-net: true
-## godot-force-mono: true
-## dotnet-version: ${DOTNET_VERSION}
-## paths: |
-## res://tests/
-## publish-report: false
-## upload-report: false
-## console-verbosity: 'normal'
-## arguments: "--verbose --headless --import"
+# # - name: Run tests
+# # uses: godot-gdunit-labs/gdUnit4-action@v1
+# # with:
+# # godot-version: ${GODOT_VERSION}
+# # godot-net: true
+# # godot-force-mono: true
+# # dotnet-version: ${DOTNET_VERSION}
+# # paths: |
+# # res://tests/
+# # publish-report: false
+# # upload-report: false
+# # console-verbosity: 'normal'
+# # arguments: "--verbose --headless --import"
+#
+# - name: Upload test report
+# uses: actions/upload-artifact@v3-node20
+# with:
+# name: Test Report
+# path: ${{ github.workspace }}/reports/test-result.html
+#
+# OtherTest:
+# runs-on: godot
+# env:
+# RUNNER_TOOL_CACHE: /toolcache # Runner Tool Cache
+# steps:
+# - name: Checkout with LFS
+# uses: https://git.game-dev.space/minimata/checkout-with-lfs.git@main
+#
+# - uses: actions/setup-dotnet@v5
+# name: 💽 Setup .NET SDK
+# with:
+# dotnet-version: ${DOTNET_VERSION}
+#
+# - name: 📦 Restore Dependencies
+# run: |
+# dotnet --version
+# dotnet restore
+# dotnet build
+# dotnet list package
+#
+# - uses: chickensoft-games/setup-godot@v2
+# name: 🤖 Setup Godot
+# with:
+# # Version must include major, minor, and patch, and be >= 4.0.0
+# # Pre-release label is optional.
+# version: ${GODOT_VERSION}
+# # Use .NET-enabled version of Godot (the default is also true).
+# use-dotnet: true
+# # Include the Godot Export Templates (the default is false).
+# include-templates: true
+#
+# - name: 🔬 Verify Setup
+# run: |
+# dotnet --version
+# godot --version
+#
+# - name: 🧑🔬 Generate .NET Bindings
+# run: godot --headless --build-solutions --quit || exit 0
+#
+# - name: 🦺 Build Projects
+# run: dotnet build --configuration Release
+#
+# - name: Run C# Tests
+# env:
+# GODOT_BIN: godot
+# shell: bash
+# run: |
+# dotnet test --no-build --settings .runsettings --results-directory ./reports --logger "console;verbosity=normal" --logger "trx;LogFileName=results.xml" -- GdUnit4.Parameters="--verbose --headless --import"
#
# - name: Upload test report
# uses: actions/upload-artifact@v3-node20
diff --git a/Movement tests.csproj b/Movement tests.csproj
index ef39936d..f361e139 100644
--- a/Movement tests.csproj
+++ b/Movement tests.csproj
@@ -3,6 +3,8 @@
net9.0
true
Movementtests
+
+ CS9057
@@ -131,6 +133,13 @@
+
+
+
+
+
+
+
diff --git a/managers/InventoryManager.cs b/managers/InventoryManager.cs
index 8b920629..eec1b254 100644
--- a/managers/InventoryManager.cs
+++ b/managers/InventoryManager.cs
@@ -25,12 +25,9 @@ public partial class InventoryManager : Node
public delegate void WeaponEventAbilityRemovedEventHandler(WeaponEventAbilityData data);
public Dictionary> WeaponEventsInventory { get; } = [];
-
- public static InventoryManager Instance { get; private set; }
public override void _Ready()
{
- Instance = this;
WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet();
WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet();
WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet();
diff --git a/maps/_templates/MainSceneTemplate.cs b/maps/_templates/MainSceneTemplate.cs
index d9bdfdcb..9e3437a1 100644
--- a/maps/_templates/MainSceneTemplate.cs
+++ b/maps/_templates/MainSceneTemplate.cs
@@ -1,47 +1,68 @@
using Godot;
using System;
-using Movementtests.interfaces;
+using Chickensoft.AutoInject;
+using Chickensoft.Introspection;
+using Movementtests.interfaces;using Movementtests.managers;
using Movementtests.systems;
-public partial class MainSceneTemplate : Node3D
+[Meta(
+ typeof(IAutoOn),
+ typeof(IAutoConnect),
+ typeof(IProvider)
+)]
+public partial class MainSceneTemplate : Node3D, IProvide
{
- private Marker3D? _playerRespawnMarker;
+ public override void _Notification(int what) => this.Notify(what);
+
+ [Node("PlayerFellRespawn")] private Marker3D? PlayerRespawnMarker { get; set; }
private AnimationPlayer? _animationPlayer;
private Node3D? _respawnabble;
private Area3D? _playerFellPlane;
private Area3D? _deathPlane;
- public override void _Ready()
+ public required InventoryManager InventoryManager { get; set; }
+ InventoryManager IProvide.Value() => InventoryManager;
+
+ public void OnReady()
{
- _playerRespawnMarker = GetNode("PlayerFellRespawn");
_animationPlayer = GetNode("AnimationPlayer");
_playerFellPlane = GetNode("PlayerFellTP");
_deathPlane = GetNode("DeathPlane");
- if (_playerRespawnMarker == null) throw new Exception("Player respawn marker is null");
+ if (PlayerRespawnMarker == null) throw new Exception("Player respawn marker is null");
if (_animationPlayer == null) throw new Exception("Animation player is null");
if (_playerFellPlane == null) throw new Exception("Player reset plane is null");
if (_deathPlane == null) throw new Exception("Enemy death plane is null");
_playerFellPlane.BodyEntered += StartResetPlayerAnimation;
_deathPlane.BodyEntered += KillEnemy;
-
+
+ InventoryManager = new InventoryManager();
+ AddChild(InventoryManager);
+ this.Provide();
+ }
+
+ public void OnProvided()
+ {
+ // You can optionally implement this method. It gets called once you call
+ // this.Provide() to inform AutoInject that the provided values are now
+ // available.
}
public void ResetPlayerPosition()
{
- if (_respawnabble == null || _playerRespawnMarker == null) throw new Exception("Player or respawn marker is null");
- _respawnabble.GlobalPosition = _playerRespawnMarker.GlobalPosition;
+ if (_respawnabble == null || PlayerRespawnMarker == null) throw new Exception("Player or respawn marker is null");
+ _respawnabble.GlobalPosition = PlayerRespawnMarker.GlobalPosition;
}
public void StartResetPlayerAnimation(Node3D body)
{
if (body is WeaponSystem weapon)
{
- if (_playerRespawnMarker == null) throw new Exception("Respawn marker is null");
- weapon.GlobalPosition = _playerRespawnMarker.GlobalPosition;
+ if (PlayerRespawnMarker == null) throw new Exception("Respawn marker is null");
+ weapon.GlobalPosition = PlayerRespawnMarker.GlobalPosition;
weapon.SetLinearVelocity(Vector3.Down);
return;
}
diff --git a/menus/scenes/overlaid_menus/InventoryUi.cs b/menus/scenes/overlaid_menus/InventoryUi.cs
index ba1a9a81..bb6d786c 100644
--- a/menus/scenes/overlaid_menus/InventoryUi.cs
+++ b/menus/scenes/overlaid_menus/InventoryUi.cs
@@ -1,54 +1,67 @@
using System.Collections.Generic;
+using Chickensoft.AutoInject;
+using Chickensoft.Introspection;
using Gamesmiths.Forge.Effects;
using Gamesmiths.Forge.Godot.Resources.Abilities;
using Godot;
using Movementtests.managers;
using Movementtests.systems;
-[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png")]
+
+[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png"), Meta(typeof(IAutoNode))]
public partial class InventoryUi : Control
{
- private AbilitySelection _startedFlyingSelection;
- private AbilitySelection _whileFlyingSelection;
- private AbilitySelection _stoppedFlyingSelection;
+ public override void _Notification(int what) => this.Notify(what);
+
+ #region Dependencies
+ [Dependency]
+ public InventoryManager InventoryManager => this.DependOn();
+ #endregion Dependencies
- public override void _Ready()
+ #region Nodes
+ [Node]
+ public required AbilitySelection StartedFlying { get; set; }
+ [Node]
+ public required AbilitySelection WhileFlying { get; set; }
+ [Node]
+ public required AbilitySelection StoppedFlying { get; set; }
+ #endregion Nodes
+
+ public void OnReady()
{
- _startedFlyingSelection = GetNode("%StartedFlying");
- _whileFlyingSelection = GetNode("%WhileFlying");
- _stoppedFlyingSelection = GetNode("%StoppedFlying");
-
- _startedFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying]);
- _whileFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
- _stoppedFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
+ StartedFlying.AbilityAdded += AddAbilityForEvent;
+ WhileFlying.AbilityAdded += AddAbilityForEvent;
+ StoppedFlying.AbilityAdded += AddAbilityForEvent;
- _startedFlyingSelection.AbilityAdded += AddAbilityForEvent;
- _whileFlyingSelection.AbilityAdded += AddAbilityForEvent;
- _stoppedFlyingSelection.AbilityAdded += AddAbilityForEvent;
-
- _startedFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
- _whileFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
- _stoppedFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
-
- InventoryManager.Instance.WeaponEventAbilityAdded += OnWeaponEventInventoryAdded;
- InventoryManager.Instance.WeaponEventAbilityRemoved += OnWeaponEventInventoryRemoved;
+ StartedFlying.AbilityRemoved += RemoveAbilityForEvent;
+ WhileFlying.AbilityRemoved += RemoveAbilityForEvent;
+ StoppedFlying.AbilityRemoved += RemoveAbilityForEvent;
}
- public override void _ExitTree()
+ public void OnResolved()
{
- InventoryManager.Instance.WeaponEventAbilityAdded -= OnWeaponEventInventoryAdded;
- InventoryManager.Instance.WeaponEventAbilityRemoved -= OnWeaponEventInventoryRemoved;
- base._ExitTree();
+ StartedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying]);
+ WhileFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
+ StoppedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
+
+ InventoryManager.WeaponEventAbilityAdded += OnWeaponEventInventoryAdded;
+ InventoryManager.WeaponEventAbilityRemoved += OnWeaponEventInventoryRemoved;
+ }
+
+ public void OnExitTree()
+ {
+ InventoryManager.WeaponEventAbilityAdded -= OnWeaponEventInventoryAdded;
+ InventoryManager.WeaponEventAbilityRemoved -= OnWeaponEventInventoryRemoved;
}
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- InventoryManager.Instance.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
+ InventoryManager.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
}
public void RemoveAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
{
- InventoryManager.Instance.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
+ InventoryManager.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
}
public void OnWeaponEventInventoryAdded(WeaponEventAbilityData data)
@@ -71,9 +84,9 @@ public partial class InventoryUi : Control
{
var abilitiesSelectionsMap = new Dictionary
{
- { WeaponSystem.WeaponEvent.StartedFlying, _startedFlyingSelection },
- { WeaponSystem.WeaponEvent.StoppedFlying, _stoppedFlyingSelection },
- { WeaponSystem.WeaponEvent.FlyingTick, _whileFlyingSelection },
+ { WeaponSystem.WeaponEvent.StartedFlying, StartedFlying },
+ { WeaponSystem.WeaponEvent.StoppedFlying, StoppedFlying },
+ { WeaponSystem.WeaponEvent.FlyingTick, WhileFlying },
};
return abilitiesSelectionsMap[forEvent];
diff --git a/project.godot b/project.godot
index 7559bb6c..a11ac9fd 100644
--- a/project.godot
+++ b/project.godot
@@ -30,7 +30,6 @@ Shaker="*uid://c7flmumgr5w3u"
CsgToolkitAutoload="*uid://w8ad8q4lneis"
"Forge Bootstrap"="*uid://ba8fquhtwu5mu"
GlobalHelpers="*uid://dqcm83o8e66a2"
-InventoryManager="*uid://cgwhrwfqsiing"
[display]
diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs
index 12bf553e..40d60427 100644
--- a/scenes/player_controller/scripts/PlayerController.cs
+++ b/scenes/player_controller/scripts/PlayerController.cs
@@ -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();
+
// 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)
{