aboutsummaryrefslogtreecommitdiff
path: root/world.c
blob: 3b736e6da979b74f8aabbd071347010764082e2a (plain) (blame)
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
#include "world.h"

void init_world(World* world) {
	world->entity_count = 0;
}

Entity new_entity(World* world) {
	Entity e;

	e = 
		world->recycle_bin_count > 0 ?
		world->recycle_bin[--world->recycle_bin_count] :
		world->entity_count++;

	world->bitmask[e] = 0;

	return e;
}

void destroy_entity(World* world, Entity e) {
	world->recycle_bin[world->recycle_bin_count++] = e;
	world->bitmask[e] = 0;
}

void add_components(World* world, Entity e, CType bits) {
	world->bitmask[e] |= bits;
}

void remove_components(World* world, Entity e, CType bits) {
	world->bitmask[e] &= ~bits;
}