Live-star skybox: game activity feed + procedural star sky
Server: - GameActivityRegistry singleton tracks subscribed clients - game.subscribe_activity handler: registers client, returns active session IDs - game.unsubscribe_activity handler: deregisters client - BroadcastActivityAsync helper in GameHandlerBase (mirrors spectator push pattern) - GamePlaceArchSpiritHandler broadcasts "started" when both players have placed - FinalizeGameAsync broadcasts "ended" to all subscribers Client: - Settings.skybox_mode: "live" | "cdn" | "off" (default: "live"), persisted to cfg - Game.game_activity signal forwarded from game.activity push - game_screen.gd: live mode sets near-black procedural sky; subscribes to activity feed; each active session is an emissive sphere star (280-unit radius, blue-white) that fades in on start, twinkles via sine tween, and flash-explodes on end - CDN and Off modes preserved; hot-swap supported mid-game via Settings.settings_changed - InGameSettings: SkyboxModeOption OptionButton (Live / CDN / Off) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -89,6 +89,23 @@ internal abstract class GameHandlerBase
|
||||
await gameDb.Database.CommitTransactionAsync(ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcast a game activity event (session started / ended) to all subscribed clients.
|
||||
/// Used by the live-star skybox feature. Best-effort; subscriber list is in-memory only.
|
||||
/// </summary>
|
||||
internal static async Task BroadcastActivityAsync(
|
||||
IClientPush clientPush,
|
||||
string eventType,
|
||||
Guid sessionId,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var subs = GameActivityRegistry.Instance?.Subscribers;
|
||||
if (subs is null || subs.Count == 0) return;
|
||||
var push = ServerMessage.Push("game.activity",
|
||||
new GameActivityPush(eventType, sessionId.ToString()));
|
||||
await Task.WhenAll(subs.Select(uid => clientPush.PushAsync(uid, push, ct)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Push the updated game state to both players and any current spectators.
|
||||
/// When <paramref name="prevState"/> is supplied a structured delta (<c>game.state_delta</c>)
|
||||
@@ -270,6 +287,9 @@ internal abstract class GameHandlerBase
|
||||
|
||||
await Task.WhenAll(gameOverTasks);
|
||||
|
||||
// Notify skybox activity subscribers that this game has ended.
|
||||
await BroadcastActivityAsync(clientPush, "ended", session.Id, ct);
|
||||
|
||||
// Publish inter-service event so ChatLifecycleHostedService archives the match channel.
|
||||
await eventBus.PublishAsync(NatsSubjects.GameEnded,
|
||||
new GameEndedEvent(
|
||||
|
||||
Reference in New Issue
Block a user