Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Collider Class Reference

The base class used for collision detection. Entities contain Colliders that can check for collisions which each other. Note that some functions for detecting collisions can take generic Enums as their tags. Be aware that these functions are slightly slower than casting your Enums to int for the int tags functions. More...

Inherited by Otter.BoxCollider, Otter.CircleCollider, Otter.GridCollider, Otter.LineCollider, Otter.PixelCollider, Otter.PointCollider, and Otter.PolygonCollider.

Public Member Functions

bool Overlap (float x, float y, int px, int py)
 Checks for a collision with a specific point. More...
 
bool Overlap (float x, float y, params int[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, Collider c)
 Checks for a collision against a specific Collider and returns true or false. More...
 
bool Overlap (float x, float y, Entity e)
 Checks for a collision against a specific Entity and returns true or false. More...
 
bool Overlap (float x, float y, List< int > tags)
 Checks for a collision against a list of Collliders and returns true or false. More...
 
bool Overlap (float x, float y, params Enum[] tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Enum > tags)
 Checks for a collision against the specified tags and returns true or false. More...
 
bool Overlap (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
bool Overlap< T > (float x, float y, List< T > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide (float x, float y, List< Entity > entities)
 Checks for a collision against a list of Entities and all of their colliders. More...
 
Collider Collide< T > (float x, float y, List< T > entities)
 
Collider Collide (float x, float y, params int[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, params Enum[] tags)
 Checks for a collision against specified tags. More...
 
Collider Collide (float x, float y, Collider c)
 Checks for a collision with a specific collider. More...
 
Collider Collide (float x, float y, Entity e)
 Checks for a collision with a specific entity. More...
 
Collider Collide (float x, float y, List< int > tags)
 Checks for a collision with a list of tags. More...
 
Collider Collide (float x, float y, List< Enum > tags)
 Checks for a collision with a list of tags. More...
 
Entity CollideEntity (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params int[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, params Enum[] tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Entity e)
 Checks for a collision with a specific Entity and returns an Entity. More...
 
Entity CollideEntity (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
CollideEntity< T > (float x, float y, Collider c)
 Checks for a collision with a specific Collider and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< int > tags)
 Checks for a collision with a list of tags and returns an Entity. More...
 
Entity CollideEntity (float x, float y, List< Entity > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
CollideEntity< T > (float x, float y, List< T > entities)
 Checks for a collision with a list of Entities and returns an Entity. More...
 
List< ColliderCollideList (float x, float y, params int[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, params Enum[] tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< Enum > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< ColliderCollideList (float x, float y, List< int > tags)
 Creates a list of Colliders that this Collider is colliding with. More...
 
List< EntityCollideEntities (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params int[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, params Enum[] tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< Enum > tags)
 Creates a list of Entities that the Collider has collided with. More...
 
List< T > CollideEntities< T > (float x, float y, List< T > entities)
 Creates a list of Entities that the Collider has collided with. More...
 
List< EntityCollideEntities (float x, float y, List< int > tags)
 Creates a list of entities that the Collider has collided with. More...
 
virtual void Added ()
 Callback for when the Collider has been added to an Entity. More...
 
virtual void Removed ()
 Callback for when the Collider has been removed from an Entity. More...
 
virtual void Render (Color color=null)
 Callback for when the Collider renders (usually for debugging purposes.) More...
 
Collider AddTag (int tag)
 Add a new tag to the Collider. More...
 
Collider AddTag (params Enum[] tags)
 Add new tags to the Collider. More...
 
bool HasTag (params Enum[] tags)
 
bool HasTag (params int[] tags)
 
Collider AddTag (params int[] tags)
 Add new tags to the Collider. More...
 
Collider RemoveTag (int tag)
 Remove a tag from the Collider. More...
 
Collider RemoveTag (params int[] tags)
 Remove tags from the Collider. More...
 
Collider RemoveTag (params Enum[] tags)
 Remove tags from the Collider. More...
 
virtual void CenterOrigin ()
 Center the origin of the Collider. Based off of Width and Height. More...
 
void SetPosition (float x, float y)
 Set the positon of the Collider. More...
 
void SetPosition (Vector2 xy)
 Set the position of the Collider. More...
 
void SetOrigin (float x, float y)
 Set the origin of the Collider More...
 
void SetOrigin (Vector2 xy)
 Set the origin of the Collider. More...
 

Public Attributes

float X
 The X position of the Collider relative to the Entity. More...
 
float Y
 The Y position of the Collider relative to the Entity. More...
 
float OriginX
 The OriginX of the Collider. More...
 
float OriginY
 The OriginY of the Collider. More...
 
Entity Entity
 The entity that this collider is parented to. More...
 
bool Collidable = true
 Determines if this collider is collidable. If false, it will not register collisions with other colliders, but can still check for collisions with other colliders. More...
 

Properties

List< int > Tags [get, set]
 The tags that this Collider is registered with. More...
 
virtual float Width [get, set]
 The width of the Collider. More...
 
virtual float Height [get, set]
 The height of the Collider. More...
 
virtual float CenterX [get]
 The X position of the center of the Collider. More...
 
virtual float CenterY [get]
 The Y position of the center of the Collider. More...
 
virtual float Left [get]
 The X position of the left side of the Collider. More...
 
virtual float Right [get]
 The X position of the right side of the Collider. More...
 
virtual float Top [get]
 The Y position of the top of the Collider. More...
 
virtual float Bottom [get]
 The Y position of the bottom of the Collider. More...
 
float HalfHeight [get]
 Half of the Collider's height. More...
 
float HalfWidth [get]
 Half of the Collider's width. More...
 

Detailed Description

The base class used for collision detection. Entities contain Colliders that can check for collisions which each other. Note that some functions for detecting collisions can take generic Enums as their tags. Be aware that these functions are slightly slower than casting your Enums to int for the int tags functions.

Member Function Documentation

virtual void Otter.Collider.Added ( )
virtual

Callback for when the Collider has been added to an Entity.

Collider Otter.Collider.AddTag ( int  tag)

Add a new tag to the Collider.

Parameters
tagThe tag to add.
Returns
The Collider.
Collider Otter.Collider.AddTag ( params Enum[]  tags)

Add new tags to the Collider.

Parameters
tagsThe tags to add.
Returns
The Collider.
Collider Otter.Collider.AddTag ( params int[]  tags)

Add new tags to the Collider.

Parameters
tagsThe tags to add.
Returns
The Collider.
virtual void Otter.Collider.CenterOrigin ( )
virtual

Center the origin of the Collider. Based off of Width and Height.

Collider Otter.Collider.Collide ( float  x,
float  y,
List< Entity entities 
)

Checks for a collision against a list of Entities and all of their colliders.

Parameters
xThe x position to check.
yThe y position to check.
entitiesThe Entities to check.
Returns
True if there was a collision.
Collider Otter.Collider.Collide ( float  x,
float  y,
params int[]  tags 
)

Checks for a collision against specified tags.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The collider that was hit first.
Collider Otter.Collider.Collide ( float  x,
float  y,
params Enum[]  tags 
)

Checks for a collision against specified tags.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The collider that was hit first.
Collider Otter.Collider.Collide ( float  x,
float  y,
Collider  c 
)

Checks for a collision with a specific collider.

Parameters
xThe x position to check.
yThe y position to check.
cThe collider to check for.
Returns
The collider that was hit first.
Collider Otter.Collider.Collide ( float  x,
float  y,
Entity  e 
)

Checks for a collision with a specific entity.

Parameters
xThe x position to check.
yThe y position to check.
eThe entity to check for.
Returns
The collider that was hit.
Collider Otter.Collider.Collide ( float  x,
float  y,
List< int >  tags 
)

Checks for a collision with a list of tags.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Collider that was hit.
Collider Otter.Collider.Collide ( float  x,
float  y,
List< Enum >  tags 
)

Checks for a collision with a list of tags.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Collider that was hit.
List<Entity> Otter.Collider.CollideEntities ( float  x,
float  y,
params int[]  tags 
)

Creates a list of Entities that the Collider has collided with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
List<Entity> Otter.Collider.CollideEntities ( float  x,
float  y,
params Enum[]  tags 
)

Creates a list of Entities that the Collider has collided with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
List<Entity> Otter.Collider.CollideEntities ( float  x,
float  y,
List< Enum >  tags 
)

Creates a list of Entities that the Collider has collided with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
List<Entity> Otter.Collider.CollideEntities ( float  x,
float  y,
List< int >  tags 
)

Creates a list of entities that the Collider has collided with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
List<T> Otter.Collider.CollideEntities< T > ( float  x,
float  y,
params int[]  tags 
)

Creates a list of Entities that the Collider has collided with.

Template Parameters
TThe type of list to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
Type Constraints
T :Entity 
List<T> Otter.Collider.CollideEntities< T > ( float  x,
float  y,
params Enum[]  tags 
)

Creates a list of Entities that the Collider has collided with.

Template Parameters
TThe type of list to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
Type Constraints
T :Entity 
List<T> Otter.Collider.CollideEntities< T > ( float  x,
float  y,
List< Enum >  tags 
)

Creates a list of Entities that the Collider has collided with.

Template Parameters
TThe type of list to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of entities.
Type Constraints
T :Entity 
List<T> Otter.Collider.CollideEntities< T > ( float  x,
float  y,
List< T >  entities 
)

Creates a list of Entities that the Collider has collided with.

Template Parameters
TThe type of Entity.
Parameters
xThe x position to check.
yThe y position to check.
entitiesThe Entities to check.
Returns
A list of entities.
Type Constraints
T :Entity 
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
params int[]  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Entity that was hit.
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
params Enum[]  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Entity that was hit.
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
Entity  e 
)

Checks for a collision with a specific Entity and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
eThe Entity to check for.
Returns
The Entity that was hit.
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
Collider  c 
)

Checks for a collision with a specific Collider and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
cThe Collider to check for.
Returns
The Entity that was hit.
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
List< int >  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe list of tags to check.
Returns
The Entity that was hit.
Entity Otter.Collider.CollideEntity ( float  x,
float  y,
List< Entity entities 
)

Checks for a collision with a list of Entities and returns an Entity.

Parameters
xThe x position to check.
yThe y position to check.
entitiesThe list of Entities to check.
Returns
The Entity that was hit.
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
params int[]  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
params Enum[]  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
Entity  e 
)

Checks for a collision with a specific Entity and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
eThe Entity to check for.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
Collider  c 
)

Checks for a collision with a specific Collider and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
cThe Collider to check for.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
List< int >  tags 
)

Checks for a collision with a list of tags and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
tagsThe list of tags to check.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
T Otter.Collider.CollideEntity< T > ( float  x,
float  y,
List< T >  entities 
)

Checks for a collision with a list of Entities and returns an Entity.

Template Parameters
TThe type of Entity to return.
Parameters
xThe x position to check.
yThe y position to check.
entitiesThe list of Entities to check.
Returns
The Entity that was hit.
Type Constraints
T :Entity 
List<Collider> Otter.Collider.CollideList ( float  x,
float  y,
params int[]  tags 
)

Creates a list of Colliders that this Collider is colliding with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of colliders.
List<Collider> Otter.Collider.CollideList ( float  x,
float  y,
params Enum[]  tags 
)

Creates a list of Colliders that this Collider is colliding with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of colliders.
List<Collider> Otter.Collider.CollideList ( float  x,
float  y,
List< Enum >  tags 
)

Creates a list of Colliders that this Collider is colliding with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of colliders.
List<Collider> Otter.Collider.CollideList ( float  x,
float  y,
List< int >  tags 
)

Creates a list of Colliders that this Collider is colliding with.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
A list of colliders.
bool Otter.Collider.Overlap ( float  x,
float  y,
int  px,
int  py 
)

Checks for a collision with a specific point.

Parameters
xThe x position to check.
yThe y position to check.
pxThe x of the point to check.
pyThe y of the point to check.
Returns
True if the Collider at position x, y overlaps px, py.
bool Otter.Collider.Overlap ( float  x,
float  y,
params int[]  tags 
)

Checks for a collision against the specified tags and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
Collider  c 
)

Checks for a collision against a specific Collider and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
cThe Collider to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
Entity  e 
)

Checks for a collision against a specific Entity and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
eThe Collider to check.
Returns
True of there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
List< int >  tags 
)

Checks for a collision against a list of Collliders and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe list of colliders to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
params Enum[]  tags 
)

