DocFX + Singulink = ♥

Class Feature<T>

A strongly-typed constant setting of a SlugBaseCharacter.

Inheritance
object
Feature
Feature<T>
GameFeature<T>
PlayerFeature<T>
Inherited Members
Feature.ID
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SlugBase.Features
Assembly: SlugBase.dll
Syntax
public class Feature<T> : Feature
Type Parameters
Name Description
T

The type that stores this setting's information.

Remarks

PlayerFeature<T> and GameFeature<T> should be used when possible. Otherwise, consider making a child class with a TryGet method that finds the most appropriate SlugBaseCharacter to pass to TryGet(SlugBaseCharacter, out T).

Constructors

View Source

Feature(string, Func<JsonAny, T>)

Creates a new Feature<T> with the given id.

Declaration
public Feature(string id, Func<JsonAny, T> factory)
Parameters
Type Name Description
string id

The JSON key.

Func<JsonAny, T> factory

A delegate that parses JsonAny into T. An exception should be thrown on failure.

Exceptions
Type Condition
ArgumentNullException

factory is null.

ArgumentNullException

id is null.

ArgumentException

A Feature with the given id already exists.

Methods

View Source

TryGet(SlugBaseCharacter, out T)

Gets the T instance assocated with character.

Declaration
public bool TryGet(SlugBaseCharacter character, out T value)
Parameters
Type Name Description
SlugBaseCharacter character

The SlugBaseCharacter that may have this Feature.

T value

The stored setting, or T's default value if the feature wasn't found.

Returns
Type Description
bool

true if character had this feature, false otherwise.