add initial project files and configurations, including EventBus, systems, and resources

This commit is contained in:
2026-01-24 02:47:23 +01:00
commit bba82f64fd
110 changed files with 2735 additions and 0 deletions

View File

@@ -0,0 +1,96 @@
using Godot;
using MaxEffort.Code.Core;
using MaxEffort.Code.Data;
namespace MaxEffort.Code.Systems;
[GlobalClass]
public partial class GameManager : Node
{
[Export] private Godot.Collections.Array<DayConfig> _days;
[Export] private HazardSystem _hazardSystem;
[Export] private Node _minigameContainer;
[Export] private Control _winScreen;
[Export] private Control _loseScreen;
[Export] private Label _dayLabel;
private int _currentDayIndex = 0;
private Node _currentMiniGame;
public override void _Ready()
{
EventBus.OnLiftCompleted += HandleLiftResult;
StartDay(_currentDayIndex);
}
public override void _ExitTree()
{
EventBus.OnLiftCompleted -= HandleLiftResult;
}
private void StartDay(int index)
{
if (index >= _days.Count)
{
GD.Print("YOU BEAT THE GYM! ALL DAYS COMPLETE.");
// TODO: Show "Game Complete" screen
return;
}
var config = _days[index];
_currentMiniGame?.QueueFree();
_hazardSystem.ClearHazards();
if (config.MiniGameScene != null)
{
_currentMiniGame = config.MiniGameScene.Instantiate();
_minigameContainer.AddChild(_currentMiniGame);
var liftSystem = _currentMiniGame.GetNode<BaseLiftSystem>("System");
liftSystem?.Initialize(config.TargetWeight, config.Gravity);
}
_hazardSystem.SetAvailableHazards(config.AvailableHazards);
if (_dayLabel != null) _dayLabel.Text = config.DayTitle;
if (_winScreen != null) _winScreen.Visible = false;
if (_loseScreen != null) _loseScreen.Visible = false;
GD.Print($"Started {config.DayTitle}");
}
private void HandleLiftResult(bool success)
{
if (success)
{
GD.Print("Day Complete! Next day loading...");
if (_winScreen != null) _winScreen.Visible = true;
// Wait for player input to proceed, or auto-load after delay
// For now, let's auto-advance after 3 seconds for the prototype
GetTree().CreateTimer(3.0f).Timeout += () => NextDay();
}
else
{
GD.Print("FAIL! Go home.");
if (_loseScreen != null) _loseScreen.Visible = true;
// Restart day after delay
GetTree().CreateTimer(3.0f).Timeout += () => RestartDay();
}
}
private void NextDay()
{
_currentDayIndex++;
StartDay(_currentDayIndex);
}
private void RestartDay()
{
GetTree().ReloadCurrentScene();
}
}