public class Handler extends Object implements HandledObjects, Updatable, Renderable
ObjectGame
. Maintain an objects list by updating and rendering them. Modifications on the
list can be done at any time because their are applied at the beginning of the next update.ObjectGame
,
ComponentUpdatable
,
ComponentRenderable
Constructor and Description |
---|
Handler()
Create a handler.
|
Modifier and Type | Method and Description |
---|---|
void |
add(ObjectGame object)
Add an object to the list.
|
void |
addListener(HandlerListener listener)
Add a handler listener.
|
void |
addRenderable(ComponentRenderable component)
Add a renderable component.
|
void |
addUpdatable(ComponentUpdatable component)
Add an updatable component.
|
<I> Iterable<I> |
get(Class<I> type)
Get all objects of this type.
|
ObjectGame |
get(Integer id)
Get the object from its id.
|
void |
notifyDestroyed(Integer objectId)
Called when object is destroyed (after a call to
ObjectGame.destroy() . |
void |
remove(ObjectGame object)
Remove an object from the remove list.
|
void |
removeAll()
Remove all objects from the list.
|
void |
removeListener(HandlerListener listener)
Remove a handler listener.
|
void |
render(Graphic g) |
int |
size()
Get the number of handled objects.
|
void |
update(double extrp) |
Iterable<ObjectGame> |
values()
Get all objects.
|
public final void addListener(HandlerListener listener)
listener
- The listener to add.public final void removeListener(HandlerListener listener)
listener
- The listener to remove.public final void addUpdatable(ComponentUpdatable component)
component
- The component to add.public final void addRenderable(ComponentRenderable component)
component
- The component to add.public final void add(ObjectGame object)
update(double)
call. If this function is
called during update(double)
, it will be delayed to next update(double)
call.object
- The object to add.public final void remove(ObjectGame object)
update(double)
call. If
this function is called during update(double)
, it will be delayed to next update(double)
call.object
- The object to remove.public final void removeAll()
update(double)
call. If
this function is called during update(double)
, it will be delayed to next update(double)
call.public final int size()
public final ObjectGame get(Integer id)
HandledObjects
get
in interface HandledObjects
id
- The object id.ObjectGame.getId()
public <I> Iterable<I> get(Class<I> type)
HandledObjects
get
in interface HandledObjects
I
- The object interface type.type
- The expected type.public Iterable<ObjectGame> values()
HandledObjects
values
in interface HandledObjects
public void render(Graphic g)
render
in interface Renderable
public final void notifyDestroyed(Integer objectId)
ObjectGame.destroy()
.objectId
- The destroyed object id.Copyright © 2016 Byron 3D Games Studio. All rights reserved.