-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathworld.hpp
60 lines (53 loc) · 1.35 KB
/
world.hpp
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
55
56
57
58
59
60
#pragma once
#include "bot_specs.hpp"
#include "sched.hpp"
#include <cstdint>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <vector>
class ActiveEntity;
class Entity;
class Library;
class Rend;
class Terrain;
class World
{
public:
World(Library &);
~World();
void draw(Rend &, float camX, float camY, float camZ);
void tick();
float getO2Level() const;
float getH2OLevel() const;
float getTreeLevel() const;
void move(Entity &, float x, float y);
std::vector<Entity *> getAround(float x, float y, float rad = -1.0f) const;
void remove(Entity &);
void kill(Entity &);
int getNow() const;
bool isAlive(const Entity &) const;
int64_t getIncome() const;
template <typename T, typename... Args>
Entity *add(Args &&... args)
{
return internalAdd(std::make_unique<T>(*this, std::forward<Args>(args)...));
}
Sched sched;
std::unique_ptr<Terrain> terrain;
BotSpecs specs;
public:
int botsNum = 0;
int o2Rate = 0;
int h2ORate = 0;
int treesNum = 0;
int64_t money = 1000000000;
private:
Entity *internalAdd(std::unique_ptr<Entity> &&ent);
int64_t realO2Level = 0;
int64_t realH2OLevel = 0;
std::unordered_map<const Entity *, std::unique_ptr<Entity>> entities;
std::unordered_map<uint32_t, std::unordered_set<Entity *>> grid;
std::unordered_set<ActiveEntity *> active;
int now = 0;
};