diff --git a/src/main/java/com/groep15/amazonsim/models/Truck.java b/src/main/java/com/groep15/amazonsim/models/Truck.java new file mode 100644 index 0000000..59bcfa9 --- /dev/null +++ b/src/main/java/com/groep15/amazonsim/models/Truck.java @@ -0,0 +1,46 @@ +package com.groep15.amazonsim.models; + +import com.groep15.amazonsim.ai.ActionIdle; +import com.groep15.amazonsim.ai.IWorldAction; +import com.groep15.amazonsim.ai.IWorldActor; + +public class Truck extends Object3D implements IWorldActor { + private IWorldAction action; + private boolean changedFromAction; + + public Truck(World world) { + super(world); + + this.passable = true; + this.action = new ActionIdle(); + this.changedFromAction = this.action.onActionStart(this); + } + + @Override + public boolean update() { + if (this.action.progress(this) || changedFromAction) { + changedFromAction = false; + return true; + } + + return false; + } + + @Override + public double getSpeed() { + return 0.25; + } + + @Override + public void setAction(IWorldAction action) { + this.changedFromAction |= this.action.onActionDone(this); + this.action = action; + this.changedFromAction |= this.action.onActionStart(this); + } + + @Override + public IWorldAction getAction() { + return this.action; + } + +} diff --git a/src/main/resources/client/index.html b/src/main/resources/client/index.html index 3780450..ac5da64 100644 --- a/src/main/resources/client/index.html +++ b/src/main/resources/client/index.html @@ -12,6 +12,7 @@ +