Skip to main content

GymnasiumXpStatusDisplay

A class in Root.Township, ATT.FeatureTestGymnasium.

Debug panel in the feature test gymnasium that shows and changes the nearest player's XP for one progression path (or all of them). The server handles the buttons and syncs the text to clients.

Constructors​

MemberWhat it is
GymnasiumXpStatusDisplay()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private LabelledButtonWrapper backButtonButton that selects the previous path.
private ProgressionPath currentPathLocal copy of the selected path, used when there is no shrine.
private LabelledButtonWrapper forwardButtonButton that selects the next path.
private LabelledButtonWrapper increaseXpButtonButton that levels up the nearest player once.
private LabelledButtonWrapper maxOutXpButtonButton that maxes out the nearest player's XP.
private int MaxXpXP cap read from ProgressionSettings.UncapSkillPoints in OnEnable.
private TextRenderer pathNameText showing the selected path.
private string[] pathNamesNames of the ProgressionPath values, cached in OnEnable.
private TextRenderer pathXpDisplayText showing the nearest player's XP for the selected path.
private LabelledButtonWrapper resetXpButtonButton that clears the nearest player's XP slots.
private SkillShrine shrineBacking field for Shrine.
private MethodSync syncPathMethod sync for the selected path.
private MethodSync syncStatusTextMethod sync for the XP status text.

Properties​

5 private and internal properties
MemberWhat it is
private ProgressionPath CurrentPath { get; set; }The selected path. Reads from and writes to the child SkillShrine when there is one; on clients it also updates the path label.
private bool isAllPaths { get; }True when the selected path is DevDebug, which makes the buttons act on every path.
private int maxPathValue { get; }Upper bound used when serializing the path index (the number of path names).
private static int PathCount { get; }Number of values in the ProgressionPath enum.
private SkillShrine Shrine { get; }Optional child SkillShrine, found lazily. When present, the path is taken from and pushed to it.

Methods​

MemberWhat it is
override void Initialize()Creates the two method syncs (SyncA for the path, SyncB for the status text).
override void OnConnected(Player player)Sends the current path and status text to the chunks when a player connects.
21 private and internal methods
MemberWhat it is
private string AllPathsXp(IPlayer player)Builds the all-paths status text: first letter of each non-debug path and a level. Bug: it reads CurrentPath's level for every entry.
private void ChangeProgressionPathBackwards()Server: button handler that moves to the previous progression path and syncs it.
private void ChangeProgressionPathForwards()Server: button handler that moves to the next progression path and syncs it.
private IPlayer GetClosestPlayer(Vector3 position)Returns the player nearest a position, from Player.AllPlayers. The buttons act on this player.
private void IncreaseXp()Server: button handler that gives the nearest player enough XP for one level in the current path, or in every path when on DevDebug.
private void IncreaseXpAllPaths(IPlayer player)Runs IncreaseXpSinglePath for every progression path.
private void IncreaseXpSinglePath(IPlayer player, ProgressionPath path)Gives the player the XP left to reach their next level in one path, through PlayerProgressionManager.GainExperience.
private void MaxOutXp()Server: button handler that raises the nearest player's XP to the uncapped maximum in the current path, or all paths on DevDebug.
private void MaxOutXpAllPaths(IPlayer player)Runs MaxOutXpSinglePath for every progression path.
private void MaxOutXpSinglePath(ProgressionPath path, IPlayer player)Gives the player the XP missing up to MaxXp in one path. Logs an error if they have no entry for it.
private void OnDisable()Server: unhooks the button handlers.
private void OnEnable()Caches the path names, reads MaxXp and hooks the buttons.
private string ParsePlayerXp(IPlayer player)Server: builds the status text for a player (current XP, XP for the level and next level). Returns empty on clients.
private void ResetXp()Server: button handler that clears the nearest player's slots in the current path (or all paths) and recounts their points.
private void ResetXpAllPaths(IPlayer player)Runs ResetXpSinglePath for every progression path.
private void ResetXpSinglePath(IPlayer player, ProgressionPath path)Calls DebugClearSlots on the player's experience for one path.
private void Setup()Server: hooks the five buttons' Released events to their handlers.
private ProgressionPath ShiftProgressionPath(int offset)Returns the path a given offset away from the current one, wrapping around the enum.
private void SyncPath(IPlayer player, Stream stream)Method sync body for the path index. Clients apply the value they read.
private void SyncStatusText(IPlayer player, Stream stream)Method sync body for the status text. The server writes ParsePlayerXp, clients show it.
private void UpdatePath()Sends both the path and the status text to the chunks.