75 lines
1.9 KiB
C#
75 lines
1.9 KiB
C#
using EinSoftworks.Events;
|
|
using EinSoftworks.Input;
|
|
using EinSoftworks.Movement;
|
|
using Godot;
|
|
using Voider.Player;
|
|
|
|
namespace Voider.Testing;
|
|
|
|
public partial class TestGameManager : Node
|
|
{
|
|
[Export]
|
|
public Label InfoLabel { get; set; }
|
|
|
|
[Export]
|
|
public Player.Player Player { get; set; }
|
|
|
|
private InputManager _inputManager;
|
|
private float _gameTime = 0f;
|
|
|
|
public override void _Ready()
|
|
{
|
|
// InputManager is initialized by the library itself
|
|
_inputManager = InputManager.Instance;
|
|
|
|
MovementEvents.StateChanged += OnStateChanged;
|
|
MovementEvents.PlayerJumped += OnPlayerJumped;
|
|
|
|
if (InfoLabel != null)
|
|
{
|
|
InfoLabel.Text =
|
|
"Library Integration Test\nPress ESC to toggle mouse capture\nWASD to move, Space to jump, Shift to sprint, Ctrl to crouch";
|
|
}
|
|
|
|
GD.Print("=== Library Integration Test Started ===");
|
|
GD.Print("All EinSoftworks libraries loaded successfully!");
|
|
}
|
|
|
|
public override void _Process(double delta)
|
|
{
|
|
_gameTime += (float)delta;
|
|
|
|
if (_inputManager != null && _inputManager.IsActionJustPressed("ui_home"))
|
|
{
|
|
ResetPlayer();
|
|
}
|
|
}
|
|
|
|
private void OnStateChanged(string state)
|
|
{
|
|
GD.Print($"[GameManager] Movement state: {state}");
|
|
}
|
|
|
|
private void OnPlayerJumped()
|
|
{
|
|
GD.Print($"[GameManager] Player jumped at time: {_gameTime:F2}s");
|
|
}
|
|
|
|
private void ResetPlayer()
|
|
{
|
|
if (Player != null)
|
|
{
|
|
Player.GlobalPosition = new Vector3(0, 2, 0);
|
|
Player.Velocity = Vector3.Zero;
|
|
GD.Print("Player reset to spawn position");
|
|
}
|
|
}
|
|
|
|
public override void _ExitTree()
|
|
{
|
|
MovementEvents.StateChanged -= OnStateChanged;
|
|
MovementEvents.PlayerJumped -= OnPlayerJumped;
|
|
MovementEvents.ClearAllSubscriptions();
|
|
}
|
|
}
|