Class AbstractBlockLogicExtension
- java.lang.Object
-
- com.bombinggames.wurfelengine.core.map.AbstractBlockLogicExtension
-
public abstract class AbstractBlockLogicExtension extends java.lang.Object
Manages the game logic for a block. The instances are not saved in the map save file; therfore, every data saved in the fields are lost after quitting.
Points to aCoordinate
in the map. If the content of the coordinate changes it will be removed viaMap
. Check if is about to be removed viaisValid()
.
If you want to save information in the save file you have to use and spawn anAbstractEntity
.
-
-
Constructor Summary
Constructors Constructor Description AbstractBlockLogicExtension()
Called when spawned.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
dispose()
called when removedCoordinate
getPosition()
This method must be named "getPosition" so that this method can implement other interfaces using this API signaturestatic boolean
isRegistered(byte blockId)
boolean
isValid()
A logicblock is still valid if the pointer shows to a block with the same id as during creation.static AbstractBlockLogicExtension
newLogicInstance(byte blockId, byte value, Coordinate coord)
Creates a new logic instance if registered.static void
registerClass(byte id, java.lang.Class<? extends AbstractBlockLogicExtension> aClass)
Register a block id with a logic block class.void
setValue(byte value)
abstract void
update(float dt)
-
-
-
Method Detail
-
registerClass
public static void registerClass(byte id, java.lang.Class<? extends AbstractBlockLogicExtension> aClass)
Register a block id with a logic block class.- Parameters:
id
-aClass
-
-
newLogicInstance
public static AbstractBlockLogicExtension newLogicInstance(byte blockId, byte value, Coordinate coord)
Creates a new logic instance if registered. This can happen before the chunk is filled at this position.- Parameters:
blockId
- the block at the positionvalue
-coord
- the position where the logic block is placed- Returns:
- null if not registered
-
isRegistered
public static boolean isRegistered(byte blockId)
-
getPosition
public Coordinate getPosition()
This method must be named "getPosition" so that this method can implement other interfaces using this API signature- Returns:
- not copy safe. never null
-
isValid
public boolean isValid()
A logicblock is still valid if the pointer shows to a block with the same id as during creation.- Returns:
- false if should be deleted
-
update
public abstract void update(float dt)
- Parameters:
dt
- time in ms
-
dispose
public abstract void dispose()
called when removed
-
setValue
public void setValue(byte value)
- Parameters:
value
-
-
-