GameTaskManager
A class in Root.Township, the global namespace.
Singleton behind achievements, action stats and micro tutorial completion. The server keeps a tracker per player loaded from Alta's achievement service and syncs completed flags to that player. See the Other systems guide.
- Listed in Global namespace: E to H
- Inherits or implements
NetworkEntityBehaviour,IAutoSave - Nested types
ProgressFlagSync - Documented in Other systems
Constructors
| Member | What it is |
|---|---|
GameTaskManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
5 private and internal fields
| Member | What it is |
|---|---|
private readonly Dictionary<GameActionChannel, List<GameAction>> actionStatMap | Server: GameAction lists by channel, for the actions valid in the current scene. |
private static readonly Logger logger | NLog logger for this class. |
private readonly Dictionary<IPlayer, PlayerTracker> playerTrackers | Server: progress tracker per connected player, loaded from the web API on connect. |
private MethodSync syncInitialize | Method sync that sends a player all their completed flags on connect. |
private MethodSyncStruct<uint> syncProgressFlagStatus | Method sync that sends a single completed flag. |
Properties
| Member | What it is |
|---|---|
static GameTaskManager Instance { get; private set; } | The manager in the scene. Extra copies destroy themselves. |
Events
| Member | What it is |
|---|---|
static event Action ReceivedSync | Client: raised after the initial list of completed flags arrives. |
Methods
| Member | What it is |
|---|---|
static void ActionExecuted(IPlayer player, GameTaskActionArgument argument) | Reports a player action. Updates every matching game action for that player; errors are logged, not thrown. |
void ClearAchievementForPlayer(int userId, GameAchievement achievement) | Server: un-completes an achievement for a user id and resets its target stat, locally and in the achievement service. |
void ClearActionStatForPlayer(int userId, GameAction action) | Server: sets one action stat to 0 for a user id, locally and in the achievement service. |
void ClearAllAchievementsForPlayer(int userIdentifier) | Server: resets every stat and achievement for a user id, online or not. |
void IncrementForPlayer(GameAction gameTask, IPlayer player) | Server: adds 1 to a game action's value for a player who has a tracker. |
override void Initialize() | Sets up the initial flag sync and the single flag update sync. |
override void InitializeAsServer(SpawnData spawnData) | Maps game actions valid for this scene by channel and hooks every achievement's completion. Registers for autosave. |
static bool IsAchievementCompletedByPlayer(IPlayer player, GameAchievement achievement) | Whether a player has the achievement. Clients only know about the local player. |
static bool IsAchievementLocallyCompleted(GameAchievement achievement) | Whether the local player has the achievement. |
static bool IsTutorialCompletedByPlayer(IPlayer player, IMicroTutorialSettings tutorialSettings) | Whether a player has finished a micro tutorial. Clients only know about the local player. |
override async void OnConnected(Player player) | Server: loads the player's stats and achievements from the achievement service, then makes a tracker and syncs. No tracker if that fails. |
override void OnDisconnected(Player player) | Server: sends the player's progress to the achievement service. |
12 private and internal methods
| Member | What it is |
|---|---|
private void IAutoSave.AutoSave() | Server: sends every connected player's task progress to the web API on autosave. |
private void Awake() | Sets Instance, or destroys itself if one already exists. |
private static void FinishSync() | Raises ReceivedSync once a client has read its completed flags. |
private void InternalActionExecute(IPlayer player, GameTaskActionArgument argument) | Server: feeds an action to every GameAction on its channel that accepts it, updating the player's value. |
private static bool IsProgressFlagLocallyCompleted(PlayerProgressFlag flag) | Client: checks the synced completed set. Server: checks the tracker of Player.Current. |
private void LocalCompletedAchievement(IPlayer player, GameAchievement achievement) | Plays the achievement effect if the player is local and the achievement shows one. |
private void OnDestroy() | Clears Instance if it was this one. |
private void OnPlayerCompletedAchievement(IPlayer player, GameAchievement achievement) | Server: records a newly completed achievement, plays its effect for a local player and sends it to the player and web API. |
private void OnPlayerCompletedTutorial(IPlayer player, MicroTutorialSettings tutorialSettings) | Server: records a completed micro tutorial and syncs it. Not hooked to anything in this file. |
private void SyncPlayerCompletedProgressFlagItem(IPlayer player, HashedGeneralValue hashedValue) | Server: sends a completed flag's hash to the player and marks it completed in the web API. |
private void SyncProgressFlagStatus(IPlayer player, Stream stream, uint flagHash) | Sends one completed flag hash. Client: marks the achievement or tutorial complete when received. |
private void UpdateForPlayer(GameAction stat, IPlayer player, float value) | Sets a player's tracked value for a GameAction. Hooked to each action's ValueUpdate. |