Checks for a collision against the specified tags and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
List< Enum >  tags 
)

Checks for a collision against the specified tags and returns true or false.

Parameters
xThe x position to check.
yThe y position to check.
tagsThe tags to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap ( float  x,
float  y,
List< Entity entities 
)

Checks for a collision against a list of Entities and all of their colliders.

Parameters
xThe x position to check.
yThe y position to check.
entitiesThe Entities to check.
Returns
True if there was a collision.
bool Otter.Collider.Overlap< T > ( float  x,
float  y,
List< T >  entities 
)

Checks for a collision against a list of Entities and all of their colliders.

Template Parameters
TThe type of entity to check.
Parameters
xThe x position to check.
yThe y position to check.
entitiesThe Entities to check.
Returns
True if there was a collision.
Type Constraints
T :Entity 
virtual void Otter.Collider.Removed ( )
virtual

Callback for when the Collider has been removed from an Entity.

Collider Otter.Collider.RemoveTag ( int  tag)

Remove a tag from the Collider.

Parameters
tagThe tags to remove.
Returns
The Collider.
Collider Otter.Collider.RemoveTag ( params int[]  tags)

Remove tags from the Collider.

Parameters
tagsThe tags to remove.
Returns
The Collider.
Collider Otter.Collider.RemoveTag ( params Enum[]  tags)

