Add MeleeEffect and related services for combat interactions
This commit is contained in:
40
GameCore/State/GameStateService.cs
Normal file
40
GameCore/State/GameStateService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
9
GameCore/State/GameStatus.cs
Normal file
9
GameCore/State/GameStatus.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace GameCore.State;
|
||||
|
||||
public enum GameStatus
|
||||
{
|
||||
InMainMenu,
|
||||
InGame,
|
||||
Paused,
|
||||
GameOver
|
||||
}
|
||||
13
GameCore/State/IGameStateService.cs
Normal file
13
GameCore/State/IGameStateService.cs
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user