Commit 058a14f0 authored by louiz’'s avatar louiz’

Clean some little things

parent 13b2155b
......@@ -109,7 +109,6 @@ std::vector<EntityId> get_selected_entities_with_ability(const GameClient* game)
Ability* ability = abilities->find(T::ability_type);
if (ability)
{
T* blink = static_cast<T*>(ability);
// Check cooldown, mana, etc etc
Entity* e = const_cast<Entity*>(entity);
ids.push_back(e->get_id());
......
......@@ -9,6 +9,7 @@
*/
#include <gui/screen/left_click.hpp>
#include <functional>
class GuiAbility
{
......@@ -17,6 +18,7 @@ public:
~GuiAbility() = default;
LeftClick left_click;
std::function<void()> callback;
private:
GuiAbility(const GuiAbility&) = delete;
......
......@@ -155,7 +155,10 @@ void Hud::activate_ability(const std::size_t nb)
this->game->get_hud().add_info_message("The ability type is " + std::to_string(static_cast<int>(ability->get_type())));
const GuiAbility* gui_ab = this->abilities_panel.get(ability->get_type());
assert(gui_ab);
this->screen->set_left_click(gui_ab->left_click);
if (gui_ab->callback)
gui_ab->callback();
else
this->screen->set_left_click(gui_ab->left_click);
}
}
}
......
......@@ -152,21 +152,14 @@ void World::do_cast(const std::vector<EntityId>& ids, const Position& pos, const
for (const EntityId id: ids)
{
Entity* entity = this->get_entity_by_id(id);
if (entity)
{
Ability* ability = get_ability(entity, type);
if (ability)
{
ability->cast(entity, pos, queue);
}
else
{
log_warning("Received a cast order, but entity " << id << " does not have ability: " << static_cast<int>(type));
}
}
if (!entity)
continue;
Ability* ability = get_ability(entity, type);
if (ability)
ability->cast(entity, this, pos, queue);
else
{
log_warning("Received a cast order for non existing entity: " << id);
log_warning("Received a cast order, but entity " << id << " does not have ability: " << static_cast<int>(type));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment