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.
- Listed in ATT, Features and other game namespaces
Constructors
| Member | What 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
| Member | What it is |
|---|---|
private readonly Dictionary<IPlayer, IMicroTutorial> activeTutorialMap | Backing map for ActiveTutorials. |
private readonly IAnalyticsService analyticsService | Analytics service events are sent to. |
private static readonly MicroTutorialLogger logger | Micro tutorial logger. |
private readonly ISyncController syncController | Sync controller used to tell clients to clear steps. |
private readonly IMicroTutorialFactory tutorialFactory | Factory that creates tutorial instances. |
Properties
| Member | What it is |
|---|---|
IReadOnlyDictionary<IPlayer, IMicroTutorial> ActiveTutorials { get; } | The tutorial each player is in now. |
Methods
| Member | What 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
| Member | What 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: