public class ObjectGame extends Object
Handler
. To
remove it from the handler, a simple call to destroy()
is needed.
An object can also be externally configured by using a Configurer
, filled from an XML file.
They are also designed to be created by a Factory
. In that case, they must have at least a constructor with a
single argument, which must be a type of Setup
.
It is possible to retrieve external Services
when object is being constructed.
Instead of using traditional interface implementation, it is possible to use Trait
system, in order to reduce
class complexity. The Handler
is designed to work well with that system.
Constructor and Description |
---|
ObjectGame(Setup setup,
Services services)
Create an object.
|
Modifier and Type | Method and Description |
---|---|
<T extends Trait> |
addTrait(T trait)
Add a trait.
|
void |
addType(Object type)
Add a type.
|
void |
destroy()
Declare as removable from handler.
|
Configurer |
getConfigurer()
Get the configurer reference.
|
Integer |
getId()
|
Media |
getMedia()
Get the media representing this object.
|
<T> T |
getTrait(Class<T> trait)
Get a trait from its class.
|
Iterable<Trait> |
getTraits()
Get all traits.
|
Iterable<Class<? extends Trait>> |
getTraitsType()
Get all traits types.
|
boolean |
hasTrait(Class<?> trait)
Check if object has the following trait.
|
protected void |
onPrepared()
Called when object has been prepared and is ready to be used.
|
public ObjectGame(Setup setup, Services services)
setup
- The setup reference (resources sharing entry point).services
- The services reference (external services provider).LionEngineException
- If setup or service is null
.public final <T extends Trait> T addTrait(T trait)
T
- The trait type.trait
- The trait to add.public final void addType(Object type)
type
- The type to add.public final boolean hasTrait(Class<?> trait)
trait
- The trait to check (could be a Trait
or a classic interface.true
if has trait, false
else.public final <T> T getTrait(Class<T> trait)
T
- The trait class type used.trait
- The trait class.LionEngineException
- If feature was not found.public final Iterable<Class<? extends Trait>> getTraitsType()
public final Media getMedia()
public final Configurer getConfigurer()
public final Integer getId()
public final void destroy()
Handler.update(double)
call.
Can be destroyed only one time.protected void onPrepared()
Copyright © 2016 Byron 3D Games Studio. All rights reserved.