aboutsummaryrefslogtreecommitdiff
path: root/src/entities/generale.c
blob: 4865d4eb159ecd1e393584edd9f1560cc2daa4dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "generale.h"
#include "assets.h"
#include "game.h"

void initGenerale(Entity * entity, Game * game) {
	entity->model = &game->assets.models[GENERALE_ASSET];
	entity->collisionModel = entityCreateCollisionModel(*entity->model);
	entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);
	setEntityRadius(entity);

	// Allocate data.
	entity->data = KF_MALLOC(sizeof(Generale));

	if (entity->data == NULL) {
		ALLOCATION_ERROR;
		return;
	}

	Generale * data = (Generale*)entity->data;

	data->flyToPoint = (EntityFlyToPointInfo){
		.controller.bangbang.speed = 85.0,
		.controller.bangbang.stopAt = 0.0,
		.controlType = ENTITY_FLY_TO_POINT_BANG_BANG,
		.rotationSpeed = 0.0,
		.applyRotation = false
	};

	data->zigzag = GENERALE_ZIG;
}

void closeGenerale(Entity * entity) {
	if (entity->data != NULL)
		KF_FREE(entity->data);

	entityFreeCollisionModel(entity->collisionModel);
	entityFreeCollisionModel(entity->transformedCollisionModel);
}

void updateGenerale(Game * game, Entity * entity) {
	entityUpdateLastValues(entity);

	entityCheckTransformedCollisionModel(entity);
}

void drawGenerale(Game * game, Entity * entity) {
	entityDraw(entity);
}

void getTargetGenerale(Game * game, Entity * entity) {
	Entity * player = getEntityFromWorld(game->world, 0);

	Vector3 dis = Vector3Subtract(
}