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
View SourcePlayerData(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
View SourceGet(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 |
|---|---|
| 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 |
|---|---|
| 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 |
|---|---|
| bool |
|
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 |
|---|---|
| bool |
|