Mana
Loading...
Searching...
No Matches
actorspritemanager.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24#include "actorsprite.h"
25#include "being.h"
26#include "eventlistener.h"
27#include "flooritem.h"
28
30
31#include <memory>
32
33class LocalPlayer;
34class Map;
35
36using ActorSprites = std::set<ActorSprite *>;
37
39{
40 public:
42
44
48 void setMap(Map *map);
49
53 void setPlayer(LocalPlayer *player);
54
58 Being *createBeing(int id, ActorSprite::Type type, int subtype);
59
67 FloorItem *createItem(int id, int itemId, const Vector &position);
68
72 void destroyActor(ActorSprite *actor);
73
78 void scheduleDelete(ActorSprite *actor);
79
83 Being *findBeing(int id) const;
84
88 Being *findBeing(int x, int y,
90
94 Being *findBeingByPixel(int x, int y) const;
95
99 FloorItem *findItem(int id) const;
100
104 FloorItem *findItem(int x, int y, int maxDist = 0) const;
105
116 Being *findNearestLivingBeing(int x, int y, int maxTileDist,
118 Being *excluded = nullptr) const;
119
128 Being *findNearestLivingBeing(Being *aroundBeing, int maxTileDist,
129 ActorSprite::Type type = Being::UNKNOWN) const;
130
134 Being *findBeingByName(const std::string &name,
135 ActorSprite::Type type = Being::UNKNOWN) const;
136
140 const ActorSprites &getAll() const;
141
148 bool hasActorSprite(ActorSprite *someActor) const;
149
154 void logic();
155
159 void clear();
160
162
164
165 void updatePlayerNames();
166
167 void event(Event::Channel channel, const Event &event) override;
168
169 protected:
170 friend class PlayerNamesLister;
172
173 std::unique_ptr<AutoCompleteLister> mPlayerNames;
174 std::unique_ptr<AutoCompleteLister> mPlayerNPCNames;
178};
179
std::set< ActorSprite * > ActorSprites
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
Being * createBeing(int id, ActorSprite::Type type, int subtype)
Create a Being and add it to the list of ActorSprites.
AutoCompleteLister * getPlayerNPCNameLister() const
FloorItem * findItem(int id) const
Returns a specific FloorItem, by id.
Being * findNearestLivingBeing(int x, int y, int maxTileDist, ActorSprite::Type type=Being::UNKNOWN, Being *excluded=nullptr) const
Returns a being nearest to specific coordinates.
void scheduleDelete(ActorSprite *actor)
Destroys the given ActorSprite at the end of ActorSpriteManager::logic.
std::unique_ptr< AutoCompleteLister > mPlayerNPCNames
Being * findBeingByName(const std::string &name, ActorSprite::Type type=Being::UNKNOWN) const
Finds a being by name and (optionally) by type.
void destroyActor(ActorSprite *actor)
Immediately destroys the given actor.
void setPlayer(LocalPlayer *player)
Sets the current player.
bool hasActorSprite(ActorSprite *someActor) const
Returns true if the given ActorSprite is in the manager's list, false otherwise.
Being * findBeingByPixel(int x, int y) const
Returns a being at the specific pixel.
const ActorSprites & getAll() const
Returns the whole list of beings.
std::unique_ptr< AutoCompleteLister > mPlayerNames
Being * findBeing(int id) const
Returns a specific Being, by id;.
void event(Event::Channel channel, const Event &event) override
void setMap(Map *map)
Sets the map on which ActorSprites are created.
FloorItem * createItem(int id, int itemId, const Vector &position)
Create a FloorItem and add it to the list of ActorSprites.
void clear()
Destroys all ActorSprites except the local player.
void logic()
Performs ActorSprite logic and deletes ActorSprite scheduled to be deleted.
AutoCompleteLister * getPlayerNameLister() const
Definition being.h:65
Definition event.h:42
Channel
Definition event.h:45
An item lying on the floor.
Definition flooritem.h:32
The local player character.
Definition localplayer.h:75
A tile map.
Definition map.h:147
Vector class.
Definition vector.h:33