UserState
UserState
Core state data for user information and preferences Contains pure C# data without Godot dependencies for unit testing Manages user profile, settings, preferences, and session data
Project: GridPlacement v6.0
Layer: Core
Source: Core/_incomplete/State/User/UserState.cs
Namespace: GridBuilding.Core.State.User
Kind: class
Parsing Method: AST-based (Roslyn) - NOT regex
⚠️ IMPORTANT: This documentation was generated using AST parsing, not regex.
Properties
UserId
Unique user identifier
Username
User’s login name
DisplayName
Display name shown in UI
Level
User’s current level
Experience
Total experience points
TotalBuildingsPlaced
Total number of buildings placed
TotalBuildingsRemoved
Total number of buildings removed
TotalPlayTime
Total play time in seconds
LastLoginTime
Unix timestamp of last login
SessionStartTime
Unix timestamp when current session started
TotalSessionTime
Total session time in seconds
Preferences
User preferences and settings
Statistics
User statistics and metrics
Achievements
List of earned achievements
UnlockedBuildings
List of unlocked building types
CompletedTutorials
List of completed tutorials
Permissions
User permissions level
Settings
User settings configuration
Inventory
User inventory and resources
IsGuest
Whether this is a guest user
IsOnline
Whether the user is currently online
LastSaveId
ID of the last save
LastSaveTime
Unix timestamp of last save
ExperienceToNextLevel
Experience needed for next level
LevelProgress
Progress towards next level (0.0 to 1.0)
CurrentSessionDuration
Current session duration in seconds
HasCompletedTutorials
Whether the user has completed any tutorials
HasAchievements
Whether the user has any achievements
HasUnlockedBuildings
Whether the user has unlocked any buildings
TotalBuildingsModified
Total buildings modified (placed + removed)
BuildingsPerHour
Buildings per hour ratio
Methods
AddExperience
Adds experience points to the user
Returns: void
Parameters:
int amount
RecordBuildingPlacement
Records a building placement
Returns: void
Parameters:
string buildingType
RecordBuildingRemoval
Records a building removal
Returns: void
Parameters:
string buildingType
StartSession
Starts a new session
Returns: void
EndSession
Ends the current session
Returns: void
UnlockBuilding
Unlocks a building type
Returns: bool
Parameters:
string buildingType
IsBuildingUnlocked
Checks if a building type is unlocked
Returns: bool
Parameters:
string buildingType
CompleteTutorial
Completes a tutorial
Returns: bool
Parameters:
string tutorialId
IsTutorialCompleted
Checks if a tutorial is completed
Returns: bool
Parameters:
string tutorialId
AddAchievement
Adds an achievement
Returns: bool
Parameters:
UserAchievement achievement
HasAchievement
Checks if an achievement is earned
Returns: bool
Parameters:
string achievementId
GetAchievement
Gets an achievement by ID
Returns: UserAchievement?
Parameters:
string achievementId
SetPreference
Sets a preference value
Returns: void
Parameters:
string keyobject value
GetPreference
Gets a preference value
Returns: T
Parameters:
string keyT defaultValue
HasPreference
Checks if a preference exists
Returns: bool
Parameters:
string key
RemovePreference
Removes a preference
Returns: bool
Parameters:
string key
SetStatistic
Sets a statistic value
Returns: void
Parameters:
string keyobject value
GetStatistic
Gets a statistic value
Returns: T
Parameters:
string keyT defaultValue
IncrementStatistic
Increments a numeric statistic
Returns: void
Parameters:
string keyint amount
HasStatistic
Checks if a statistic exists
Returns: bool
Parameters:
string key
RemoveStatistic
Removes a statistic
Returns: bool
Parameters:
string key
UpdateLastSave
Updates the last save information
Returns: void
Parameters:
string saveId
Clone
Creates a deep copy of this user state
Returns: UserState
Validate
Validates the user state data
Returns: List<string>
ToString
Gets a string representation of the user state
Returns: string
Create
Creates a new user state
Returns: UserState
Parameters:
string username
CreateGuest
Creates a guest user state
Returns: UserState
CreateFromTemplate
Creates a user state from template
Returns: UserState
Parameters:
UserState templatestring newUsername