refactor(app): close ordered startup composition
This commit is contained in:
parent
54244d31f1
commit
530b4bd8f5
16 changed files with 537 additions and 215 deletions
|
|
@ -1097,8 +1097,18 @@ public sealed class GameWindow :
|
|||
|
||||
GameWindowPlatformResult<GL, IInputContext> platform = AcquirePlatform();
|
||||
|
||||
HostInputCameraResult hostInputCamera =
|
||||
new HostInputCameraCompositionPhase(
|
||||
GameWindowCompositionPipeline.Run<
|
||||
GameWindowPlatformResult<GL, IInputContext>,
|
||||
HostInputCameraResult,
|
||||
ContentEffectsAudioResult,
|
||||
SettingsDevToolsResult,
|
||||
WorldRenderResult,
|
||||
InteractionRetainedUiResult,
|
||||
LivePresentationResult,
|
||||
SessionPlayerResult,
|
||||
FrameRootResult>(
|
||||
platform,
|
||||
platformResult => new HostInputCameraCompositionPhase(
|
||||
new HostInputCameraDependencies(
|
||||
_framebufferResize,
|
||||
_window!.FramebufferSize,
|
||||
|
|
@ -1111,12 +1121,9 @@ public sealed class GameWindow :
|
|||
_chaseCameraInput,
|
||||
_pointerPosition,
|
||||
_renderDiagnosticLog),
|
||||
this).Compose(platform);
|
||||
WorldRenderDiagnostics worldRenderDiagnostics =
|
||||
hostInputCamera.WorldRenderDiagnostics;
|
||||
|
||||
ContentEffectsAudioResult contentEffectsAudio =
|
||||
new ContentEffectsAudioCompositionPhase(
|
||||
this).Compose(platformResult),
|
||||
(platformResult, hostInputCamera) =>
|
||||
new ContentEffectsAudioCompositionPhase(
|
||||
new ContentEffectsAudioDependencies(
|
||||
_datDir,
|
||||
_physicsDataCache,
|
||||
|
|
@ -1130,91 +1137,95 @@ public sealed class GameWindow :
|
|||
_options.NoAudio,
|
||||
Console.WriteLine,
|
||||
Console.Error.WriteLine),
|
||||
this).Compose(platform, hostInputCamera);
|
||||
|
||||
SettingsDevToolsOptionalDependencies? optionalDevTools = null;
|
||||
if (DevToolsEnabled)
|
||||
{
|
||||
var devToolsWorldEntities =
|
||||
new DeferredCanonicalWorldEntityCountSource();
|
||||
var devToolsFrameDiagnostics =
|
||||
new DeferredRenderFrameDiagnosticsSource();
|
||||
var devToolsPlayerModeCommands =
|
||||
new DeferredDevToolsPlayerModeCommands();
|
||||
var devToolsFacts = new DevToolsRuntimeFacts(
|
||||
_localPlayerMode,
|
||||
_playerControllerSlot,
|
||||
hostInputCamera.CameraController,
|
||||
devToolsWorldEntities,
|
||||
_animatedEntities,
|
||||
_debugVmRenderFacts,
|
||||
_physicsEngine,
|
||||
_worldSceneDebugState,
|
||||
_renderRange,
|
||||
hostInputCamera.CameraPointerInput,
|
||||
_worldEnvironment,
|
||||
Lighting,
|
||||
contentEffectsAudio.ParticleSystem,
|
||||
devToolsFrameDiagnostics);
|
||||
IRuntimeKeyBindingTarget? keyBindingTarget =
|
||||
hostInputCamera.InputDispatcher is { } settingsDispatcher
|
||||
? new RuntimeKeyBindingTarget(settingsDispatcher)
|
||||
: null;
|
||||
optionalDevTools = new SettingsDevToolsOptionalDependencies(
|
||||
devToolsFacts,
|
||||
keyBindingTarget,
|
||||
devToolsWorldEntities,
|
||||
devToolsFrameDiagnostics,
|
||||
devToolsPlayerModeCommands);
|
||||
}
|
||||
SettingsDevToolsResult settingsDevTools =
|
||||
new SettingsDevToolsCompositionPhase(
|
||||
new SettingsDevToolsDependencies(
|
||||
_window!,
|
||||
_runtimeSettings,
|
||||
new RuntimeSettingsStartupTargets(
|
||||
new SilkRuntimeDisplayWindowTarget(_window!),
|
||||
_displayFramePacing,
|
||||
this).Compose(platformResult, hostInputCamera),
|
||||
(platformResult, hostInputCamera, contentEffectsAudio) =>
|
||||
{
|
||||
SettingsDevToolsOptionalDependencies? optionalDevTools = null;
|
||||
if (DevToolsEnabled)
|
||||
{
|
||||
var devToolsWorldEntities =
|
||||
new DeferredCanonicalWorldEntityCountSource();
|
||||
var devToolsFrameDiagnostics =
|
||||
new DeferredRenderFrameDiagnosticsSource();
|
||||
var devToolsPlayerModeCommands =
|
||||
new DeferredDevToolsPlayerModeCommands();
|
||||
var devToolsFacts = new DevToolsRuntimeFacts(
|
||||
_localPlayerMode,
|
||||
_playerControllerSlot,
|
||||
hostInputCamera.CameraController,
|
||||
contentEffectsAudio.Audio?.Engine),
|
||||
_hostQuiescence,
|
||||
Chat,
|
||||
Combat,
|
||||
LocalPlayer,
|
||||
optionalDevTools,
|
||||
_runtimeDiagnosticCommands,
|
||||
_combatFeedback,
|
||||
_keyBindings,
|
||||
_frameProfiler,
|
||||
_framebufferResize,
|
||||
Console.WriteLine),
|
||||
this).Compose(platform, hostInputCamera, contentEffectsAudio);
|
||||
Action<string>? compositionToast = settingsDevTools.DevTools is { } composedDevTools
|
||||
? text => composedDevTools.Debug.AddToast(text)
|
||||
: null;
|
||||
devToolsWorldEntities,
|
||||
_animatedEntities,
|
||||
_debugVmRenderFacts,
|
||||
_physicsEngine,
|
||||
_worldSceneDebugState,
|
||||
_renderRange,
|
||||
hostInputCamera.CameraPointerInput,
|
||||
_worldEnvironment,
|
||||
Lighting,
|
||||
contentEffectsAudio.ParticleSystem,
|
||||
devToolsFrameDiagnostics);
|
||||
IRuntimeKeyBindingTarget? keyBindingTarget =
|
||||
hostInputCamera.InputDispatcher is { } settingsDispatcher
|
||||
? new RuntimeKeyBindingTarget(settingsDispatcher)
|
||||
: null;
|
||||
optionalDevTools = new SettingsDevToolsOptionalDependencies(
|
||||
devToolsFacts,
|
||||
keyBindingTarget,
|
||||
devToolsWorldEntities,
|
||||
devToolsFrameDiagnostics,
|
||||
devToolsPlayerModeCommands);
|
||||
}
|
||||
|
||||
const uint initialCenterLandblockId = 0xA9B4FFFFu;
|
||||
WorldRenderResult worldRender = new WorldRenderCompositionPhase(
|
||||
new WorldRenderDependencies(
|
||||
_worldEnvironment,
|
||||
_renderResourceLifetime,
|
||||
_gpuFrameFlights!,
|
||||
initialCenterLandblockId,
|
||||
Console.WriteLine),
|
||||
this).Compose(platform, contentEffectsAudio, settingsDevTools);
|
||||
string shadersDir = worldRender.Foundation.ShadersDirectory;
|
||||
Console.WriteLine(
|
||||
$"loading world view centered on " +
|
||||
$"0x{worldRender.TerrainBuild.InitialCenterLandblockId:X8}");
|
||||
|
||||
InteractionRetainedUiResult interactionUi =
|
||||
new InteractionRetainedUiCompositionPhase(
|
||||
new InteractionRetainedUiDependencies(
|
||||
return new SettingsDevToolsCompositionPhase(
|
||||
new SettingsDevToolsDependencies(
|
||||
_window!,
|
||||
_runtimeSettings,
|
||||
new RuntimeSettingsStartupTargets(
|
||||
new SilkRuntimeDisplayWindowTarget(_window!),
|
||||
_displayFramePacing,
|
||||
hostInputCamera.CameraController,
|
||||
contentEffectsAudio.Audio?.Engine),
|
||||
_hostQuiescence,
|
||||
Chat,
|
||||
Combat,
|
||||
LocalPlayer,
|
||||
optionalDevTools,
|
||||
_runtimeDiagnosticCommands,
|
||||
_combatFeedback,
|
||||
_keyBindings,
|
||||
_frameProfiler,
|
||||
_framebufferResize,
|
||||
Console.WriteLine),
|
||||
this).Compose(platformResult, hostInputCamera, contentEffectsAudio);
|
||||
},
|
||||
(platformResult, contentEffectsAudio, settingsDevTools) =>
|
||||
{
|
||||
const uint initialCenterLandblockId = 0xA9B4FFFFu;
|
||||
WorldRenderResult worldRender = new WorldRenderCompositionPhase(
|
||||
new WorldRenderDependencies(
|
||||
_worldEnvironment,
|
||||
_renderResourceLifetime,
|
||||
_gpuFrameFlights!,
|
||||
initialCenterLandblockId,
|
||||
Console.WriteLine),
|
||||
this).Compose(platformResult, contentEffectsAudio, settingsDevTools);
|
||||
Console.WriteLine(
|
||||
$"loading world view centered on " +
|
||||
$"0x{worldRender.TerrainBuild.InitialCenterLandblockId:X8}");
|
||||
return worldRender;
|
||||
},
|
||||
(platformResult, hostInputCamera, contentEffectsAudio, settingsDevTools, worldRender) =>
|
||||
{
|
||||
Action<string>? compositionToast = settingsDevTools.DevTools is { } devTools
|
||||
? text => devTools.Debug.AddToast(text)
|
||||
: null;
|
||||
return new InteractionRetainedUiCompositionPhase(
|
||||
new InteractionRetainedUiDependencies(
|
||||
_options,
|
||||
platform.Graphics,
|
||||
platformResult.Graphics,
|
||||
_window!,
|
||||
platform.Input,
|
||||
shadersDir,
|
||||
platformResult.Input,
|
||||
worldRender.Foundation.ShadersDirectory,
|
||||
contentEffectsAudio.Dats,
|
||||
_datLock,
|
||||
worldRender.Foundation.TextureCache,
|
||||
|
|
@ -1252,16 +1263,26 @@ public sealed class GameWindow :
|
|||
Console.WriteLine),
|
||||
_retailUiLease,
|
||||
this).Compose(
|
||||
platformResult,
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender);
|
||||
|
||||
LivePresentationResult livePresentation =
|
||||
new LivePresentationCompositionPhase(
|
||||
new LivePresentationDependencies(
|
||||
},
|
||||
(platformResult,
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi) =>
|
||||
{
|
||||
Action<string>? compositionToast = settingsDevTools.DevTools is { } devTools
|
||||
? text => devTools.Debug.AddToast(text)
|
||||
: null;
|
||||
return new LivePresentationCompositionPhase(
|
||||
new LivePresentationDependencies(
|
||||
_options,
|
||||
platform.Graphics,
|
||||
platformResult.Graphics,
|
||||
_window!,
|
||||
_datLock,
|
||||
_runtimeSettings,
|
||||
|
|
@ -1299,13 +1320,20 @@ public sealed class GameWindow :
|
|||
_uiFrameDiagnostics,
|
||||
compositionToast),
|
||||
this).Compose(
|
||||
platformResult,
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi);
|
||||
|
||||
SessionPlayerResult sessionPlayer =
|
||||
new SessionPlayerCompositionPhase(
|
||||
},
|
||||
(hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi,
|
||||
livePresentation) =>
|
||||
new SessionPlayerCompositionPhase(
|
||||
new SessionPlayerDependencies(
|
||||
_options,
|
||||
_window!,
|
||||
|
|
@ -1371,58 +1399,65 @@ public sealed class GameWindow :
|
|||
this).Compose(
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi,
|
||||
livePresentation);
|
||||
|
||||
FrameRootResult frameRoots = new FrameRootCompositionPhase(
|
||||
new FrameRootDependencies(
|
||||
_options,
|
||||
_gl!,
|
||||
_window!,
|
||||
_input!,
|
||||
WorldTime,
|
||||
Weather,
|
||||
Lighting,
|
||||
_worldEnvironment,
|
||||
_physicsEngine,
|
||||
_cellVisibility,
|
||||
_localPlayerMode,
|
||||
_localPlayerIdentity,
|
||||
_chaseCameraInput,
|
||||
_playerControllerSlot,
|
||||
_liveWorldOrigin,
|
||||
_particleVisibility,
|
||||
_effectPoses,
|
||||
_renderRange,
|
||||
_runtimeSettings,
|
||||
_displayFramePacing,
|
||||
_worldSceneDebugState,
|
||||
_retailAlphaQueue,
|
||||
_frameProfiler,
|
||||
_frameDiag,
|
||||
_renderDiagnosticLog,
|
||||
_debugVmRenderFacts,
|
||||
_inputCapture,
|
||||
_cameraInput,
|
||||
_selection,
|
||||
_animatedEntities,
|
||||
_updateFrameClock,
|
||||
Combat,
|
||||
_frameGraphs,
|
||||
Console.WriteLine),
|
||||
this).Compose(
|
||||
livePresentation),
|
||||
(platformResult,
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi,
|
||||
livePresentation,
|
||||
sessionPlayer);
|
||||
|
||||
new SessionStartCompositionPhase(
|
||||
new SessionStartDependencies(_options, Console.WriteLine))
|
||||
.Start(frameRoots);
|
||||
sessionPlayer) => new FrameRootCompositionPhase(
|
||||
new FrameRootDependencies(
|
||||
_options,
|
||||
platformResult.Graphics,
|
||||
_window!,
|
||||
platformResult.Input,
|
||||
WorldTime,
|
||||
Weather,
|
||||
Lighting,
|
||||
_worldEnvironment,
|
||||
_physicsEngine,
|
||||
_cellVisibility,
|
||||
_localPlayerMode,
|
||||
_localPlayerIdentity,
|
||||
_chaseCameraInput,
|
||||
_playerControllerSlot,
|
||||
_liveWorldOrigin,
|
||||
_particleVisibility,
|
||||
_effectPoses,
|
||||
_renderRange,
|
||||
_runtimeSettings,
|
||||
_displayFramePacing,
|
||||
_worldSceneDebugState,
|
||||
_retailAlphaQueue,
|
||||
_frameProfiler,
|
||||
_frameDiag,
|
||||
_renderDiagnosticLog,
|
||||
_debugVmRenderFacts,
|
||||
_inputCapture,
|
||||
_cameraInput,
|
||||
_selection,
|
||||
_animatedEntities,
|
||||
_updateFrameClock,
|
||||
Combat,
|
||||
_frameGraphs,
|
||||
Console.WriteLine),
|
||||
this).Compose(
|
||||
platformResult,
|
||||
hostInputCamera,
|
||||
contentEffectsAudio,
|
||||
settingsDevTools,
|
||||
worldRender,
|
||||
interactionUi,
|
||||
livePresentation,
|
||||
sessionPlayer),
|
||||
frameRoots => new SessionStartCompositionPhase(
|
||||
new SessionStartDependencies(_options, Console.WriteLine))
|
||||
.Start(frameRoots));
|
||||
}
|
||||
|
||||
private void OnUpdate(double dt)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue