forked from ucectoplasm/eft-packet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtk_map.hpp
91 lines (73 loc) · 2.16 KB
/
tk_map.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#pragma once
#include "common.hpp"
#include "tk_loot.hpp"
#include <string>
#include <unordered_map>
#include <mutex>
namespace tk
{
struct LootEntry
{
Vector3 pos;
std::string name;
int value;
bool container = false;
LootItem::Rarity rarity;
std::string bundle_path;
};
struct Observer
{
int pid;
uint8_t cid;
enum ObserverType
{
Self,
Player,
Scav
} type;
std::string id;
std::string group_id;
std::string name;
Vector3 last_pos;
Vector3 pos;
Vector3 rot;
int level = 0;
bool is_dead = false;
bool is_npc = false;
bool is_unspawned = false;
std::vector<LootEntry> inventory;
};
struct TemporaryLoot
{
int id; // Hash of the loot template ID. Could label dropped loot if we implement it.
Vector3 pos;
};
class Map
{
public:
Map(Vector3 min, Vector3 max);
Vector3 bounds_min() const { return m_min; }
Vector3 bounds_max() const { return m_max; }
void create_observer(int cid, Observer&& obs);
void destroy_observer(int cid);
Observer* get_observer_manual_lock(int cid);
std::vector<Observer*> get_observers_manual_lock();
Observer* get_player_manual_lock();
void add_loot_item(LootEntry&& entry);
std::vector<LootEntry*> get_loot_manual_lock();
void add_static_corpse(Vector3 pos);
std::vector<Vector3*> get_static_corpses_manual_lock();
TemporaryLoot* get_or_create_temporary_loot_manual_lock(int id);
std::vector<TemporaryLoot*> get_temporary_loots_manual_lock();
void lock();
void unlock();
private:
Vector3 m_min;
Vector3 m_max;
std::unordered_map<uint8_t, Observer> m_observers;
std::unordered_map<int, TemporaryLoot> m_temporary_loot;
std::vector<LootEntry> m_loot;
std::vector<Vector3> m_static_corpses;
std::mutex m_lock;
};
}