using AcDream.App.Combat; using AcDream.App.Input; using AcDream.App.Interaction; using AcDream.App.Net; using AcDream.App.Streaming; using AcDream.App.World; using AcDream.Core.Chat; using AcDream.Core.Items; using AcDream.Core.Selection; using AcDream.Runtime; using AcDream.Runtime.Session; using AcDream.UI.Abstractions; namespace AcDream.App.Runtime; /// /// App composition root for Slice J's borrowed runtime boundary. Focused /// adapters project the existing canonical owners; this root owns only those /// adapters and never owns or copies gameplay state. /// internal sealed class CurrentGameRuntimeAdapter : IGameRuntimeView, IGameRuntimeCommands, IRuntimeEventSource, IDisposable { private readonly CurrentGameRuntimeViewAdapter _view; private readonly CurrentGameRuntimeEventAdapter _events; private readonly CurrentGameRuntimeCommandAdapter _commands; private bool _disposed; public CurrentGameRuntimeAdapter( LiveSessionController session, LiveSessionHost sessionHost, ICommandBus commands, LocalPlayerIdentityState playerIdentity, LiveEntityRuntime entities, ClientObjectTable objects, ChatLog chat, ILocalPlayerControllerSource playerController, WorldRevealCoordinator worldReveal, IGameRuntimeClock clock, SelectionState selectionState, SelectionInteractionController selection, GameplayInputFrameController gameplayInput, ILiveCombatModeCommand combat) { _view = new CurrentGameRuntimeViewAdapter( session, playerIdentity, entities, objects, chat, playerController, worldReveal, clock); _events = new CurrentGameRuntimeEventAdapter( _view, entities, objects, chat, clock); _commands = new CurrentGameRuntimeCommandAdapter( session, sessionHost, commands, _view, selectionState, selection, gameplayInput, combat, _events); } public RuntimeGenerationToken Generation => _view.Generation; public RuntimeLifecycleSnapshot Lifecycle => _view.Lifecycle; public IGameRuntimeClock Clock => _view.Clock; public IRuntimeEntityView Entities => _view.Entities; public IRuntimeInventoryView Inventory => _view.Inventory; public IRuntimeChatView Chat => _view.Chat; public IRuntimeMovementView Movement => _view.Movement; public IRuntimePortalView Portal => _view.Portal; public IRuntimeSessionCommands Session => _commands; public IRuntimeSelectionCommands Selection => _commands; public IRuntimeCombatCommands Combat => _commands; public IRuntimeMovementCommands MovementCommands => _commands; IRuntimeMovementCommands IGameRuntimeCommands.Movement => _commands; public IRuntimeChatCommands ChatCommands => _commands; IRuntimeChatCommands IGameRuntimeCommands.Chat => _commands; public IRuntimePortalCommands PortalCommands => _commands; IRuntimePortalCommands IGameRuntimeCommands.Portal => _commands; public RuntimeStateCheckpoint CaptureCheckpoint() => _view.CaptureCheckpoint(); public IDisposable Subscribe(IRuntimeEventObserver observer) => _events.Subscribe(observer); public void Dispose() { if (_disposed) return; _disposed = true; _view.Deactivate(); _events.Dispose(); } }