Add initial game systems and input handling for player interactions

This commit is contained in:
2025-12-09 22:20:38 +01:00
commit 5e0db113aa
182 changed files with 70557 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using System;
using Infrastructure;
namespace Core.Systems
{
public class PersistenceSystem : IDisposable
{
private readonly IPersistenceService _service;
private readonly string _saveKey;
private int _currentRunScore;
public PersistenceSystem(IPersistenceService service, string saveKey)
{
_service = service;
_saveKey = saveKey;
GameEvents.ScoreUpdated += OnScoreUpdated;
GameEvents.GameOver += OnGameOver;
}
public int GetHighScore()
{
return _service.LoadHighScore(_saveKey);
}
private void OnGameOver()
{
var existingHighScore = _service.LoadHighScore(_saveKey);
if (_currentRunScore > existingHighScore)
{
_service.SaveHighScore(_saveKey, _currentRunScore);
}
}
private void OnScoreUpdated(int newScore)
{
_currentRunScore = newScore;
}
public void Dispose()
{
GameEvents.ScoreUpdated -= OnScoreUpdated;
GameEvents.GameOver -= OnGameOver;
}
}
}