Add MeleeEffect and related services for combat interactions

This commit is contained in:
2025-10-30 03:24:44 +01:00
parent bb31c9a39c
commit f65277e6b4
9 changed files with 145 additions and 5 deletions

View File

@@ -0,0 +1,40 @@
using GameCore.ECS;
using GameCore.Events;
namespace GameCore.State;
public class GameStateService(World world) : IGameStateService
{
private readonly HashSet<string> _unlockedLevelIds = [];
private readonly World _world = world;
public GameStatus CurrentStatus { get; private set; } = GameStatus.InMainMenu;
public string CurrentLevelId { get; private set; }
public IReadOnlyCollection<string> UnlockedLevelIds => _unlockedLevelIds;
public void SetStatus(GameStatus newStatus)
{
if (CurrentStatus == newStatus) return;
CurrentStatus = newStatus;
_world.PublishEvent(new GameStatusChangedEvent(newStatus));
}
public void StartGame(string startingLevelId)
{
CurrentLevelId = startingLevelId;
_unlockedLevelIds.Add(startingLevelId);
SetStatus(GameStatus.InGame);
}
public void UnlockLevel(string levelId)
{
_unlockedLevelIds.Add(levelId);
}
public void ResetProgress()
{
_unlockedLevelIds.Clear();
CurrentLevelId = null!;
SetStatus(GameStatus.InMainMenu);
}
}

View File

@@ -0,0 +1,9 @@
namespace GameCore.State;
public enum GameStatus
{
InMainMenu,
InGame,
Paused,
GameOver
}

View File

@@ -0,0 +1,13 @@
namespace GameCore.State;
public interface IGameStateService
{
GameStatus CurrentStatus { get; }
string CurrentLevelId { get; }
IReadOnlyCollection<string> UnlockedLevelIds { get; }
void SetStatus(GameStatus newStatus);
void StartGame(string startingLevelId);
void UnlockLevel(string levelId);
void ResetProgress();
}