GUECS now doesn't have the facts feature from DinkyECS and instead you refer to the whole area with gui.MAIN. This is an entity that's at 0 and represents the whole grid. Background is placed there.
This commit is contained in:
parent
abea6da2e0
commit
7c90eb6da1
5 changed files with 7 additions and 39 deletions
30
guecs.hpp
30
guecs.hpp
|
@ -150,11 +150,10 @@ namespace guecs {
|
|||
|
||||
class UI {
|
||||
public:
|
||||
unsigned long entity_count = 0;
|
||||
Entity MAIN = 0;
|
||||
unsigned long entity_count = 1;
|
||||
std::unordered_map<std::type_index, EntityMap> $components;
|
||||
std::unordered_map<std::type_index, std::any> $facts;
|
||||
std::unordered_map<std::type_index, std::any> $component_storages;
|
||||
|
||||
std::unordered_map<string, Entity> $name_ents;
|
||||
shared_ptr<sf::Font> $font = nullptr;
|
||||
lel::Parser $parser;
|
||||
|
@ -212,31 +211,6 @@ namespace guecs {
|
|||
return $components[std::type_index(typeid(Comp))];
|
||||
}
|
||||
|
||||
|
||||
template <typename Comp>
|
||||
bool has_the() {
|
||||
auto comp_id = std::type_index(typeid(Comp));
|
||||
return $facts.contains(comp_id);
|
||||
}
|
||||
|
||||
template <typename Comp>
|
||||
void set_the(Comp val) {
|
||||
$facts.insert_or_assign(std::type_index(typeid(Comp)), val);
|
||||
}
|
||||
|
||||
template <typename Comp>
|
||||
Comp &get_the() {
|
||||
auto comp_id = std::type_index(typeid(Comp));
|
||||
dbc::check($facts.contains(comp_id),
|
||||
fmt::format("!!!! ATTEMPT to access world fact that hasn't "
|
||||
"been set yet: {}",
|
||||
typeid(Comp).name()));
|
||||
|
||||
// use .at to get std::out_of_range if fact not set
|
||||
std::any &res = $facts.at(comp_id);
|
||||
return std::any_cast<Comp &>(res);
|
||||
}
|
||||
|
||||
template <typename Comp>
|
||||
void set(Entity ent, Comp val) {
|
||||
EntityMap &map = entity_map_for<Comp>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue