Fixing a stupid bug where it would crash because a fact wasn't in the world.
This commit is contained in:
parent
93f53d1714
commit
5a6494acf5
7 changed files with 11 additions and 6 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <tuple>
|
||||
#include <queue>
|
||||
#include "tser.hpp"
|
||||
#include "dbc.hpp"
|
||||
|
||||
namespace DinkyECS {
|
||||
|
||||
|
@ -56,8 +57,11 @@ namespace DinkyECS {
|
|||
|
||||
template <typename Comp>
|
||||
Comp &get_the() {
|
||||
auto comp_id = std::type_index(typeid(Comp));
|
||||
dbc::check($facts.contains(comp_id), "!!!! ATTEMPT to access world fact that hasn't been set yet.");
|
||||
|
||||
// use .at to get std::out_of_range if fact not set
|
||||
std::any &res = $facts.at(std::type_index(typeid(Comp)));
|
||||
std::any &res = $facts.at(comp_id);
|
||||
return std::any_cast<Comp&>(res);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue