IPlayerState
An interface in Root.Township, Alta.PlayerStates.
One player state (first join, playing, combat, downed, dead, spirit and so on) held by a player's PlayerStateManager. States can decorate a base state. Implemented by PlayerStateBase; the server decides, clients follow.
- Listed in Players and characters
- Derived types
PlayerStateBase
Properties
| Member | What it is |
|---|---|
AllTransitions AllTransitions { get; } | The transitions this state allows out of it. |
IPlayerState BaseState { get; set; } | The state underneath, when this one decorates another (for example PlayingState under combat). |
IPlayerState Decorator { get; set; } | The state sitting on top of this one, or null. |
bool IsActive { get; } | True while the state is active. |
bool IsDecorated { get; } | In PlayerStateBase this returns true when Decorator is null, so it reads the opposite of its name. Check Decorator instead. |
string Name { get; set; } | Display name for logs. |
Player Player { get; set; } | The player this state belongs to. |
IPlayerStateSettings Settings { get; } | This state's settings from the state settings manager. |
PlayerStateManager StateManager { get; set; } | The player's state manager. |
PlayerStateType StateType { get; } | Which PlayerStateType this is. |
Methods
| Member | What it is |
|---|---|
void Activate() | Starts the state. Runs the server or remote activation hooks depending on side. |
void Deactivate() | Ends the state and runs the matching deactivation hooks. |
void Decorate(IPlayerState baseState, IPlayerState decorator) | Called when a decorating state goes on top; sets Decorator if this is the base state. |
void EditorDrawInspectorGUI() | Editor-only hook for drawing debug info; empty by default. |
void RequestStateChange(PlayerStateType destinationStateType) | Client: asks the server to move this player to another state type. The server calls SetState with it. |
void SerializeDisk(Stream stream) | Reads or writes extra state data for the player save. Empty in the base class. |
void SerializeToRemote(Stream stream) | Extra data for remote sync; only logs in the base class. |
void SyncStateEnter(Stream stream) | Reads or writes extra data sent when the state is entered. |
void SyncStateLeave(Stream stream) | Reads or writes extra data sent when the state is left. |
void Undecorate(IPlayerState baseState, IPlayerState decorator) | Called when a decorating state comes off. |
bool ValidateStateActivation(bool isDuringLoading) | Server: run before activating. Return false to refuse, or switch to another state from here. |
Used in
Members of other types that take, return or hold a IPlayerState:
IPlayerStateFactory.CreateNewPlayerState, PlayerStateBase.BaseState, PlayerStateBase.Decorate, PlayerStateBase.Decorator, PlayerStateBase.OnDecorated, PlayerStateBase.OnDecoratedRemote, PlayerStateBase.OnUndecorated, PlayerStateBase.OnUndecoratedRemote, PlayerStateBase.Undecorate, PlayerStateFactory.CreateNewPlayerState, PlayerStateFactory.FindStateOfType, PlayerStateHandler.BeginInvoke, PlayerStateHandler.Invoke, PlayerStateManager.currentState, PlayerStateManager.CurrentState, PlayerStateManager.DeactivateCurrentStateAndFindCommonBase, PlayerStateManager.EnterNewState, PlayerStateManager.GetCurrentStateOrBase, PlayerStateManager.GetSyncStreamForLeavingState, PlayerStateManager.LoadFromStream, PlayerStateManager.SerializeStateToDisk, PlayerStateManager.SerializeStateToRemote, PlayerStateManager.SetState, PlayerStateManager.WriteToStream, PlayingState.OnDecorated, PlayingState.OnDecoratedRemote, PlayingState.OnUndecorated, PlayingState.OnUndecoratedRemote, RemoteStateTransitionsManager.RemoteStateTransitionsManager, StateTransitionsManager.ClearAllTransitions, StateTransitionsManager.parentState, StateTransitionsManager.StateTransitionsManager, CombatToCombatTransition.TransitionToDestinationState, DeadToPlayingTransition.DestinationPreActivationCallback, DownedToDeadTransition.DestinationPreActivationCallback, IPlayerStateTransition.SourceState, PlayingToCustomizationTransition.TransitionToDestinationState, PlayingToDeadTransition.DestinationPreActivationCallback, PlayingToDownedTransition.DestinationPreActivationCallback, StateTransition<TFrom, TTo>.Alta.PlayerStates.Transitions.IPlayerStateTransition.SourceState, StateTransition<TFrom, TTo>.DestinationPreActivationCallback, StateTransition<TFrom, TTo>.OnTransitionComplete, StateTransition<TFrom, TTo>.sourceState, StateTransition<TFrom, TTo>.SourceState, StateTransition<TFrom, TTo>.TransitionToDestinationState, EquipmentModeQuickAccess.UpdateState, ReturnToMainMenuAction.ShouldBeValid, ReturnToMainMenuAction.UpdateState, StatBarVisibilityGroup.CheckCombatState, StatBarVisibilityGroup.CheckDownedState, StatBarVisibilityGroup.OnStateActivated, StatBarVisibilityGroup.OnStateDeactivated, PlayerUnlockAnalytics.CanSendChallengeEvent, PlayerUnlockAnalytics.SendChallengeExitEvent, PlayerUnlockAnalytics.SendChallengeStartEvent, DiscordController.StateChanged, Player.HandleStateActivation, Player.HandleStateDeactivation, TrialLogic.StateChange.