#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); entity->task->progress += 0.01; } else if(entity->task->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{ entity->task->progress += 0.2 * GetFrameTime(); } } }