-
-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathbucket_map.h
More file actions
30 lines (23 loc) · 634 Bytes
/
bucket_map.h
File metadata and controls
30 lines (23 loc) · 634 Bytes
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
#pragma once
#include "util.h"
#include "entity_set.h"
#include "indexed_vector.h"
template <typename T>
class BucketMap {
public:
BucketMap(Vec2 size, int bucketSize);
void addElement(Vec2, T*);
void removeElement(Vec2, T*);
void moveElement(Vec2 from, Vec2 to, T*);
int countElementsInBucket(Vec2) const;
vector<T*> getElements(Rectangle area) const;
SERIALIZATION_DECL(BucketMap)
private:
int SERIAL(bucketSize);
Table<IndexedVector<T*, typename UniqueEntity<T>::Id>> SERIAL(buckets);
};
class Creature;
class CreatureBucketMap : public BucketMap<Creature> {
public:
using BucketMap::BucketMap;
};