refactor(runtime): extract the live object frame
This commit is contained in:
parent
99a3e819c4
commit
4e4aac2c5a
27 changed files with 1217 additions and 371 deletions
|
|
@ -1,4 +1,7 @@
|
|||
using AcDream.App.Update;
|
||||
using AcDream.App.Input;
|
||||
using AcDream.App.Net;
|
||||
using AcDream.App.Streaming;
|
||||
|
||||
namespace AcDream.App.World;
|
||||
|
||||
|
|
@ -14,36 +17,37 @@ namespace AcDream.App.World;
|
|||
/// from freezing an action due to complete this frame while ensuring the
|
||||
/// periodic AutonomousPosition check observes accepted inbound state.
|
||||
/// </remarks>
|
||||
public sealed class RetailLiveFrameCoordinator
|
||||
internal sealed class RetailLiveFrameCoordinator : IRetailLiveFramePhase
|
||||
{
|
||||
private readonly Action<float> _advanceObjectRuntime;
|
||||
private readonly Action _dispatchInboundNetwork;
|
||||
private readonly Action _runPostNetworkCommands;
|
||||
private readonly Action _reconcileSpatialPresentation;
|
||||
private readonly ILiveObjectFramePhase _objects;
|
||||
private readonly GpuWorldState _worldState;
|
||||
private readonly ILiveSessionFramePhase _session;
|
||||
private readonly IPostNetworkCommandFramePhase _localPlayer;
|
||||
private readonly ILiveSpatialReconcilePhase _spatialReconciler;
|
||||
|
||||
public RetailLiveFrameCoordinator(
|
||||
Action<float> advanceObjectRuntime,
|
||||
Action dispatchInboundNetwork,
|
||||
Action runPostNetworkCommands,
|
||||
Action reconcileSpatialPresentation)
|
||||
ILiveObjectFramePhase objects,
|
||||
GpuWorldState worldState,
|
||||
ILiveSessionFramePhase session,
|
||||
IPostNetworkCommandFramePhase localPlayer,
|
||||
ILiveSpatialReconcilePhase spatialReconciler)
|
||||
{
|
||||
_advanceObjectRuntime = advanceObjectRuntime
|
||||
?? throw new ArgumentNullException(nameof(advanceObjectRuntime));
|
||||
_dispatchInboundNetwork = dispatchInboundNetwork
|
||||
?? throw new ArgumentNullException(nameof(dispatchInboundNetwork));
|
||||
_runPostNetworkCommands = runPostNetworkCommands
|
||||
?? throw new ArgumentNullException(nameof(runPostNetworkCommands));
|
||||
_reconcileSpatialPresentation = reconcileSpatialPresentation
|
||||
?? throw new ArgumentNullException(nameof(reconcileSpatialPresentation));
|
||||
_objects = objects ?? throw new ArgumentNullException(nameof(objects));
|
||||
_worldState = worldState ?? throw new ArgumentNullException(nameof(worldState));
|
||||
_session = session ?? throw new ArgumentNullException(nameof(session));
|
||||
_localPlayer = localPlayer ?? throw new ArgumentNullException(nameof(localPlayer));
|
||||
_spatialReconciler = spatialReconciler
|
||||
?? throw new ArgumentNullException(nameof(spatialReconciler));
|
||||
}
|
||||
|
||||
public void Tick(float deltaSeconds)
|
||||
{
|
||||
float frameDelta = (float)NormalizeDeltaSeconds(deltaSeconds);
|
||||
_advanceObjectRuntime(frameDelta);
|
||||
_dispatchInboundNetwork();
|
||||
_runPostNetworkCommands();
|
||||
_reconcileSpatialPresentation();
|
||||
_objects.Tick(frameDelta);
|
||||
using (_worldState.BeginMutationBatch())
|
||||
_session.Tick();
|
||||
_localPlayer.RunPostNetworkCommandPhase();
|
||||
_spatialReconciler.Reconcile();
|
||||
}
|
||||
|
||||
public static double NormalizeDeltaSeconds(double deltaSeconds) =>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue