public class CollidableModel extends FeatureModel implements Collidable, Recyclable, TransformableListener, IdentifiableListener
Constructor and Description |
---|
CollidableModel(Services services)
Create a collidable model.
|
CollidableModel(Services services,
Setup setup)
Create a collidable model.
|
Modifier and Type | Method and Description |
---|---|
void |
addAccept(int group)
Add a group to accept list.
|
void |
addCollision(Collision collision)
Add a collision to use.
|
void |
addListener(CollidableListener listener)
Add a collision listener.
|
void |
checkListener(Object listener)
Check object interface listening and add them automatically.
|
Collision |
collide(Collidable other)
Check if the collidable entered in collision with another one.
|
List<Integer> |
getAccepted()
Get the accepted groups.
|
List<Rectangle> |
getCollisionBounds()
Get the collisions bounds.
|
Collection<Collision> |
getCollisions()
Get the declared collisions.
|
Integer |
getGroup()
Get the associated group.
|
int |
getMaxHeight()
Get the current max height.
|
int |
getMaxWidth()
Get the current max width.
|
void |
notifyCollided(Collidable collidable)
Notify when a collision occurred with another
Collidable . |
void |
notifyDestroyed(Integer id)
Called when identifiable is destroyed (after a call to
Identifiable.destroy() . |
void |
notifyTransformed(Transformable transformable)
Notify transformable modification.
|
void |
prepare(FeatureProvider provider)
Prepare the feature.
|
void |
recycle()
Recycle feature, to make it ready for reuse.
|
void |
removeAccept(int group)
Remove a group from accept list.
|
void |
render(Graphic g) |
void |
setCollisionVisibility(boolean visible)
Set the collision visibility.
|
void |
setEnabled(boolean enabled)
Set the collision enabled flag.
|
void |
setGroup(int group)
Set the associated group.
|
void |
setOrigin(Origin origin)
Set the origin to use.
|
getFeature, getFeatures, getFeaturesType, hasFeature
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFeature, getFeatures, getFeaturesType, hasFeature
public CollidableModel(Services services)
The Services
must provide:
The Featurable
must have:
If the Featurable
is a CollidableListener
, it will automatically
addListener(CollidableListener)
on it.
services
- The services reference.public CollidableModel(Services services, Setup setup)
The Services
must provide:
The Featurable
must have:
If the Featurable
is a CollidableListener
, it will automatically
addListener(CollidableListener)
on it.
services
- The services reference.setup
- The setup reference, must provide a valid CollisionConfig
.public void prepare(FeatureProvider provider)
Feature
Featurable.addFeature(Feature)
or
Featurable.addFeatureAndGet(Feature)
.prepare
in interface Feature
prepare
in class FeatureModel
provider
- The owner reference.public void checkListener(Object listener)
FeatureModel
Feature
provide listeners, this will
allow to add them automatically.
Does nothing by default.
checkListener
in interface Feature
checkListener
in class FeatureModel
listener
- The listener to check.public void addListener(CollidableListener listener)
Collidable
addListener
in interface Collidable
listener
- The listener reference.public void addCollision(Collision collision)
Collidable
addCollision
in interface Collidable
collision
- The collision to add.public void addAccept(int group)
Collidable
addAccept
in interface Collidable
group
- The group to accept on Collidable.collide(Collidable)
.public void removeAccept(int group)
Collidable
removeAccept
in interface Collidable
group
- The group to remove on Collidable.collide(Collidable)
.public Collision collide(Collidable other)
Collidable
collide
in interface Collidable
other
- The collidable reference.null
if none.public void render(Graphic g)
render
in interface Renderable
public void setGroup(int group)
Collidable
setGroup
in interface Collidable
group
- The associated group.public void setOrigin(Origin origin)
Collidable
setOrigin
in interface Collidable
origin
- The origin to use.public void setEnabled(boolean enabled)
Collidable
setEnabled
in interface Collidable
enabled
- true
to enable collision checking, false
else.public void setCollisionVisibility(boolean visible)
Collidable
setCollisionVisibility
in interface Collidable
visible
- true
if visible, false
else.public Collection<Collision> getCollisions()
Collidable
getCollisions
in interface Collidable
public List<Rectangle> getCollisionBounds()
Collidable
getCollisionBounds
in interface Collidable
public void notifyCollided(Collidable collidable)
CollidableListener
Collidable
.notifyCollided
in interface CollidableListener
collidable
- The collidable reference.public Integer getGroup()
Collidable
getGroup
in interface Collidable
public List<Integer> getAccepted()
Collidable
getAccepted
in interface Collidable
public int getMaxWidth()
Collidable
getMaxWidth
in interface Collidable
public int getMaxHeight()
Collidable
getMaxHeight
in interface Collidable
public final void recycle()
Recyclable
recycle
in interface Recyclable
public void notifyTransformed(Transformable transformable)
TransformableListener
notifyTransformed
in interface TransformableListener
transformable
- The modified transformable.public void notifyDestroyed(Integer id)
IdentifiableListener
Identifiable.destroy()
.notifyDestroyed
in interface IdentifiableListener
id
- The destroyed ID.Copyright © 2017 Byron 3D Games Studio. All rights reserved.