Package com.prineside.tdi2
Class Registrable
java.lang.Object
com.prineside.tdi2.Registrable
- All Implemented Interfaces:
KryoSerializable
- Direct Known Subclasses:
Ability
,BuffProcessor
,Building
,Enemy
,Explosion
,GameSystem
,Gate
,Miner
,ModifierProcessor
,Projectile
,Tile
,Unit
A base class of things that store a reference to
GameSystemProvider
for its usage.
This class basically means that an object can have a reference to the system provider (field S)
and is considered to be "registered in the game's state" if it has a reference to the system
provider.
Many different classes that implement Registrable
require an access to the game's state
before you can call their methods, and for that setRegistered(GameSystemProvider)
has to be called beforehand.
setRegistered(GameSystemProvider)
manually as it is
a responsibility of the systems.-
Field Summary
FieldsModifier and TypeFieldDescriptionThis reference to the game state will be used by this object to communicate with everything else. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check if object has a link to the game state and is considered to be a part of it.void
void
setRegistered
(GameSystemProvider systemProvider) Mark this object as registered in the game state and give it a reference to the game state.void
Remove the reference to the game state and mark this object as not registered.void
-
Field Details
-
S
This reference to the game state will be used by this object to communicate with everything else. If this field is null, it means that object is not registered in the game state andisRegistered()
will return null.
-
-
Constructor Details
-
Registrable
public Registrable()
-
-
Method Details
-
write
- Specified by:
write
in interfaceKryoSerializable
-
read
- Specified by:
read
in interfaceKryoSerializable
-
setRegistered
Mark this object as registered in the game state and give it a reference to the game state.- Parameters:
systemProvider
- game state to link this object to, will be set to the S field.
-
setUnregistered
public void setUnregistered()Remove the reference to the game state and mark this object as not registered. -
isRegistered
public boolean isRegistered()Check if object has a link to the game state and is considered to be a part of it.- Returns:
- true if S is set and object has a reference to a game state
-