aboutsummaryrefslogtreecommitdiff
path: root/src/entities/caporale.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/caporale.c')
-rw-r--r--src/entities/caporale.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/entities/caporale.c b/src/entities/caporale.c
index bd6fcd5..c8b4345 100644
--- a/src/entities/caporale.c
+++ b/src/entities/caporale.c
@@ -4,15 +4,45 @@
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);
- entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0};
+
+ // 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
+ };
}
void closeCaporale(Entity * entity) {
+ if (entity->data != NULL)
+ KF_FREE(entity->data);
+
+ entityFreeCollisionModel(entity->collisionModel);
+ entityFreeCollisionModel(entity->transformedCollisionModel);
}
void updateCaporale(Game * game, Entity * entity) {
- entityUpdateRotation(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) {