parent
1c1d919672
commit
8dbcf46304
@ -0,0 +1,51 @@
|
||||
#include "entityacts.h"
|
||||
#include "../Textures/animationHandler.h"
|
||||
#include "../MapObject/building.h"
|
||||
|
||||
void BuilderAct(Game *game, Entity *entity){
|
||||
Building *target = (Building *) entity->task->target;
|
||||
|
||||
// Hat noch keine Baustelle oder die Baustelle wurde fertiggestellt
|
||||
if(entity->task->target == 0 || !target->isBaustelle){
|
||||
AnimationChangeType(entity->animationHandler, AN_ENTITY_IDLE);
|
||||
|
||||
if(entity->hasDestination == 1){
|
||||
entity->hasDestination = 0;
|
||||
}
|
||||
|
||||
// Prüft, ob eine Baustelle existiert
|
||||
Building *current = game->buildings->head;
|
||||
while(current != 0){
|
||||
if(current->isBaustelle){
|
||||
entity->hasDestination = 1;
|
||||
entity->destX = current->sprite->x;
|
||||
entity->destY = current->sprite->y;
|
||||
|
||||
entity->task->target = current;
|
||||
entity->task->progress = 0;
|
||||
break;
|
||||
}
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
else if(entity->hasDestination == 1){
|
||||
EntityMoveToDestination(entity);
|
||||
}
|
||||
else{
|
||||
// Is beim target angekommen
|
||||
if(entity->task->progress == 0){
|
||||
// Angekommen, noch nicht mit arbeiten begonnen
|
||||
AnimationChangeType(entity->animationHandler, AN_ENTITY_ARBEITEN);
|
||||
target->progress += 0.01;
|
||||
}
|
||||
else if(target->progress >= 1.0){
|
||||
// Fertig mit arbeiten, Animation zu Idle zurück
|
||||
AnimationChangeType(entity->animationHandler, AN_ENTITY_IDLE);
|
||||
BuildingFinishConstruction(game, (Building *) entity->task->target);
|
||||
entity->task->target = 0;
|
||||
}
|
||||
else{
|
||||
target->progress += 0.2 * GetFrameTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
#ifndef ENTITYACTS_H_
|
||||
#define ENTITYACTS_H_
|
||||
#include "entity.h"
|
||||
#include "../game.h"
|
||||
|
||||
void BuilderAct(Game *game, Entity *entity);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in new issue