Search Results for

    Show / Hide Table of Contents

    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
    object
    ParticleAttributeBase
    ParticleAttribute<T>
    ParticleAttributeWithHistory<T>
    ParticleAttribute_Enum<T>
    Implements
    IParticleAttribute
    IReplayHistory
    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 Source

    ParticleAttribute_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 Source

    Value

    Declaration
    private T Value { get; set; }
    Property Value
    Type Description
    T

    Methods

    | Edit this page View Source

    Equals(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 other parameter; otherwise, false.

    Overrides
    ParticleAttribute<T>.Equals(ParticleAttribute<T>)
    | Edit this page View Source

    GenerateSaveData()

    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
    ParticleAttributeWithHistory<T>.GenerateSaveData()
    | Edit this page View Source

    GetCurrentValue()

    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
    ParticleAttribute<T>.GetCurrentValue()
    | Edit this page View Source

    GetValue()

    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
    ParticleAttribute<T>.GetValue()
    | Edit this page View Source

    RestoreFromSaveData(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

    true if and only if the state update was successful.

    Overrides
    ParticleAttributeWithHistory<T>.RestoreFromSaveData(ParticleAttributeSaveDataBase)
    | Edit this page View Source

    SetRandomValue()

    Sets the attribute's value to a random value if the attribute type allows this.

    Declaration
    public bool SetRandomValue()
    Returns
    Type Description
    bool

    true if and only if the value was updated successfully.

    | Edit this page View Source

    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
    ParticleAttribute<T>.SetValue(T)
    | Edit this page View Source

    ToString()

    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
    object.ToString()
    | Edit this page View Source

    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.

    | Edit this page View Source

    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

    true if and only if the given string was parsed successfully.

    Implements

    IParticleAttribute
    IReplayHistory
    • Edit this page
    • View Source
    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX