Class ParticleAttributeFactory
Factory class for creating and initializing ParticleAttribute<T> subclass instances.
Inheritance
Namespace: AS2.Sim
Assembly: .dll
Syntax
public static class ParticleAttributeFactory
Methods
| Edit this page View SourceCheckAttributeName(string)
Checks whether the given attribute name is valid and throws an exception if it is not.
Invalid attribute names are "Chirality"
and
"Compass Dir"
because these names are used by the
particle panel to represent a particle's chirality and
compass direction, which are not actually attributes.
Declaration
private static void CheckAttributeName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The attribute names to check. |
CheckParticleInConstruction(Particle)
Checks whether the given particle is currently in construction or
null
and throws an exception otherwise. This is done to
prevent attributes from being created outside of the constructor.
Declaration
private static void CheckParticleInConstruction(Particle p)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The particle to check. |
CreateParticleAttribute(Particle, Type, string, object)
Creates a particle attribute matching the desired type if a corresponding attribute type exists. The attribute is not added to the given particle's list of attributes.
Declaration
public static IParticleAttribute CreateParticleAttribute(Particle p, Type type, string name, object initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The particle holding the attribute. |
Type | type | The data type stored by the attribute. |
string | name | The name of the attribute. |
object | initialValue | The initial value of the attribute. If |
Returns
Type | Description |
---|---|
IParticleAttribute | A new attribute instance if the type could be matched,
otherwise |
CreateParticleAttributeBool(Particle, string, bool)
Creates a new ParticleAttribute_Bool and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_Bool CreateParticleAttributeBool(Particle p, string name, bool initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
bool | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_Bool | A newly initialized ParticleAttribute_Bool. |
CreateParticleAttributeDirection(Particle, string, Direction)
Creates a new ParticleAttribute_Direction and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_Direction CreateParticleAttributeDirection(Particle p, string name, Direction initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
Direction | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_Direction | A newly initialized ParticleAttribute_Direction. |
CreateParticleAttributeEnum<EnumT>(Particle, string, EnumT)
Creates a new ParticleAttribute_Enum<T> and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_Enum<EnumT> CreateParticleAttributeEnum<EnumT>(Particle p, string name, EnumT initialValue) where EnumT : Enum
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
EnumT | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_Enum<EnumT> | A newly initialized ParticleAttribute_Enum<T>. |
Type Parameters
Name | Description |
---|---|
EnumT | The enum type represented by the attribute. |
CreateParticleAttributeFloat(Particle, string, float)
Creates a new ParticleAttribute_Float and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_Float CreateParticleAttributeFloat(Particle p, string name, float initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
float | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_Float | A newly initialized ParticleAttribute_Float. |
CreateParticleAttributeInt(Particle, string, int)
Creates a new ParticleAttribute_Int and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_Int CreateParticleAttributeInt(Particle p, string name, int initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
int | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_Int | A newly initialized ParticleAttribute_Int. |
CreateParticleAttributePinConfiguration(Particle, string, PinConfiguration)
Creates a new ParticleAttribute_PinConfiguration and adds it to the given Particle's list of attributes.
Note the usage remarks of the ParticleAttribute_PinConfiguration class.
Declaration
public static ParticleAttribute_PinConfiguration CreateParticleAttributePinConfiguration(Particle p, string name, PinConfiguration initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
PinConfiguration | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_PinConfiguration | A newly initialized ParticleAttribute_PinConfiguration. |
CreateParticleAttributeString(Particle, string, string)
Creates a new ParticleAttribute_String and adds it to the given Particle's list of attributes.
Declaration
public static ParticleAttribute_String CreateParticleAttributeString(Particle p, string name, string initialValue)
Parameters
Type | Name | Description |
---|---|---|
Particle | p | The Particle to which the attribute should belong. |
string | name | The display name of the attribute. |
string | initialValue | The initial attribute value. |
Returns
Type | Description |
---|---|
ParticleAttribute_String | A newly initialized ParticleAttribute_String. |