Class ParticleAttribute_Enum<T>
ParticleAttribute<T> subclass representing enum values.
To use this attribute, simply create an enum
and use it
as the attribute's type parameter:
public enum State { IDLE, ROOT, LEADER }
public class MyParticleAlgo : ParticleAlgorithm {
public ParticleAttribute_Enum<State> myEnumAttr;
public MyParticleAlgo(Particle p) : base(p) {
myEnumAttr = new ParticleAttribute_Enum<State>(this, "Fancy display name", State.IDLE);
}
}
Inheritance
Namespace: AS2.Sim
Assembly: .dll
Syntax
public class ParticleAttribute_Enum<T> : ParticleAttributeWithHistory<T>, IParticleAttribute, IReplayHistory where T : Enum
Type Parameters
Name | Description |
---|---|
T | The enum type to represent. |
Constructors
| Edit this page View SourceParticleAttribute_Enum(Particle, string, T)
Declaration
public ParticleAttribute_Enum(Particle particle, string name, T initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | particle | |
string | name | |
T | initialValue |
Properties
| Edit this page View SourceValue
Declaration
private T Value { get; set; }
Property Value
Type | Description |
---|---|
T |
Methods
| Edit this page View SourceEquals(ParticleAttribute<T>)
Indicates whether the current object is equal to another object of the same type.
Declaration
public override bool Equals(ParticleAttribute<T> other)
Parameters
Type | Name | Description |
---|---|---|
ParticleAttribute<T> | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Overrides
| Edit this page View SourceGenerateSaveData()
Implementation of GenerateSaveData(). Generates data specifically for enum attributes, which includes the name of the enum type so that it can be restored when loading.
Declaration
public override ParticleAttributeSaveDataBase GenerateSaveData()
Returns
Type | Description |
---|---|
ParticleAttributeSaveDataBase | A serializable representation of the attribute's state. |
Overrides
| Edit this page View SourceGetCurrentValue()
Returns the latest value of this attribute.
The return value changes based on value assignments made within this activation. Use GetValue() to get the attribute's value at the beginning of the current round.
Declaration
public override T GetCurrentValue()
Returns
Type | Description |
---|---|
T | The latest value of this attribute. |
Overrides
| Edit this page View SourceGetValue()
Returns the attribute's value from the snapshot taken at the beginning of the current round.
The return value is not changed by assigning new values to this attribute! To get the latest assigned value, use GetCurrentValue().
Declaration
public override T GetValue()
Returns
Type | Description |
---|---|
T | The attribute value at the beginning of the current round. |
Overrides
| Edit this page View SourceRestoreFromSaveData(ParticleAttributeSaveDataBase)
Implementation of RestoreFromSaveData(ParticleAttributeSaveDataBase). Uses additional information stored in specific enum attribute save data to restore the correct enum type.
Declaration
public override bool RestoreFromSaveData(ParticleAttributeSaveDataBase data)
Parameters
Type | Name | Description |
---|---|---|
ParticleAttributeSaveDataBase | data | A serializable representation of a particle attribute state. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceSetRandomValue()
Sets the attribute's value to a random value if the attribute type allows this.
Declaration
public bool SetRandomValue()
Returns
Type | Description |
---|---|
bool |
|
SetValue(T)
Assigns the given value to this attribute.
Note that this value will only be visible to other particles in the next round.
Declaration
public override void SetValue(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The new value assigned to this attribute. |
Overrides
| Edit this page View SourceToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
ToString_AttributeValue()
String representation of the attribute's current value.
Declaration
public string ToString_AttributeValue()
Returns
Type | Description |
---|---|
string | A string containing the attribute's current value. |
UpdateAttributeValue(string)
Updates the attribute's value to the one represented by the given string.
Declaration
public bool UpdateAttributeValue(string value)
Parameters
Type | Name | Description |
---|---|---|
string | value | String representation of the new value. |
Returns
Type | Description |
---|---|
bool |
|