From: Mikko Rasa Date: Sat, 12 Nov 2022 15:40:28 +0000 (+0200) Subject: Cosmetic tweaks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=db01a6ed506ea2352b20f10b2694e249d2bba6c5;p=libs%2Fgame.git Cosmetic tweaks --- diff --git a/examples/bassteroids/source/gamecontroller.cpp b/examples/bassteroids/source/gamecontroller.cpp index 05586b0..eae5e2d 100644 --- a/examples/bassteroids/source/gamecontroller.cpp +++ b/examples/bassteroids/source/gamecontroller.cpp @@ -8,8 +8,8 @@ using namespace Msp; GameController::GameController(Game::Stage &s): System(s), - asteroid_setup{ .physical = { .body = { .mass = 200 }, .collider = { .type = ColliderType::CIRCLE, .radius = 3.0f } }, - .mesh = { .object_name = "Asteroid 1.object" }} + asteroid_setup{ .physical={ .body={ .mass=200 }, .collider={ .type=ColliderType::CIRCLE, .radius=3.0f } }, + .mesh={ .object_name="Asteroid 1.object" }} { } void GameController::tick(Time::TimeDelta) diff --git a/examples/bassteroids/source/physics.cpp b/examples/bassteroids/source/physics.cpp index 429715a..89feeed 100644 --- a/examples/bassteroids/source/physics.cpp +++ b/examples/bassteroids/source/physics.cpp @@ -193,9 +193,8 @@ void Physics::collide_circle_circle(unsigned i, unsigned j) if(d_sq - EventDispatcher &get_emitter(); + EventDispatcher &get_dispatcher(); public: template void add_observer(EventObserver &obs, std::function cb) - { get_emitter().add_observer(&obs, std::move(cb)); } + { get_dispatcher().add_observer(&obs, std::move(cb)); } void replace_observer(EventObserver &, EventObserver &); void remove_observer(EventObserver &); @@ -83,7 +83,7 @@ inline unsigned EventBus::get_event_id() } template -inline EventDispatcher &EventBus::get_emitter() +inline EventDispatcher &EventBus::get_dispatcher() { unsigned id = get_event_id(); if(dispatchers.size()<=id) diff --git a/source/game/eventsource.h b/source/game/eventsource.h index 5dacbee..0856e08 100644 --- a/source/game/eventsource.h +++ b/source/game/eventsource.h @@ -44,6 +44,14 @@ public: }; +template +template +inline void EventSource::cancel_observation() +{ + for(const auto &h: static_cast &>(*this).handlers) + h.observer->remove_source(*this); +} + template template inline void EventSource::emit(Args &&... args) const @@ -53,14 +61,6 @@ inline void EventSource::emit(Args &&... args) const bus.dispatch(event); } -template -template -inline void EventSource::cancel_observation() -{ - for(const auto &h: static_cast &>(*this).handlers) - h.observer->remove_source(*this); -} - } // namespace Msp::Game #endif