Interface ICollisionEntity
- All Superinterfaces:
IEntity
- All Known Subinterfaces:
ICombatEntity,IMobileEntity
- All Known Implementing Classes:
CollisionBox,CollisionEntity,CombatEntity,Creature,Prop,Trigger
-
Method Summary
Modifier and TypeMethodDescriptionbooleancanCollideWith(ICollisionEntity otherEntity) Determines if this entity can collide with another specifiedICollisionEntity.voidfireCollisionEvent(CollisionEvent event) Triggers a collision event for this entity.Gets the collision box.getCollisionBox(Point2D location) Gets the collision box.Retrieves the horizontal alignment of the entity's collision box.Gets the centerPoint2Dof the entities collision box.doubleRetrieves the height of the entity's collision box.Retrieves the vertical alignment of the entity's collision box.doubleRetrieves the width of the entity's collision box.Retrieves the collision type of this entity.booleanChecks if the entity has collision enabled.voidonCollision(CollisionListener listener) Registers aCollisionListenerto this entity.voidremoveCollisionListener(CollisionListener listener) Removes a previously registeredCollisionListenerfrom this entity.voidsetCollision(boolean collision) Sets the collision state of the entity.voidsetCollisionBoxAlign(Align align) Sets the horizontal alignment of the entity's collision box.voidsetCollisionBoxHeight(double collisionBoxHeight) Sets the height of the entity's collision box.voidsetCollisionBoxValign(Valign valign) Sets the vertical alignment of the entity's collision box.voidsetCollisionBoxWidth(double collisionBoxWidth) Sets the width of the entity's collision box.voidsetCollisionType(Collision collisionType) Sets the collision type of this entity.Methods inherited from interface de.gurkenlabs.litiengine.entities.IEntity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, detachControllers, getAngle, getBoundingBox, getCenter, getController, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, renderWithLayer, sendMessage, setAngle, setController, setHeight, setLocation, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setSize, setVisible, setWidth, setX, setY
-
Method Details
-
onCollision
Registers aCollisionListenerto this entity. The listener will be notified whenever this entity collides with anotherICollisionEntity.- Parameters:
listener- TheCollisionListenerto be added to this entity. It should not benull.
-
removeCollisionListener
Removes a previously registeredCollisionListenerfrom this entity. After removal, the listener will no longer receive collision events involving this entity.- Parameters:
listener- TheCollisionListenerto be removed. It should match a listener that was previously added withonCollision(CollisionListener).
-
fireCollisionEvent
Triggers a collision event for this entity. This method is used to manually fire a collision event, which can be useful for custom collision handling or for simulating collisions in specific scenarios.- Parameters:
event- TheCollisionEventthat encapsulates the details of the collision. This includes information such as the entities involved in the collision and the collision's impact point.
-
canCollideWith
Determines if this entity can collide with another specifiedICollisionEntity. This method should be implemented to define custom collision logic between entities.- Parameters:
otherEntity- The otherICollisionEntityto check collision capability with.- Returns:
trueif this entity can collide with the specified entity;falseotherwise.
-
getCollisionBox
-
getCollisionBox
Gets the collision box.- Parameters:
location- the location- Returns:
- the collision box
-
getCollisionBoxCenter
-
getCollisionBoxValign
-
getCollisionBoxAlign
-
getCollisionType
-
getCollisionBoxHeight
double getCollisionBoxHeight()Retrieves the height of the entity's collision box. This height is used in collision detection to determine the vertical bounds of the entity.- Returns:
- The height of the collision box in pixels.
-
getCollisionBoxWidth
double getCollisionBoxWidth()Retrieves the width of the entity's collision box. This width is used in collision detection to determine the horizontal bounds of the entity.- Returns:
- The width of the collision box in pixels.
-
hasCollision
boolean hasCollision()Checks if the entity has collision enabled.- Returns:
trueif the entity has collision enabled;falseotherwise.
-
setCollision
void setCollision(boolean collision) Sets the collision state of the entity.- Parameters:
collision- The collision state to set.trueto enable collision;falseto disable it.
-
setCollisionBoxHeight
void setCollisionBoxHeight(double collisionBoxHeight) Sets the height of the entity's collision box.- Parameters:
collisionBoxHeight- The height of the collision box in pixels.
-
setCollisionBoxWidth
void setCollisionBoxWidth(double collisionBoxWidth) Sets the width of the entity's collision box.- Parameters:
collisionBoxWidth- The width of the collision box in pixels.
-
setCollisionBoxAlign
-
setCollisionBoxValign
-
setCollisionType
-