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

public abstract class Registrable extends Object implements KryoSerializable
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.

Normally you don't call setRegistered(GameSystemProvider) manually as it is a responsibility of the systems.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    This reference to the game state will be used by this object to communicate with everything else.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if object has a link to the game state and is considered to be a part of it.
    void
    read(Kryo kryo, Input input)
     
    void
    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
    write(Kryo kryo, Output output)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 and isRegistered() will return null.
  • Constructor Details

    • Registrable

      public Registrable()
  • Method Details

    • write

      public void write(Kryo kryo, Output output)
      Specified by:
      write in interface KryoSerializable
    • read

      public void read(Kryo kryo, Input input)
      Specified by:
      read in interface KryoSerializable
    • setRegistered

      public void setRegistered(GameSystemProvider systemProvider)
      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