MicroTutorial
A class in Root.Township, ATT.MicroTutorial.
Server: one run of a micro tutorial for one player. It moves the player into a private domain, runs the steps in order, and returns them to the overworld when despawned.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
IMicroTutorial
Constructors
| Member | What it is |
|---|---|
MicroTutorial(IMicroTutorialSettings settings, IPlayer player, IMicroTutorialSystem tutorialSystem, IDomainController domainController) | Creates a MicroTutorial from settings, player, tutorialSystem and domainController. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private LoadingStatus clientLoadStatus | Whether the client has acknowledged spawning the tutorial content. |
private Domain domain | The player's private tutorial domain, created in CreateDomain. |
private readonly IDomainController domainController | Domain controller used to create the tutorial domain. |
private static readonly MicroTutorialLogger logger | Micro tutorial logger for this class. |
private static readonly object staticLock | Lock around the instance counter when building SessionId. |
private readonly List<IServerStepInstance> steps | The server step instances, one per settings step. |
private static long tutorialInstanceCount | Count of tutorials made since start, hashed with the server ID and tutorial name into SessionId. |
private readonly IMicroTutorialSystem tutorialSystem | The micro tutorial system, used for settings and the sync controller. |
Properties
| Member | What it is |
|---|---|
LocationChunk Chunk { get; } | The chunk of the tutorial's domain. |
NetworkEntity Entity { get; } | The network entity of the tutorial's domain. |
bool IsReplay { get; } | True if the player had already completed this tutorial when it was created. |
IPlayer Player { get; } | The player taking the tutorial. |
string SessionId { get; } | A hash of the server ID, tutorial name and an instance counter, unique per tutorial run. |
IMicroTutorialSettings Settings { get; } | The tutorial's settings, including its list of steps. |
TutorialState State { get; private set; } | Inactive, Started or Completed. |
int StepIndex { get; private set; } | Index of the current step. |
IReadOnlyList<IServerStepInstance> Steps { get; } | The server step instances, one per step in the settings. |
Transform Transform { get; } | The transform of the tutorial's domain. |
3 private and internal properties
| Member | What it is |
|---|---|
private IServerStepInstance CurrentStep { get; } | The step instance at StepIndex. |
private bool IsFinalStep { get; } | True when StepIndex is the last step. |
private int StepCount { get; } | Number of steps in the settings. |
Events
| Member | What it is |
|---|---|
event Action<IPlayer, IMicroTutorial> Despawned | Raised after the tutorial has been cleaned up. |
event Action<IPlayer, IMicroTutorial> Spawned | Raised once the domain is up and the client has finished loading. |
event Action<IPlayer, IMicroTutorial> StepCompleted | Raised every time a step finishes, including the last. |
event Action<IPlayer, IMicroTutorial> TutorialCompleted | Raised when the final step finishes. Despawning is left to the caller. |
Methods
13 private and internal methods
| Member | What it is |
|---|---|
private async Task CleanUpTutorialContent() | Despawns and stops every step in reverse order, clears the list and destroys the domain. Called from Despawn. |
private async Task CreateDomain() | Asks the domain controller for a private domain for the player and spawns them into it. |
private void CreateStepInstances() | Makes a ServerStepInstance for each step in the settings and hooks its StepCompleted. Called from the constructor. |
private string GetStepInfo() | Short state text used by ToString, such as how many steps are done. |
private void NextStep() | Increments StepIndex and starts that step. |
private void OnClientLoadCompleted(IPlayer player) | Marks the client load as done when the tutorial's own player reports it; ignores other players. |
private void OnPlayerDisconnected(Connection connection) | Despawns the tutorial when its player disconnects. |
private void OnStepCompleted(IServerStepInstance stepInstance) | Raises TutorialCompleted on the last step, then StepCompleted, then starts the next step if there is one. |
private void OnTutorialPlayerDamaged(DamageState damageState) | Marks all damage to the player as handled, so they can't be hurt during the tutorial. |
private void PreparePlayerForTutorialStart() | Docks held items to the player's back and drops held items matching the system's drop tags. |
private async Task ReturnPlayerToGame() | Destroys the tutorial controller, removes the save blocker and respawns the player at their entry point in the overworld. |
private void Start() | Sets the state to started and starts the first step. |
private async Task WaitForClientLoad() | Polls every 100 ms until the client says it has spawned the first step's content. |