Class SpawnPolicyBuilder
Builder class for creating SpawnPolicy instances with specific parameters.
Inheritance
Namespace: GUPS.EasyPooling.Policy
Assembly: cs.temp.dll.dll
Syntax
public class SpawnPolicyBuilder
Remarks
The SpawnPolicyBuilder class provides a fluent interface for constructing SpawnPolicy instances with customizable spawning parameters. It encapsulates the configuration of randomization methods, dimensionality (2D or 3D), spawning shape (circle, sphere, or square), center position, radius, boundaries, initial velocity, and velocity direction.
The builder pattern allows the step-by-step definition of a spawning policy, providing flexibility and ease of use.
Constructors
SpawnPolicyBuilder()
Initializes a new instance of the SpawnPolicyBuilder class with the UniformRandom randomization method.
Declaration
public SpawnPolicyBuilder()
SpawnPolicyBuilder(IRandom)
Initializes a new instance of the SpawnPolicyBuilder class with the specified randomization method.
Declaration
public SpawnPolicyBuilder(IRandom _Random)
Parameters
Type | Name | Description |
---|---|---|
IRandom | _Random | The randomization method to use for spawning. |
Methods
Build()
Builds a SpawnPolicy instance with the configured parameters.
Declaration
public SpawnPolicy Build()
Returns
Type | Description |
---|---|
SpawnPolicy | The constructed SpawnPolicy instance. |
Explosion2D(Vector2, Single, Single)
Creates a 2D (on the XY plane) explosion spawn policy with the specified parameters.
Declaration
public static SpawnPolicy Explosion2D(Vector2 _Center, float _Radius, float _Velocity)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | _Center | The center position of the explosion. |
System.Single | _Radius | The radius of the explosion. |
System.Single | _Velocity | The initial velocity of spawned objects. |
Returns
Type | Description |
---|---|
SpawnPolicy | The generated SpawnPolicy. |
Explosion3D(Vector3, Single, Single)
Creates a 3D explosion spawn policy with the specified parameters.
Declaration
public static SpawnPolicy Explosion3D(Vector3 _Center, float _Radius, float _Velocity)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | _Center | The center position of the explosion. |
System.Single | _Radius | The radius of the explosion. |
System.Single | _Velocity | The initial velocity of spawned objects. |
Returns
Type | Description |
---|---|
SpawnPolicy | The generated SpawnPolicy. |
Is2D()
Sets the spawning to 2D mode.
Declaration
public SpawnPolicyBuilder Is2D()
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
Is2D(EPlane)
Sets the spawning to 2D mode.
Declaration
public SpawnPolicyBuilder Is2D(EPlane _Plane)
Parameters
Type | Name | Description |
---|---|---|
EPlane | _Plane | The 2D plane to spawn on. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
Is3D()
Sets the spawning to 3D mode.
Declaration
public SpawnPolicyBuilder Is3D()
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SetCenter(Vector3)
Sets the center position for spawning objects.
Declaration
public SpawnPolicyBuilder SetCenter(Vector3 _Center)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | _Center | The center position. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SetVelocity(Single)
Set the rigidbody velocity of the spawned objects to move aways from the center with the passed velocity.
Declaration
public SpawnPolicyBuilder SetVelocity(float _Velocity)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Velocity | The velocity of the spawned objects. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SetVelocity(Vector3, Single)
Set the rigidbody velocity of the spawned objects to the specified direction and velocity.
Declaration
public SpawnPolicyBuilder SetVelocity(Vector3 _Direction, float _Velocity)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | _Direction | The direction of the velocity. |
System.Single | _Velocity | The velocity of the spawned objects. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInBox()
Sets the spawning shape to a square with boundaries of size one. Every GameObject will be spawned in a square around the center with the boundaries [-1, 1] in each direction.
Declaration
public SpawnPolicyBuilder SpawnInBox()
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInBox(Box)
Sets the spawning shape to a square with the specified minimum and maximum positions. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInBox(Box _Boundaries)
Parameters
Type | Name | Description |
---|---|---|
Box | _Boundaries |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInBox(Vector3)
Sets the spawning shape to a square with the passed boundaries. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInBox(Vector3 _Boundary)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | _Boundary |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInCircle(Single)
Sets the spawning area to a 2D circle (default is the XY plane) with the specified radius. Every GameObject will be spawned in a circle around the center within the specified radius.
Declaration
public SpawnPolicyBuilder SpawnInCircle(float _Radius)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Radius | The radius of the circle. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInCircle(Single, EPlane)
Sets the spawning area to a 2D circle (default is the XY plane) with the specified radius. Every GameObject will be spawned in a circle around the center within the specified radius.
Declaration
public SpawnPolicyBuilder SpawnInCircle(float _Radius, EPlane _Plane)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Radius | The radius of the circle. |
EPlane | _Plane | The 2D plane to spawn on. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInCircle(Single, EPlane, Tuple<Single, Single>)
Sets the spawning area to a 2D circle (default is the XY plane) with the specified radius. Every GameObject will be spawned in a circle around the center within the specified radius.
Declaration
public SpawnPolicyBuilder SpawnInCircle(float _Radius, EPlane _Plane, Tuple<float, float> _Limit)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Radius | The radius of the circle. |
EPlane | _Plane | The 2D plane to spawn on. |
System.Tuple<System.Single, System.Single> | _Limit |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInCircle(Single, EPlane, Tuple<Single, Single>[])
Sets the spawning area to a 2D circle (default is the XY plane) with the specified radius. Every GameObject will be spawned in a circle around the center within the specified radius.
Declaration
public SpawnPolicyBuilder SpawnInCircle(float _Radius, EPlane _Plane, Tuple<float, float>[] _Limits)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Radius | The radius of the circle. |
EPlane | _Plane | The 2D plane to spawn on. |
System.Tuple<System.Single, System.Single>[] | _Limits | The spawn limits of the circle in radian [0, 2pi]. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSphere(Single)
Sets the spawning area to a 3D sphere with the specified radius. Every GameObject will be spawned in a sphere around the center within the specified radius.
Declaration
public SpawnPolicyBuilder SpawnInSphere(float _Radius)
Parameters
Type | Name | Description |
---|---|---|
System.Single | _Radius | The radius of the circle. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSquare()
Sets the spawning area to a 2D square (the default is the XY plane) with boundaries of size one. Every GameObject will be spawned in a square around the center with the boundaries [-1, 1] in each direction.
Declaration
public SpawnPolicyBuilder SpawnInSquare()
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSquare(Rect)
Sets the spawning area to a 2D square (the default is the XY plane) with the passed boundaries. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInSquare(Rect _Boundaries)
Parameters
Type | Name | Description |
---|---|---|
Rect | _Boundaries | The size of the square. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSquare(Rect, EPlane)
Sets the spawning area to a 2D square (the default is the XY plane) with the passed boundaries. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInSquare(Rect _Boundaries, EPlane _Plane)
Parameters
Type | Name | Description |
---|---|---|
Rect | _Boundaries | The size of the square. |
EPlane | _Plane | The 2D plane to spawn on. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSquare(Vector2)
Sets the spawning area to a 2D square (the default is the XY plane) with the passed boundaries. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInSquare(Vector2 _Boundary)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | _Boundary | The size of the square. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |
SpawnInSquare(Vector2, EPlane)
Sets the spawning area to a 2D square (the default is the XY plane) with the passed boundaries. Every GameObject will be spawned in a square around the center within the passed boundaries.
Declaration
public SpawnPolicyBuilder SpawnInSquare(Vector2 _Boundary, EPlane _Plane)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | _Boundary | The size of the square. |
EPlane | _Plane | The 2D plane to spawn on. |
Returns
Type | Description |
---|---|
SpawnPolicyBuilder | The updated SpawnPolicyBuilder instance. |