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 ColliderShape
s are:
-
Constructor Summary
ConstructorsConstructorDescriptionColliderComponent
(ColliderShape<?> colliderShape) Creates a ColliderComponent instance with specifiedColliderShape
.ColliderComponent
(ColliderShape<?> colliderShape, float offsetX, float offsetY) Creates a ColliderComponent instance with specifiedColliderShape
and collider offset. -
Method Summary
Modifier and TypeMethodDescriptionvoid
debugRender
(Renderer renderer, TransformComponent transformComponent) Renders a debug overlay over the collider.getBoundingBox
(TransformComponent transformComponent) Returns the bounding box for this ColliderComponent.float
float
<T extends Shape>
TgetShape
(TransformComponent transformComponent) Gets the geometricShape
representation of the collider for collision calculations.getTags()
getType()
Gets theColliderType
of this collider.boolean
hasIgnoreColliderTag
(ColliderTag colliderTag) Checks to see if this collider has aColliderTag
that it is ignoring.boolean
hasTag
(ColliderTag colliderTag) Checks to see if this collider has aColliderTag
.boolean
isSensor()
A collider that is a sensor will not respond to collision resolution but will emit collision events if anEntity
with aDynamicBodyComponent
collides.setIgnoreTags
(ColliderTag... ignoreTags) Sets theColliderTag
s to ignore for this collider.setSensor
(boolean isSensor) Sets whether this collider is a sensor or not.setTags
(ColliderTag... tags) Sets theColliderTag
s for this collider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 specifiedColliderShape
and collider offset.- Parameters:
colliderShape
- theColliderShape
offsetX
- 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
- theTransformComponent
of 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 anEntity
with aDynamicBodyComponent
collides.- 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
ColliderTag
s for this Collider
-
setTags
Sets theColliderTag
s 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
ColliderTag
s to ignore for this Collider
-
setIgnoreTags
Sets theColliderTag
s to ignore for this collider.- Parameters:
ignoreTags
- the new tags to ignore- Returns:
- this
-
hasIgnoreColliderTag
Checks to see if this collider has aColliderTag
that it is ignoring.- Parameters:
colliderTag
- the tag to check- Returns:
- true if collider is ignoring tag
-
getShape
Gets the geometricShape
representation of the collider for collision calculations.- Type Parameters:
T
- the type of theShape
- Parameters:
transformComponent
- theEntity
's currentTransformComponent
- Returns:
- the
Shape
of the collider
-
debugRender
Renders a debug overlay over the collider.- Parameters:
renderer
- theRenderer
transformComponent
- theEntity
'sTransformComponent
-
getType
Gets theColliderType
of this collider.- Returns:
- the
ColliderType
of this collider
-