PhysicsServices

Namespace: Murder.Services
Assembly: Murder.dll

public static class PhysicsServices

⭐ Methods

CollidesAt(Map&, int, ColliderComponent, Vector2, IEnumerable, int, out Int32&)

public bool CollidesAt(Map& map, int ignoreId, ColliderComponent collider, Vector2 position, IEnumerable<T> others, int mask, Int32& hitId)

Parameters
map Map&
ignoreId int
collider ColliderComponent
position Vector2
others IEnumerable<T>
mask int
hitId int&

Returns
bool

CollidesAt(Map&, int, ColliderComponent, Vector2, IEnumerable, int)

public bool CollidesAt(Map& map, int ignoreId, ColliderComponent collider, Vector2 position, IEnumerable<T> others, int mask)

Parameters
map Map&
ignoreId int
collider ColliderComponent
position Vector2
others IEnumerable<T>
mask int

Returns
bool

CollidesAtTile(Map&, ColliderComponent, Vector2, int)

public bool CollidesAtTile(Map& map, ColliderComponent collider, Vector2 position, int mask)

Parameters
map Map&
collider ColliderComponent
position Vector2
mask int

Returns
bool

CollidesWith(Entity, Entity, Vector2)

public bool CollidesWith(Entity entityA, Entity entityB, Vector2 positionA)

Parameters
entityA Entity
entityB Entity
positionA Vector2

Returns
bool

CollidesWith(Entity, Entity)

public bool CollidesWith(Entity entityA, Entity entityB)

Parameters
entityA Entity
entityB Entity

Returns
bool

CollidesWith(IShape, Point, IShape, Point)

public bool CollidesWith(IShape shape1, Point position1, IShape shape2, Point position2)

Parameters
shape1 IShape
position1 Point
shape2 IShape
position2 Point

Returns
bool

ContainsPoint(Entity, Point)

public bool ContainsPoint(Entity entity, Point point)

Parameters
entity Entity
point Point

Returns
bool

FindClosestEntityOnRange(World, Vector2, float, int, HashSet, out Entity&, out Nullable`1&)

public bool FindClosestEntityOnRange(World world, Vector2 fromPosition, float range, int collisionLayer, HashSet<T> excludeEntities, Entity& target, Nullable`1& location)

Parameters
world World
fromPosition Vector2
range float
collisionLayer int
excludeEntities HashSet<T>
target Entity&
location T?&

Returns
bool

GetFirstMtvAt(Map&, HashSet, ColliderComponent, Vector2, IEnumerable, int, out Int32&, out Int32&, out Vector2&)

public bool GetFirstMtvAt(Map& map, HashSet<T> ignoreIds, ColliderComponent collider, Vector2 position, IEnumerable<T> others, int mask, Int32& hitId, Int32& layer, Vector2& mtv)

Parameters
map Map&
ignoreIds HashSet<T>
collider ColliderComponent
position Vector2
others IEnumerable<T>
mask int
hitId int&
layer int&
mtv Vector2&

Returns
bool

HasCachedCollisionWith(Entity, int)

public bool HasCachedCollisionWith(Entity entity, int entityId)

Check if a trigger is colliding with an actor via the TriggerCollisionSystem.

Parameters
entity Entity

entityId int

Returns
bool

HasLineOfSight(World, Entity, Entity)

public bool HasLineOfSight(World world, Entity from, Entity to)

Parameters
world World
from Entity
to Entity

Returns
bool

Raycast(World, Vector2, Vector2, int, IEnumerable, out RaycastHit&)

public bool Raycast(World world, Vector2 startPosition, Vector2 endPosition, int layerMask, IEnumerable<T> ignoreEntities, RaycastHit& hit)

Parameters
world World
startPosition Vector2
endPosition Vector2
layerMask int
ignoreEntities IEnumerable<T>
hit RaycastHit&

Returns
bool

RaycastTiles(World, Vector2, Vector2, int, out RaycastHit&)

public bool RaycastTiles(World world, Vector2 startPosition, Vector2 endPosition, int flags, RaycastHit& hit)

Parameters
world World
startPosition Vector2
endPosition Vector2
flags int
hit RaycastHit&

Returns
bool

RemoveFromCollisionCache(Entity, int)

public bool RemoveFromCollisionCache(Entity entity, int entityId)

Removes an ID from the IsColliding component. This is usually handled by TriggerPhysics system, since a message must be sent when exiting a collision.

Parameters
entity Entity

entityId int

Returns
bool

ConeCheck(World, Vector2, float, float, float, int)

public IEnumerable<T> ConeCheck(World world, Vector2 coneStart, float range, float angle, float angleRange, int collisionLayer)

Checks for collisions in a cone.

Parameters
world World
coneStart Vector2
range float
angle float
angleRange float
collisionLayer int

Returns
IEnumerable<T>

GetAllCollisionsAt(World, Point, ColliderComponent, int, int)

public IEnumerable<T> GetAllCollisionsAt(World world, Point position, ColliderComponent collider, int ignoreId, int mask)

Parameters
world World
position Point
collider ColliderComponent
ignoreId int
mask int

Returns
IEnumerable<T>

Neighbours(Vector2, World)

public IEnumerable<T> Neighbours(Vector2 position, World world)

Get all the neighbours of a position within the world. This does not check for collision (yet)!

Parameters
position Vector2
world World

Returns
IEnumerable<T>

FilterEntities(World, int)

public ImmutableArray<T> FilterEntities(World world, int layerMask)

Parameters
world World
layerMask int

Returns
ImmutableArray<T>

FilterPositionAndColliderEntities(World, Func<T, TResult>)

public ImmutableArray<T> FilterPositionAndColliderEntities(World world, Func<T, TResult> filter)

Parameters
world World
filter Func<T, TResult>

Returns
ImmutableArray<T>

FilterPositionAndColliderEntities(World, int, Type[])

public ImmutableArray<T> FilterPositionAndColliderEntities(World world, int layerMask, Type[] requireComponents)

Parameters
world World
layerMask int
requireComponents Type[]

Returns
ImmutableArray<T>

FilterPositionAndColliderEntities(World, int)

public ImmutableArray<T> FilterPositionAndColliderEntities(World world, int layerMask)

Parameters
world World
layerMask int

Returns
ImmutableArray<T>

FilterPositionAndColliderEntities(IEnumerable, int)

public ImmutableArray<T> FilterPositionAndColliderEntities(IEnumerable<T> entities, int layerMask)

Parameters
entities IEnumerable<T>
layerMask int

Returns
ImmutableArray<T>

GetCarveBoundingBox(ColliderComponent, Point)

public IntRectangle GetCarveBoundingBox(ColliderComponent collider, Point position)

Parameters
collider ColliderComponent
position Point

Returns
IntRectangle

GetColliderBoundingBox(Entity)

public IntRectangle GetColliderBoundingBox(Entity target)

Get bounding box of an entity that contains both ColliderComponent and PositionComponent.

Parameters
target Entity

Returns
IntRectangle

GetCollidersBoundingBox(ColliderComponent, Point, bool)

public IntRectangle[] GetCollidersBoundingBox(ColliderComponent collider, Point position, bool gridCoordinates)

Parameters
collider ColliderComponent
position Point
gridCoordinates bool

Returns
IntRectangle[]

GetMtvAt(Map&, int, ColliderComponent, Vector2, IEnumerable, int, out Int32&)

public List<T> GetMtvAt(Map& map, int ignoreId, ColliderComponent collider, Vector2 position, IEnumerable<T> others, int mask, Int32& hitId)

Parameters
map Map&
ignoreId int
collider ColliderComponent
position Vector2
others IEnumerable<T>
mask int
hitId int&

Returns
List<T>

GetBoundingBox(ColliderComponent, Vector2)

public Rectangle GetBoundingBox(ColliderComponent collider, Vector2 position)

Parameters
collider ColliderComponent
position Vector2

Returns
Rectangle

FindNextAvailablePosition(World, Entity, Vector2, NextAvailablePositionFlags)

public T? FindNextAvailablePosition(World world, Entity e, Vector2 target, NextAvailablePositionFlags flags)

Parameters
world World
e Entity
target Vector2
flags NextAvailablePositionFlags

Returns
T?

AddToCollisionCache(Entity, int)

public void AddToCollisionCache(Entity entity, int entityId)

Parameters
entity Entity
entityId int

GetAllCollisionsAtGrid(World, Point, List`1&)

public void GetAllCollisionsAtGrid(World world, Point grid, List`1& output)

Parameters
world World
grid Point
output List<T>&