Add clear methods to relevant context objects

This commit is contained in:
momo5502 2019-01-27 11:00:19 +01:00
parent 8516718882
commit 0fb12bdc32
5 changed files with 15 additions and 1 deletions

View File

@ -236,7 +236,7 @@ namespace game
MessageBoxA(nullptr, string.data(), nullptr, 0);
}), "alert");
const auto level_id = *game::native::levelEntityId;
const auto level_id = *native::levelEntityId;
chai->add_global(chaiscript::var(entity(context, level_id)), "level");
}
}

View File

@ -94,6 +94,12 @@ namespace game
return {listener.id};
}
void event_handler::clear()
{
this->event_listeners_.clear();
this->generic_event_listeners_.clear();
}
void event_handler::remove(const event_listener_handle& handle)
{
for (auto task : this->event_listeners_)

View File

@ -42,6 +42,8 @@ namespace game
event_listener_handle add_event_listener(event_listener listener);
event_listener_handle add_event_listener(generic_event_listener listener);
void clear();
private:
context* context_;
std::atomic_int64_t current_listener_id_ = 0;

View File

@ -56,6 +56,11 @@ namespace game
}
}
void scheduler::clear()
{
this->tasks_.clear();
}
task_handle scheduler::add(const std::function<void()>& callback, const long long milliseconds,
const bool is_volatile)
{

View File

@ -28,6 +28,7 @@ namespace game
explicit scheduler(context* context);
void run_frame();
void clear();
private:
context* context_;