mirror of
https://github.com/edubart/otclient.git
synced 2025-12-21 16:07:12 +01:00
Introduce 2 new functions to Map
- g_map.colorizeThing - g_map.removeThingColor
This commit is contained in:
@@ -216,6 +216,42 @@ bool Map::removeThingByPos(const Position& pos, int stackPos)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Map::colorizeThing(const ThingPtr& thing, const Color& color)
|
||||
{
|
||||
if(!thing)
|
||||
return;
|
||||
|
||||
if(thing->isItem())
|
||||
thing->static_self_cast<Item>()->setColor(color);
|
||||
else if(thing->isCreature()) {
|
||||
const TilePtr& tile = thing->getTile();
|
||||
assert(tile);
|
||||
|
||||
const ThingPtr& topThing = tile->getTopThing();
|
||||
assert(topThing);
|
||||
|
||||
topThing->static_self_cast<Item>()->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::removeThingColor(const ThingPtr& thing)
|
||||
{
|
||||
if(!thing)
|
||||
return;
|
||||
|
||||
if(thing->isItem())
|
||||
thing->static_self_cast<Item>()->setColor(Color::alpha);
|
||||
else if(thing->isCreature()) {
|
||||
const TilePtr& tile = thing->getTile();
|
||||
assert(tile);
|
||||
|
||||
const ThingPtr& topThing = tile->getTopThing();
|
||||
assert(topThing);
|
||||
|
||||
topThing->static_self_cast<Item>()->setColor(Color::alpha);
|
||||
}
|
||||
}
|
||||
|
||||
StaticTextPtr Map::getStaticText(const Position& pos)
|
||||
{
|
||||
for(auto staticText : m_staticTexts) {
|
||||
@@ -732,3 +768,5 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et: */
|
||||
|
||||
Reference in New Issue
Block a user