Class PlayerData<TValue>
Stores per-player variables.
Inherited Members
Namespace: SlugBase.Features
Assembly: SlugBase.dll
Syntax
public class PlayerData<TValue> : Data<PlayerState, TValue> where TValue : new()
Type Parameters
Name | Description |
---|---|
TValue | The type of data stored. |
Constructors
PlayerData(Feature)
Creates a new per-player variable that depends on requiredFeature
.
Declaration
public PlayerData(Feature requiredFeature)
Parameters
Type | Name | Description |
---|---|---|
Feature | requiredFeature | The required Feature, or |
Methods
Get(Player)
Gets the TValue
instance assocated with player
, constructing it if it does not exist.
If the game's SlugBaseCharacter does not have RequiredFeature, then null
is returned.
Declaration
public StrongBox<TValue> Get(Player player)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The player the variable is associated with. |
Returns
Type | Description |
---|---|
System.Runtime.CompilerServices.StrongBox<TValue> |
Get(PlayerState)
Gets the TValue
instance assocated with state
, constructing it if it does not exist.
If the game's SlugBaseCharacter does not have RequiredFeature, then null
is returned.
Declaration
public StrongBox<TValue> Get(PlayerState state)
Parameters
Type | Name | Description |
---|---|---|
PlayerState | state | The player state the variable is associated with. |
Returns
Type | Description |
---|---|
System.Runtime.CompilerServices.StrongBox<TValue> |
TryGet(Player, out TValue)
Gets the TValue
instance assocated with player
, constructing it if it does not exist.
Declaration
public bool TryGet(Player player, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
Player | player | The player the variable is associated with. |
TValue | value | The stored value, or |
Returns
Type | Description |
---|---|
System.Boolean |
|
TryGet(PlayerState, out TValue)
Gets the TValue
instance assocated with state
, constructing it if it does not exist.
Declaration
public bool TryGet(PlayerState state, out TValue value)
Parameters
Type | Name | Description |
---|---|---|
PlayerState | state | The player state the variable is associated with. |
TValue | value | The stored value, or |
Returns
Type | Description |
---|---|
System.Boolean |
|