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

java.lang.Object
  extended by com.b3dgs.lionengine.game.strategy.ability.AbstractBuilderAbility<TTile,TSkill,TAttr>
Type Parameters:
TTile - tile type used.
TSkill - skill type used.
TAttr - attributes type used.
All Implemented Interfaces:
BuilderAbility<TTile,TSkill,TAttr>

public abstract class AbstractBuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
extends java.lang.Object
implements BuilderAbility<TTile,TSkill,TAttr>

This is the main implementation of the builder ability. This object can be used by any kind of unit which will receive the ability of building.


Nested Class Summary
protected  class AbstractBuilderAbility.Constructible
           
 
Field Summary
protected  java.util.Queue<AbstractBuilderAbility.Constructible> constructions
           
protected  AbstractBuilderAbility.Constructible cur
           
protected  AbstractEntryHandler<TTile,TSkill,TAttr> entrys
          Entry handler reference.
 
Constructor Summary
AbstractBuilderAbility(AbstractUnit<TTile,TSkill,TAttr> builder, AbstractEntryHandler<TTile,TSkill,TAttr> handler)
          Create a new attacker ability.
 
Method Summary
 void buildAt(int tx, int ty, java.lang.String building, int tw, int th, int time)
          Define a construction plan, set the action to 'build', and move to the destination.
abstract  boolean canBuild(AbstractBuilderAbility.Constructible constructible)
          Check if this constructible can be built.
abstract  void constructionRefused(AbstractBuilderAbility.Constructible constructible)
          Called when construction is refused.
 AbstractBuilding<TTile,TSkill,TAttr> getBuilding()
          Get building which will be built.
abstract  AbstractBuilding<TTile,TSkill,TAttr> getBuildingToBuild(java.lang.String name)
           
 boolean isConstructing()
          Check if builder is currently constructing.
 void onConstructed(AbstractBuilding<TTile,TSkill,TAttr> building)
          Called by the building when construction is done.
 void startConstruction(java.lang.String name)
           
 void stopBuild()
          Stop any action, reset all states.
 void updateConstruction(float extrp)
          Update construction routine.
abstract  void willBuild(java.lang.String name)
          Building name going to be built.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entrys

protected final AbstractEntryHandler<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes> entrys
Entry handler reference.


constructions

protected final java.util.Queue<AbstractBuilderAbility.Constructible> constructions

cur

protected AbstractBuilderAbility.Constructible cur
Constructor Detail

AbstractBuilderAbility

public AbstractBuilderAbility(AbstractUnit<TTile,TSkill,TAttr> builder,
                              AbstractEntryHandler<TTile,TSkill,TAttr> handler)
Create a new attacker ability.

Parameters:
builder - concerned builder reference.
handler - entry handler reference.
Method Detail

buildAt

public void buildAt(int tx,
                    int ty,
                    java.lang.String building,
                    int tw,
                    int th,
                    int time)
Description copied from interface: BuilderAbility
Define a construction plan, set the action to 'build', and move to the destination. Construction will start after entry has arrived.

Specified by:
buildAt in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
tx - building construction location x.
ty - building construction location y.
building - building to build.
tw - building width.
th - building height.
time - construction time.

updateConstruction

public void updateConstruction(float extrp)
Description copied from interface: BuilderAbility
Update construction routine.

Specified by:
updateConstruction in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
extrp - extrapolation value.

getBuildingToBuild

public abstract AbstractBuilding<TTile,TSkill,TAttr> getBuildingToBuild(java.lang.String name)

startConstruction

public void startConstruction(java.lang.String name)

constructionRefused

public abstract void constructionRefused(AbstractBuilderAbility.Constructible constructible)
Called when construction is refused.

Parameters:
constructible - construction refused.

canBuild

public abstract boolean canBuild(AbstractBuilderAbility.Constructible constructible)
Check if this constructible can be built.

Parameters:
constructible - constructible to construct.
Returns:
true if buildable.

isConstructing

public boolean isConstructing()
Description copied from interface: BuilderAbility
Check if builder is currently constructing.

Specified by:
isConstructing in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Returns:
true if constructing

stopBuild

public void stopBuild()
Description copied from interface: BuilderAbility
Stop any action, reset all states.

Specified by:
stopBuild in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>

getBuilding

public AbstractBuilding<TTile,TSkill,TAttr> getBuilding()
Description copied from interface: BuilderAbility
Get building which will be built.

Specified by:
getBuilding in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Returns:
building going to be built.

onConstructed

public void onConstructed(AbstractBuilding<TTile,TSkill,TAttr> building)
Description copied from interface: BuilderAbility
Called by the building when construction is done.

Specified by:
onConstructed in interface BuilderAbility<TTile extends AbstractPathTile,TSkill extends AbstractSkill<TTile,TSkill,TAttr>,TAttr extends AbstractAttributes>
Parameters:
building - building built.

willBuild

public abstract void willBuild(java.lang.String name)
Building name going to be built.

Parameters:
name - building name.