Class EdgeMovement
Represents the movement of a length 1 edge during one round for the collision check.
If the edge belongs to an expanding or contracting particle, its start and end points will coincide either before or after the movement.
Use the pooling methods Create(Vector2Int, Vector2Int, Vector2Int, Vector2Int) and Release(EdgeMovement) to avoid allocating new memory for every new edge.
Inheritance
Namespace: AS2.Sim
Assembly: .dll
Syntax
public class EdgeMovement
Constructors
| Edit this page View SourceEdgeMovement(Vector2Int, Vector2Int, Vector2Int, Vector2Int)
Declaration
private EdgeMovement(Vector2Int s1, Vector2Int e1, Vector2Int s2, Vector2Int e2)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | s1 | |
Vector2Int | e1 | |
Vector2Int | s2 | |
Vector2Int | e2 |
Fields
| Edit this page View Sourceend1
The end position before the movement.
Declaration
public Vector2Int end1
Field Value
Type | Description |
---|---|
Vector2Int |
end2
The end position after the movement.
Declaration
public Vector2Int end2
Field Value
Type | Description |
---|---|
Vector2Int |
pool
Declaration
private static Stack<EdgeMovement> pool
Field Value
Type | Description |
---|---|
Stack<EdgeMovement> |
start1
The start position before the movement.
Declaration
public Vector2Int start1
Field Value
Type | Description |
---|---|
Vector2Int |
start2
The start position after the movement.
Declaration
public Vector2Int start2
Field Value
Type | Description |
---|---|
Vector2Int |
Methods
| Edit this page View SourceCreate(Vector2Int, Vector2Int, Vector2Int, Vector2Int)
Creates an instance with the given points using pooling.
Declaration
public static EdgeMovement Create(Vector2Int s1, Vector2Int e1, Vector2Int s2, Vector2Int e2)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | s1 | The start location before the movement. |
Vector2Int | e1 | The end location before the movement. |
Vector2Int | s2 | The start location after the movement. |
Vector2Int | e2 | The end location after the movement. |
Returns
Type | Description |
---|---|
EdgeMovement | A newly initialized instance. |
EndTranslation()
Calculates the movement of the edge's end position.
Declaration
public Vector2Int EndTranslation()
Returns
Type | Description |
---|---|
Vector2Int | The vector pointing from the edge's end position before the movement to its position after the movement. |
Release(EdgeMovement)
Releases the given instance into the pool. Use this when the instance is not used any more to recycle the allocated memory.
Declaration
public static void Release(EdgeMovement em)
Parameters
Type | Name | Description |
---|---|---|
EdgeMovement | em | The instance to be reinserted into the pool. |
Reset()
Declaration
public void Reset()
Reset(Vector2Int, Vector2Int, Vector2Int, Vector2Int)
Declaration
public void Reset(Vector2Int s1, Vector2Int e1, Vector2Int s2, Vector2Int e2)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | s1 | |
Vector2Int | e1 | |
Vector2Int | s2 | |
Vector2Int | e2 |
StartTranslation()
Calculates the movement of the edge's start position.
Declaration
public Vector2Int StartTranslation()
Returns
Type | Description |
---|---|
Vector2Int | The vector pointing from the edge's start position before the movement to its position after the movement. |
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. |