com.b3dgs.lionengine.game.strategy
Class AbstractBuilding<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>

java.lang.Object
  extended by com.b3dgs.lionengine.game.purviews.Configurable
      extended by com.b3dgs.lionengine.game.Entity
          extended by com.b3dgs.lionengine.game.strategy.AbstractEntry<TTile,TSkill,TAttr>
              extended by com.b3dgs.lionengine.game.strategy.AbstractBuilding<TTile,TSkill,TAttr>
Type Parameters:
TTile - tile type used.
TSkill - skill type used.
TAttr - attributes type used.
All Implemented Interfaces:
Animator, Collisionable, Mirrorable

public abstract class AbstractBuilding<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
extends AbstractEntry<TTile,TSkill,TAttr>

This class represents any kind of building as a standard. It includes any future manufactory, defensive building, and more.


Field Summary
protected  BuilderAbility<TTile,TSkill,TAttr> builder
          Builder reference.
 
Fields inherited from class com.b3dgs.lionengine.game.strategy.AbstractEntry
anim, animName, attr, icon, id, lastAttacker, life, map, offsetX, offsetY, sprite
 
Fields inherited from class com.b3dgs.lionengine.game.Entity
collisionable, height, mirrorable, width, x, xOld, y, yOld
 
Constructor Summary
AbstractBuilding(java.lang.String data, PathBasedMap<TTile> map, java.awt.image.BufferedImage surface, TAttr attr)
          Create a new building.
 
Method Summary
 int getBuildingProgress()
          Get the current building progress in percent.
 boolean isUnderConstruction()
          Get constructing state.
abstract  void onConstructed()
          Action called when construction is done.
abstract  void onConstructing()
          Action called while the building is under construction.
abstract  void onDestroyed()
          Action called when the building is destroyed (no life remains).
abstract  void onStartConstruction()
          Action called when builder is going to start construction.
 void place(int tx, int ty)
          Set specific location in tile.
 void setBuilder(BuilderAbility<TTile,TSkill,TAttr> builder)
          Store builder reference.
 void setBuildingTime(long buildingTime)
          Set the time needed for the construction (in milliseconds).
 void startConstruction(int tx, int ty)
          Begin construction to specified location, prepare all states.
 void update(Keyboard keyboard, Mouse mouse, float extrp)
          Main routine, has to be called in a game loop.
 void updateConstruction(float extrp)
          Update construction progress.
 void updateMirror()
          Deprecated. Call update function instead, as it override it. Call it manually only if you plan a specific update.
 
Methods inherited from class com.b3dgs.lionengine.game.strategy.AbstractEntry
addSkill, applyOrder, applyOrder, getAnimState, getDistance, getDistance, getFieldOfView, getFrame, getHeight, getHeightInTile, getLayer, getLayerOld, getOrderedSkill, getOwnerID, getRealFrame, getSkill, getSkills, getWidth, getWidthInTile, getXInTile, getXOffset, getYInTile, getYOffset, hasChangedLayer, isActive, isAlive, isOver, isRemoved, isSelected, isUnselected, isVisible, onHit, onKilled, onOrdered, onOrderedFail, onSelection, play, play, play, remove, removeRef, removeSkill, render, setActive, setAlive, setAnimation, setFieldOfView, setFrame, setLayer, setLayerChanged, setOrderedSkill, setOver, setOwnerID, setSelection, setSkipLastFrameOnReverse, setVisibility, stopAnimation, unselect, updateAnimation
 
Methods inherited from class com.b3dgs.lionengine.game.Entity
backupCoord, cancelMirror, collide, collide, getCancelMirror, getCollision, getMirror, getRay, getX, getXOld, getXReal, getY, getYOld, getYReal, invertYAxis, mirror, move, renderCollision, updateCollision
 
Methods inherited from class com.b3dgs.lionengine.game.purviews.Configurable
checkInstruction, getAnim, getCollArea, getData, getDataBool, getDataInt, getDataString, getRange, loadData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

protected BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> builder
Builder reference.

Constructor Detail

AbstractBuilding

public AbstractBuilding(java.lang.String data,
                        PathBasedMap<TTile> map,
                        java.awt.image.BufferedImage surface,
                        TAttr attr)
Create a new building.

Parameters:
data - building data file path.
map - map reference.
surface - building image file path.
attr - attributes reference.
Method Detail

update

public void update(Keyboard keyboard,
                   Mouse mouse,
                   float extrp)
Description copied from class: AbstractEntry
Main routine, has to be called in a game loop.

Overrides:
update in class AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
keyboard - keyboard reference.
mouse - mouse reference.
extrp - extrapolation value.

updateMirror

@Deprecated
public void updateMirror()
Deprecated. Call update function instead, as it override it. Call it manually only if you plan a specific update.

Description copied from interface: Mirrorable
Update mirror and apply it if necessary.

Specified by:
updateMirror in interface Mirrorable
Overrides:
updateMirror in class Entity

place

public void place(int tx,
                  int ty)
Description copied from class: AbstractEntry
Set specific location in tile.

Overrides:
place in class AbstractEntry<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
tx - horizontal tile location.
ty - vertical tile location.

startConstruction

public void startConstruction(int tx,
                              int ty)
Begin construction to specified location, prepare all states.

Parameters:
tx - location x in tile.
ty - location y in tile.

updateConstruction

public void updateConstruction(float extrp)
Update construction progress. Automatically called by the builder update routine.

Parameters:
extrp -

setBuilder

public void setBuilder(BuilderAbility<TTile,TSkill,TAttr> builder)
Store builder reference. It can be used to notify the builder.

Parameters:
builder - builder reference.

setBuildingTime

public void setBuildingTime(long buildingTime)
Set the time needed for the construction (in milliseconds).

Parameters:
buildingTime - number of milliseconds.

getBuildingProgress

public int getBuildingProgress()
Get the current building progress in percent.

Returns:
progress percent.

isUnderConstruction

public boolean isUnderConstruction()
Get constructing state.

Returns:
true if under construction.

onStartConstruction

public abstract void onStartConstruction()
Action called when builder is going to start construction.


onConstructing

public abstract void onConstructing()
Action called while the building is under construction.


onConstructed

public abstract void onConstructed()
Action called when construction is done.


onDestroyed

public abstract void onDestroyed()
Action called when the building is destroyed (no life remains).