feat(progression): read surface and change announcements (slice 10a)
reads for the UI: TotalCoins, Lives, IsRunOver, CurrentLevel, LevelOf/IsOwned/CanAfford, HasCleared. The read half of candidate 01 - callers get a narrow surface instead of reaching into state. new domain events LivesChanged / TotalCoinsChanged / SkillSetChanged, announced by comparing against the last announced value, so an operation can neither forget to announce nor announce something unchanged. HandlePlayerDeath now clears the spent attempt - it was still counting towards TotalCoins after its ledger had been discarded. republisher and EventBus extended; SkillSetChanged is what SkillManager will reconcile against instead of the non-atomic call pairs. 65 tests.
This commit is contained in:
@@ -164,6 +164,16 @@ public partial class EventBus : Node
|
||||
public static void EmitRunEnded()
|
||||
=> Instance?.EmitSignal(SignalName.RunEnded);
|
||||
|
||||
/// <summary>
|
||||
/// The set of owned skills, or the level of one of them, changed. SkillManager reconciles its live
|
||||
/// components against this instead of every caller remembering to update it separately — the
|
||||
/// non-atomic pair of calls that could leave a skill owned but inert.
|
||||
/// </summary>
|
||||
[Signal] public delegate void SkillSetChangedEventHandler();
|
||||
|
||||
public static void EmitSkillSetChanged()
|
||||
=> Instance?.EmitSignal(SignalName.SkillSetChanged);
|
||||
|
||||
public static void EmitCoinsChanged(int totalCoins)
|
||||
=> Instance?.EmitSignal(SignalName.CoinsChanged, totalCoins);
|
||||
|
||||
|
||||
@@ -55,6 +55,18 @@ public sealed class ProgressionEventRepublisher
|
||||
EventBus.EmitAchievementUnlocked(unlocked.Achievement.Value);
|
||||
break;
|
||||
|
||||
case LivesChanged lives:
|
||||
EventBus.EmitLivesChanged(lives.Remaining.Value);
|
||||
break;
|
||||
|
||||
case TotalCoinsChanged coins:
|
||||
EventBus.EmitCoinsChanged(coins.Total.Value);
|
||||
break;
|
||||
|
||||
case SkillSetChanged:
|
||||
EventBus.EmitSkillSetChanged();
|
||||
break;
|
||||
|
||||
default:
|
||||
GD.PushWarning($"No signal is published for domain event {@event.GetType().Name}.");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user