Skip to main content

ServerStepInstance

A class in Root.Township, ATT.MicroTutorial.

Server-side run of one micro tutorial step: spawns its content, tells the client to spawn it, listens for player events and completes the step.

Constructors​

MemberWhat it is
ServerStepInstance(IMicroTutorial tutorial, MicroTutorialStep step, IMicroTutorialSystem microTutorialSystem)Creates a ServerStepInstance from tutorial, step and microTutorialSystem.

Fields​

5 private and internal fields
MemberWhat it is
private readonly PlayerEventBuffer eventBufferBuffers player events until the step has spawned, then passes them through.
private readonly IEventBus eventBusThe township event bus.
private bool isCompletedWhether the step has completed.
private static readonly MicroTutorialLogger loggerMicro tutorial logger for this class.
private readonly IMicroTutorialSystem tutorialSystemThe micro tutorial system, used for its sync controller.

Properties​

MemberWhat it is
IMicroTutorial Tutorial { get; }The tutorial this step belongs to.

Events​

MemberWhat it is
event Action<IServerStepInstance> StepCompletedRaised from Stop once the step is completed.

Methods​

MemberWhat it is
void Complete()Marks the step done and stops it. A second call only logs an error.
void DespawnContent()Destroys the dynamic entities, tells the client to despawn the step and removes the static content.
async void Start()Spawns the content, processes buffered events and, if not done yet, runs the step logic.
void Stop()Despawns content if the step is set to destroy on complete, stops listening and raises StepCompleted if done.
override string ToString()Returns the step name in brackets, for logs.
10 private and internal methods
MemberWhat it is
private void DespawnDynamicContent()Scene-destroys every network entity under the dynamic content transform.
private async Task ExecuteStepLogic()Runs the step settings' RunForInstance.
private void ListenToForceCompleteStepEvents()Listens for ForceCompleteTutorialStepEvent. The handler doesn't check the player, so the event completes every listening step.
private void NotifyPlayerToSpawnStep()Sends the spawn step command to the tutorial's player.
private void OnForceComplete(IPlayerEvent eventInfo)Completes the step when a force-complete event arrives.
private void ProcessBufferedEvents()Switches the event buffer to passthrough and checks the events buffered so far, stopping once the step completes.
private void ProcessPlayerEvent(IPlayerEvent playerEvent)Completes the step if the step settings say the event does.
private async Task SpawnDynamicStepContent()Loads the step's dynamic save data into the tutorial entity, instantiates additional static content, syncs positions and tells the client.
private async Task SpawnStepContent()Builds the hierarchy, spawns static content, notifies the client and spawns dynamic content.
private void SyncTutorialEntityPositions()Forces a position sync for every network entity in the tutorial chunk, waiting for ones not yet initialized.