Skip to main content

ServerController

A class in Root.Township, ATT.MicroTutorial.

Server side of micro tutorials: starts and ends a tutorial per player, tracks the active ones and sends analytics. Created by MicroTutorialSystem.

Constructors​

MemberWhat it is
ServerController(ISyncController syncController, IMicroTutorialFactory tutorialFactory, IAnalyticsService analyticsService)Built by the game's dependency injection (VContainer), which passes the services in.

Fields​

5 private and internal fields
MemberWhat it is
private readonly Dictionary<IPlayer, IMicroTutorial> activeTutorialMapBacking map for ActiveTutorials.
private readonly IAnalyticsService analyticsServiceAnalytics service events are sent to.
private static readonly MicroTutorialLogger loggerMicro tutorial logger.
private readonly ISyncController syncControllerSync controller used to tell clients to clear steps.
private readonly IMicroTutorialFactory tutorialFactoryFactory that creates tutorial instances.

Properties​

MemberWhat it is
IReadOnlyDictionary<IPlayer, IMicroTutorial> ActiveTutorials { get; }The tutorial each player is in now.

Methods​

MemberWhat it is
async Task DespawnTutorial(IPlayer player)Ends the player's current tutorial. Logs an error if they are not in one.
async Task SpawnTutorial(IPlayer player, IMicroTutorialSettings settings)Validates the player, creates the tutorial from settings, hooks its events and spawns it.
6 private and internal methods
MemberWhat it is
private void OnStepCompleted(IPlayer player, IMicroTutorial tutorial)Sends the step completed analytics event.
private void OnTutorialCompleted(IPlayer player, IMicroTutorial tutorial)Records that the player completed this tutorial.
private void OnTutorialDespawned(IPlayer player, IMicroTutorial tutorial)Removes the player's active tutorial, tells their client to clear steps and sends the exit event.
private void OnTutorialSpawned(IPlayer player, IMicroTutorial tutorial)Stores the tutorial as the player's active one and sends the enter event.
private void SendAnalyticsEvent(string eventName, IMicroTutorial tutorial, IPlayer player)Sends a micro tutorial analytics event with the given name.
private IResult ValidatePlayerCanStartNewTutorial(IPlayer player)Fails if the player is already in a tutorial, not in a savable state, or not in the Playing or Spirit state.

Used in​

Members of other types that take, return or hold a ServerController: