#include "caporale.h" #include "assets.h" #include "game.h" void initCaporale(Entity * entity, Game * game) { entity->model = &game->assets.models[CAPORATE_ASSET]; entity->collisionModel = entityCreateCollisionModel(*entity->model); entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model); setEntityRadius(entity); // Allocate data. entity->data = KF_MALLOC(sizeof(Caporale)); if (entity->data == NULL) { ALLOCATION_ERROR; return; } Caporale * data = (Caporale*)entity->data; data->flyToPlayer = (EntityFlyToPointInfo){ .controller.bangbang.speed = 80, .controller.bangbang.stopAt = 0.0, .controlType = ENTITY_FLY_TO_POINT_BANG_BANG, .rotationSpeed = 0.5, .applyRotation = true }; } void closeCaporale(Entity * entity) { if (entity->data != NULL) KF_FREE(entity->data); entityFreeCollisionModel(entity->collisionModel); entityFreeCollisionModel(entity->transformedCollisionModel); } void updateCaporale(Game * game, Entity * entity) { entityUpdateLastValues(entity); Caporale * data = (Caporale*)entity->data; Entity * player = getEntityFromWorld(game->world, 0); entityFlyToPoint(entity, player->position, &data->flyToPlayer); entityCheckTransformedCollisionModel(entity); } void drawCaporale(Game * game, Entity * entity) { entityDraw(entity); }