Remove tags from the Collider.

Parameters
tagsThe tags to remove.
Returns
The Collider.
virtual void Otter.Collider.Render ( Color  color = null)
virtual

Callback for when the Collider renders (usually for debugging purposes.)

Reimplemented in Otter.GridCollider, Otter.PixelCollider, Otter.PolygonCollider, Otter.LineCollider, Otter.CircleCollider, Otter.BoxCollider, and Otter.PointCollider.

void Otter.Collider.SetOrigin ( float  x,
float  y 
)

Set the origin of the Collider

Parameters
xThe X origin of the Collider.
yThe Y origin of the Collider.
void Otter.Collider.SetOrigin ( Vector2  xy)

Set the origin of the Collider.

Parameters
xyThe Vector2 origin of the Collider.
void Otter.Collider.SetPosition ( float  x,
float  y 
)

Set the positon of the Collider.

Parameters
xThe X position of the Collider.
yThe Y position of the Collider.
void Otter.Collider.SetPosition ( Vector2  xy)

Set the position of the Collider.

Parameters
xyThe Vector2 position of the Collider.

Member Data Documentation

bool Otter.Collider.Collidable = true

Determines if this collider is collidable. If false, it will not register collisions with other colliders, but can still check for collisions with other colliders.

Entity Otter.Collider.Entity

The entity that this collider is parented to.

float Otter.Collider.OriginX

The OriginX of the Collider.

float Otter.Collider.OriginY

The OriginY of the Collider.

float Otter.Collider.X

The X position of the Collider relative to the Entity.

float Otter.Collider.Y

The Y position of the Collider relative to the Entity.

Property Documentation

virtual float Otter.Collider.Bottom
get

The Y position of the bottom of the Collider.

virtual float Otter.Collider.CenterX
get

The X position of the center of the Collider.

virtual float Otter.Collider.CenterY
get

The Y position of the center of the Collider.

float Otter.Collider.HalfHeight
get

Half of the Collider's height.

float Otter.Collider.HalfWidth
get

Half of the Collider's width.

virtual float Otter.Collider.Height
getset

The height of the Collider.

virtual float Otter.Collider.Left
get

The X position of the left side of the Collider.

virtual float Otter.Collider.Right
get

The X position of the right side of the Collider.

List<int> Otter.Collider.Tags
getset

The tags that this Collider is registered with.

virtual float Otter.Collider.Top
get

The Y position of the top of the Collider.

virtual float Otter.Collider.Width
getset

The width of the Collider.


The documentation for this class was generated from the following file: