Module technology.sola.engine
Class ColliderComponent
java.lang.Object
technology.sola.engine.physics.component.ColliderComponent
- All Implemented Interfaces:
technology.sola.ecs.Component
ColliderComponent is a
Component that contains collision data for an Entity.
The currently supported ColliderShapes are:
-
Constructor Summary
ConstructorsConstructorDescriptionColliderComponent(ColliderShape<?> colliderShape) Creates a ColliderComponent instance with specifiedColliderShape.ColliderComponent(ColliderShape<?> colliderShape, float offsetX, float offsetY) Creates a ColliderComponent instance with specifiedColliderShapeand collider offset. -
Method Summary
Modifier and TypeMethodDescriptionvoiddebugRender(Renderer renderer, TransformComponent transformComponent) Renders a debug overlay over the collider.getBoundingBox(TransformComponent transformComponent) Returns the bounding box for this ColliderComponent.floatfloat<T extends Shape>
TgetShape(TransformComponent transformComponent) Gets the geometricShaperepresentation of the collider for collision calculations.getTags()getType()Gets theColliderTypeof this collider.booleanhasIgnoreColliderTag(ColliderTag colliderTag) Checks to see if this collider has aColliderTagthat it is ignoring.booleanhasTag(ColliderTag colliderTag) Checks to see if this collider has aColliderTag.booleanisSensor()A collider that is a sensor will not respond to collision resolution but will emit collision events if anEntitywith aDynamicBodyComponentcollides.setIgnoreTags(ColliderTag... ignoreTags) Sets theColliderTags to ignore for this collider.setSensor(boolean isSensor) Sets whether this collider is a sensor or not.setTags(ColliderTag... tags) Sets theColliderTags for this collider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface technology.sola.ecs.Component
afterDeserialize
-
Constructor Details
-
ColliderComponent
Creates a ColliderComponent instance with specifiedColliderShape.- Parameters:
colliderShape- theColliderShape
-
ColliderComponent
Creates a ColliderComponent instance with specifiedColliderShapeand collider offset.- Parameters:
colliderShape- theColliderShapeoffsetX- the collider x-axis offsetoffsetY- the collider y-axis offset
-
-
Method Details
-
getOffsetX
public float getOffsetX()- Returns:
- the x offset from the transform
-
getOffsetY
public float getOffsetY()- Returns:
- the y offset from the transform
-
getBoundingBox
Returns the bounding box for this ColliderComponent.- Parameters:
transformComponent- theTransformComponentof theEntity- Returns:
- the bounding box
-
isSensor
public boolean isSensor()A collider that is a sensor will not respond to collision resolution but will emit collision events if anEntitywith aDynamicBodyComponentcollides.- Returns:
- true if this collider is a sensor
-
setSensor
Sets whether this collider is a sensor or not.- Parameters:
isSensor- whether this collider is a sensor or not- Returns:
- this
-
getTags
- Returns:
- the
ColliderTags for this Collider
-
setTags
Sets theColliderTags for this collider.- Parameters:
tags- the new tags- Returns:
- this
-
hasTag
Checks to see if this collider has aColliderTag.- Parameters:
colliderTag- the tag to check- Returns:
- true if collider has tag
-
getIgnoreTags
- Returns:
- the
ColliderTags to ignore for this Collider
-
setIgnoreTags
Sets theColliderTags to ignore for this collider.- Parameters:
ignoreTags- the new tags to ignore- Returns:
- this
-
hasIgnoreColliderTag
Checks to see if this collider has aColliderTagthat it is ignoring.- Parameters:
colliderTag- the tag to check- Returns:
- true if collider is ignoring tag
-
getShape
Gets the geometricShaperepresentation of the collider for collision calculations.- Type Parameters:
T- the type of theShape- Parameters:
transformComponent- theEntity's currentTransformComponent- Returns:
- the
Shapeof the collider
-
debugRender
Renders a debug overlay over the collider.- Parameters:
renderer- theRenderertransformComponent- theEntity'sTransformComponent
-
getType
Gets theColliderTypeof this collider.- Returns:
- the
ColliderTypeof this collider
-