-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseObject.cpp
More file actions
35 lines (26 loc) · 894 Bytes
/
BaseObject.cpp
File metadata and controls
35 lines (26 loc) · 894 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
31
32
33
34
35
#include "Objects/BaseObject.h"
#include "pch.h"
std::string hash(const std::string& data) {
std::hash<std::string> hasher;
size_t hashed_value = hasher(data);
std::stringstream ss;
ss << std::hex << std::setw(16) << std::setfill('0') << hashed_value;
return ss.str();
}
std::string generateUniqueId() {
auto now = std::chrono::high_resolution_clock::now();
auto timestamp = now.time_since_epoch().count();
std::random_device rd;
std::mt19937_64 generator(rd());
std::uniform_int_distribution<unsigned long long> distribution;
unsigned long long random_value = distribution(generator);
std::stringstream ss;
ss << timestamp << "-" << random_value;
return hash(ss.str());
}
namespace TextScript {
BaseObject::BaseObject(const std::string& name, int x, int y)
: m_Name(name), X(x), Y(y){
m_ID = generateUniqueId();
}
}