execution time added v.2

I noticed I should place the execution time event after the walking action in update
This commit is contained in:
Woosle Park 2019-03-28 20:43:55 -04:00 committed by GitHub
parent 89f53a159a
commit 213ea4a3af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,13 +173,6 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Me
*/ */
@Override @Override
public void update() { public void update() {
int executionTime = timer.getTime();
if(executionTime > time && currentAction != Action.IDLE){
GameEvent event1 = new ExecutionTimeEvent(this, executionTime - time);
GameServer.INSTANCE.getEventDispatcher().dispatch(event1);
}
time = executionTime;
if (currentAction == Action.WALKING) { if (currentAction == Action.WALKING) {
if (spendEnergy(100)) { if (spendEnergy(100)) {
if (!incrementLocation()) { if (!incrementLocation()) {
@ -194,6 +187,13 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Me
} }
} }
int executionTime = timer.getTime();
if(executionTime > time && currentAction != Action.IDLE){
GameEvent event1 = new ExecutionTimeEvent(this, executionTime - time);
GameServer.INSTANCE.getEventDispatcher().dispatch(event1);
}
time = executionTime;
/* /*
* CurrentAction is set during the code execution and this function is called right after * CurrentAction is set during the code execution and this function is called right after
* If no action as been set, the action sent to the client is the action in currentAction that * If no action as been set, the action sent to the client is the action in currentAction that