Class Data<THolder, TValue>
Stores TValue
s associated with THolder
s.
Inherited Members
Namespace: SlugBase.Features
Assembly: SlugBase.dll
Syntax
public class Data<THolder, TValue> : Data where THolder : class where TValue : new()
Type Parameters
Name | Description |
---|---|
THolder | The key type that values are associated with. |
TValue | The type of data stored. |
Remarks
PlayerData<TValue> and GameData<TValue> should be used when possible.
Otherwise, consider making a child class with Get
and TryGet
methods that find the most
appropriate SlugBaseCharacter to pass to Get(SlugBaseCharacter, THolder).
Constructors
Data(Feature)
Creates a new instance of Data<THolder, TValue> that depends on requiredFeature
.
Declaration
public Data(Feature requiredFeature)
Parameters
Type | Name | Description |
---|---|---|
Feature | requiredFeature | The required Feature, or |
Remarks
PlayerData<TValue> and GameData<TValue> should be used when possible.
Otherwise, consider making a child class with Get
and TryGet
methods that find the most
appropriate SlugBaseCharacter to pass to Get(SlugBaseCharacter, THolder).
Methods
Get(SlugBaseCharacter, THolder)
Gets the TValue
instance assocated with key
, constructing it if it does not exist.
If character
does not have RequiredFeature, then null
is returned.
Declaration
public StrongBox<TValue> Get(SlugBaseCharacter character, THolder key)
Parameters
Type | Name | Description |
---|---|---|
SlugBaseCharacter | character | The SlugBaseCharacter that may own RequiredFeature. |
THolder | key | The key the data is attached to. |
Returns
Type | Description |
---|---|
System.Runtime.CompilerServices.StrongBox<TValue> |
Remarks
PlayerData<TValue> and GameData<TValue> should be used when possible.
Otherwise, consider making a child class with Get
and TryGet
methods that find the most
appropriate SlugBaseCharacter to pass to Get(SlugBaseCharacter, THolder).