Interface IEnvironment<TEntity>
Common environment interface to store entity type within a spatial index.
Assembly: Mars.Interfaces.dll
Syntax
public interface IEnvironment<TEntity> : IEnvironment, IModelObject where TEntity : IEntity, IPositionable
Type Parameters
Name |
Description |
TEntity |
The type of the concrete entity implementing IEntity |
Methods
Explore(Position, Double, Int32, Func<TEntity, Boolean>)
Queries the a set of nearest entities around the
position
with with optional specified radius
and count for the positioning system of the
IEnvironment.
Declaration
IEnumerable<TEntity> Explore(Position position = null, double radius = null, int count = null, Func<TEntity, bool> predicate = null)
Parameters
Type |
Name |
Description |
Position |
position |
The Position from which the exploration shall be started. |
System.Double |
radius |
The range of the exploration circle. |
System.Int32 |
count |
The amount of entities to find. |
Func<TEntity, System.Boolean> |
predicate |
A predicate to select only specific entities based on a condition. |
Returns
Type |
Description |
IEnumerable<TEntity> |
An distance based order from the nearest entity to tha farthest |
Explore(Double, Double, Double, Int32, Func<TEntity, Boolean>)
Queries the environment for entities of type from a specified position in form
of a 2D coordinate (x,y). The query can be restricted by optional passed query limit and the radius to lookup.
Also the lookup in up-/downwards or in right/leftwards can be configured.
Declaration
IEnumerable<TEntity> Explore(double x, double y, double radius = null, int count = null, Func<TEntity, bool> predicate = null)
Parameters
Type |
Name |
Description |
System.Double |
x |
The outgoing x coordinate. |
System.Double |
y |
The outgoing y coordinate. |
System.Double |
radius |
Optional radius interpreted as euclidean coordinate distance. |
System.Int32 |
count |
Optional limit of entities to query. |
Func<TEntity, System.Boolean> |
predicate |
Optional predicate which will be applied during query execution
to filter out entities matching a specific condition.
|
Returns
Type |
Description |
IEnumerable<TEntity> |
Returns a collection of distance-based ordered entities of type . |
Explore(Double[], Double, Int32, Func<TEntity, Boolean>)
Queries the a set of nearest entities around the with
with optional specified radius and count
Declaration
IEnumerable<TEntity> Explore(double[] position, double radius = null, int count = null, Func<TEntity, bool> predicate = null)
Parameters
Type |
Name |
Description |
System.Double[] |
position |
The discrete position from which the exploration shall be calculated |
System.Double |
radius |
The radius of exploration range |
System.Int32 |
count |
The amount of entities to find |
Func<TEntity, System.Boolean> |
predicate |
A predicate to filter specific entities |
Returns
Type |
Description |
IEnumerable<TEntity> |
An distance based order from the nearest entity to tha farthest |
Insert(TEntity)
Inserts an positionable entity into the environment defined by their
Declaration
bool Insert(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity to passionate. |
Returns
Type |
Description |
System.Boolean |
Returns True if the entity was successfully inserted |
MoveTo(TEntity, Position, Double, Func<Double[], Boolean>)
Moves an
entity
to the destination of type
Position along an optimal ray path with
minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
Position MoveTo(TEntity entity, Position position, double distance = null, Func<double[], bool> predicate = null)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity to move. |
Position |
position |
The target destination coordinate. |
System.Double |
distance |
The distance to move |
Func<System.Double[], System.Boolean> |
predicate |
The predicate along the movement which need to be valid or null |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
MoveTo(TEntity, Double, Double, Double, Func<Double[], Boolean>)
Moves an entity
to the destination along an optimal ray path with
minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
Position MoveTo(TEntity entity, double x, double y, double distance = null, Func<double[], bool> predicate = null)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity to move |
System.Double |
x |
The x coordinate of the destination. |
System.Double |
y |
The y coordinate of the destination. |
System.Double |
distance |
The distance to move |
Func<System.Double[], System.Boolean> |
predicate |
The predicate along the movement which need to be valid or null |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
MoveTo(TEntity, Double[], Double, Func<Double[], Boolean>)
Moves an entity
to destination along an optimal path with
minimal costs. Note that his method does not guarantee to reach the destination.
Declaration
Position MoveTo(TEntity entity, double[] position = null, double distanceInMeter = null, Func<double[], bool> predicate = null)
Parameters
Type |
Name |
Description |
TEntity |
entity |
|
System.Double[] |
position |
The discrete position target |
System.Double |
distanceInMeter |
The distance to move |
Func<System.Double[], System.Boolean> |
predicate |
The predicate along the movement which need to be valid or null |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
MoveTowards(TEntity, DirectionType, Double)
Moves an entity
the travelling distance distanceToPass
towards the direction
with a fixed bearing.
Declaration
Position MoveTowards(TEntity entity, DirectionType direction, double distanceToPass = null)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity to move |
DirectionType |
direction |
One of the eight direction on a 2D plane, including diagonal |
System.Double |
distanceToPass |
The distance units to pass. |
Returns
Type |
Description |
Position |
Returns the new position of the entity or null if no positioning happened.
|
MoveTowards(TEntity, Double, Double)
Moves an entity
the travelling distance distanceToPass
towards the bearing
direction.
Declaration
Position MoveTowards(TEntity entity, double bearing, double distanceToPass = null)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity to move |
System.Double |
bearing |
The bearing in degree in value range 0-360 |
System.Double |
distanceToPass |
The distance units to pass. |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
PosAt(TEntity, Double, Double)
Moves an entity
to the desired destination.
Declaration
Position PosAt(TEntity entity, double x, double y)
Parameters
Type |
Name |
Description |
TEntity |
entity |
the object to move |
System.Double |
x |
The x coordinate of the destination. |
System.Double |
y |
The y coordinate of the destination. |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
PosAt(TEntity, Double[])
Set the entity
exactly at the desired position without any movement actions.
Declaration
Position PosAt(TEntity entity, double[] position)
Parameters
Type |
Name |
Description |
TEntity |
entity |
the object to move |
System.Double[] |
position |
The coordinates of the position to position to |
Returns
Type |
Description |
Position |
Returns the new position of the entity > or null if no positioning happened. |
Remove(TEntity)
Removes the entity item from the environment at the defined
Position
over the
IPositionable implementation of
entity
.
Declaration
bool Remove(TEntity entity)
Parameters
Type |
Name |
Description |
TEntity |
entity |
The entity and position to remove |
Returns
Type |
Description |
System.Boolean |
Returns True if the entity was successfully removed |