C# for Games
Events and decoupled systems
An event lets a publisher announce that something happened without knowing every subscriber. This is especially useful for score, health and quest systems.
csharp
public event Action<int> ScoreChanged;
private void AddScore(int amount)
{
score += amount;
ScoreChanged?.Invoke(score);
}Lesson complete?Use the next lesson to continue the learning path.