public class Handler extends Object implements Handlables, Updatable, Renderable, IdentifiableListener
Featurable
, updating and rendering a set of components.
Modifications on the list can be done at any time because they are applied at the beginning of the next update.HandlerListener
,
ComponentUpdater
,
ComponentRenderer
Constructor and Description |
---|
Handler(Services services)
Create a handler.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Featurable featurable)
Add a featurable to the list.
|
void |
addComponent(ComponentRenderer component)
Add a renderer component.
|
void |
addComponent(ComponentUpdater component)
Add an updater component.
|
void |
addListener(HandlerListener listener)
Add a handler listener.
|
<I> Iterable<I> |
get(Class<I> type)
Get all featurables of this type.
|
Featurable |
get(Integer id)
Get the featurable from its ID.
|
void |
notifyDestroyed(Integer id)
Called when identifiable is destroyed (after a call to
Identifiable.destroy() . |
void |
remove(Featurable featurable)
Remove a featurable from the remove list.
|
void |
removeAll()
Remove all featurables from the list.
|
void |
removeListener(HandlerListener listener)
Remove a handler listener.
|
void |
render(Graphic g) |
int |
size()
Get the number of handled featurables.
|
void |
update(double extrp) |
Iterable<Featurable> |
values()
Get all featurables.
|
public Handler(Services services)
services
- The services reference.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 addComponent(ComponentUpdater component)
Services
and addListener(HandlerListener)
if
interface compatible.component
- The component to add.public final void addComponent(ComponentRenderer component)
Services
and addListener(HandlerListener)
if
interface compatible.component
- The component to add.public final void add(Featurable featurable)
update(double)
call.
If this function is called during update(double)
, it will be delayed to next update(double)
call.
Automatically add IdentifiableModel
if feature does not have Identifiable
feature.
featurable
- The featurable to add.public final void remove(Featurable featurable)
update(double)
call.
If this function is called during update(double)
, it will be delayed to next update(double)
call.featurable
- The featurable 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 Featurable get(Integer id)
Handlables
get
in interface Handlables
id
- The featurable ID.public <I> Iterable<I> get(Class<I> type)
Handlables
get
in interface Handlables
I
- The featurable interface type.type
- The expected type.public Iterable<Featurable> values()
Handlables
values
in interface Handlables
public void render(Graphic g)
render
in interface Renderable
public final void notifyDestroyed(Integer id)
IdentifiableListener
Identifiable.destroy()
.notifyDestroyed
in interface IdentifiableListener
id
- The destroyed ID.Copyright © 2017 Byron 3D Games Studio. All rights reserved.