60 for(
const ThingPtr& thing : m_things) {
61 if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom())
66 for(
auto flag: flags) {
81 thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
91 m_drawElevation += thing->getElevation();
99 for(
auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
101 if(thing->isOnTop() || thing->isOnBottom() || thing->isGroundBorder() || thing->isGround() || thing->isCreature())
103 thing->draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
104 m_drawElevation += thing->getElevation();
113 for(
const CreaturePtr& creature : m_walkingCreatures) {
114 creature->draw(
Point(dest.
x + ((creature->getPosition().x - m_position.
x)*
Otc::TILE_PIXELS - m_drawElevation)*scaleFactor,
115 dest.
y + ((creature->getPosition().y - m_position.
y)*
Otc::TILE_PIXELS - m_drawElevation)*scaleFactor), scaleFactor, animate, lightView);
119 for(
auto it = m_things.rbegin(); it != m_things.rend(); ++it) {
121 if(!thing->isCreature())
124 if(creature && (!creature->
isWalking() || !animate))
125 creature->
draw(dest - m_drawElevation*scaleFactor, scaleFactor, animate, lightView);
136 for(
const ThingPtr& thing : m_things)
138 thing->draw(dest, scaleFactor, animate, lightView);
150 while(!m_things.empty())
156 m_walkingCreatures.push_back(creature);
161 auto it = std::find(m_walkingCreatures.begin(), m_walkingCreatures.end(), creature);
162 if(it != m_walkingCreatures.end())
163 m_walkingCreatures.erase(it);
171 if(thing->isEffect()) {
172 if(thing->isTopEffect())
173 m_effects.insert(m_effects.begin(), thing->static_self_cast<
Effect>());
175 m_effects.push_back(thing->static_self_cast<
Effect>());
184 if(stackPos < 0 || stackPos == 255) {
185 int priority = thing->getStackPriority();
194 append = (priority <= 3);
202 for(stackPos = 0; stackPos < (int)m_things.size(); ++stackPos) {
203 int otherPriority = m_things[stackPos]->getStackPriority();
204 if((append && otherPriority > priority) || (!append && otherPriority >= priority))
207 }
else if(stackPos > (
int)m_things.size())
208 stackPos = m_things.size();
210 m_things.insert(m_things.begin() + stackPos, thing);
227 thing->setPosition(m_position);
230 if(thing->isTranslucent())
231 checkTranslucentLight();
239 bool removed =
false;
241 if(thing->isEffect()) {
243 auto it = std::find(m_effects.begin(), m_effects.end(), effect);
244 if(it != m_effects.end()) {
249 auto it = std::find(m_things.begin(), m_things.end(), thing);
250 if(it != m_things.end()) {
256 thing->onDisappear();
258 if(thing->isTranslucent())
259 checkTranslucentLight();
266 if(stackPos >= 0 && stackPos < (
int)m_things.size())
267 return m_things[stackPos];
274 if(effect->getId() ==
id)
281 return std::find(m_things.begin(), m_things.end(), thing) != m_things.end();
286 for(
uint stackpos = 0; stackpos < m_things.size(); ++stackpos)
287 if(thing == m_things[stackpos])
296 for(
const ThingPtr& thing : m_things)
297 if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature())
299 return m_things[m_things.size() - 1];
304 std::vector<ItemPtr> items;
305 for(
const ThingPtr& thing : m_things) {
309 items.push_back(item);
316 std::vector<CreaturePtr> creatures;
317 for(
const ThingPtr& thing : m_things) {
318 if(thing->isCreature())
319 creatures.push_back(thing->static_self_cast<
Creature>());
329 if(firstObject->isGround() && firstObject->isItem())
330 return firstObject->static_self_cast<
Item>();
336 int groundSpeed = 100;
338 groundSpeed = ground->getGroundSpeed();
345 if(m_minimapColor != 0)
346 return m_minimapColor;
348 for(
const ThingPtr& thing : m_things) {
349 if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop())
351 uint8 c = thing->getMinimapColor();
363 for(
auto thing: m_things) {
364 if(!thing->isIgnoreLook() && (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()))
376 for(
auto thing: m_things) {
377 if (thing->isForceUse() || (!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature() && !thing->isSplash()))
381 for(
auto thing: m_things) {
382 if (!thing->isGround() && !thing->isGroundBorder() && !thing->isCreature() && !thing->isSplash())
392 for(
auto thing: m_things) {
393 if(thing->isLocalPlayer())
395 else if(thing->isCreature() && !thing->isLocalPlayer())
398 if(!creature && !m_walkingCreatures.empty())
399 creature = m_walkingCreatures.back();
403 for(
int xi=-1;xi<=1;++xi) {
404 for(
int yi=-1;yi<=1;++yi) {
406 if(pos == m_position)
412 if(c->isWalking() && c->getLastStepFromPosition() == m_position && c->getStepProgress() < 0.75f) {
428 for(
uint i = 0; i < m_things.size(); ++i) {
430 if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop() && !thing->isCreature()) {
431 if(i > 0 && thing->isNotMoveable())
432 return m_things[i-1];
437 for(
const ThingPtr& thing : m_things) {
438 if(thing->isCreature())
453 for(
auto thing: m_things) {
454 if(thing->isForceUse())
458 for(
uint i = 0; i < m_things.size(); ++i) {
460 if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) {
461 if(i > 0 && thing->isSplash())
462 return m_things[i-1];
467 for(
auto thing: m_things) {
468 if(!thing->isGround() && !thing->isOnTop())
480 for(
const ThingPtr& thing : m_things) {
481 if(thing->isNotWalkable())
484 if(!ignoreCreatures) {
485 if(thing->isCreature()) {
497 for(
const ThingPtr& thing : m_things)
498 if(thing->isNotPathable())
514 return firstObject && firstObject->isFullGround();
519 if(!m_walkingCreatures.empty())
521 for(
const ThingPtr& thing : m_things)
522 if(thing->getHeight() != 1 || thing->getWidth() != 1)
529 for(
const ThingPtr& thing : m_things)
530 if(thing->blockProjectile())
537 bool hasGround =
false;
538 bool hasOnBottom =
false;
539 bool hasIgnoreLook =
false;
540 for(
const ThingPtr& thing : m_things) {
541 if(thing->isGround())
543 if(thing->isOnBottom())
545 if((hasGround || hasOnBottom) && !hasIgnoreLook)
553 return m_things.size() == 0;
558 return !m_things.empty() || !m_walkingCreatures.empty() || !m_effects.empty();
563 for(
const ThingPtr& thing : m_things)
564 if(thing->isHookEast())
571 for(
const ThingPtr& thing : m_things)
572 if(thing->isHookSouth())
579 for(
const ThingPtr& thing : m_things)
580 if(thing->isCreature())
591 if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || firstThing->isOnBottom()))
593 }
else if(firstThing && !firstThing->isDontHide() && (firstThing->isGround() || (firstThing->isOnBottom() && firstThing->blockProjectile())))
601 return m_walkingCreatures.empty() && m_effects.empty() && m_things.empty() && m_flags == 0 && m_minimapColor == 0;
607 for(
const ThingPtr& thing : m_things)
608 if(thing->getElevation() > 0)
618 void Tile::checkTranslucentLight()
631 bool translucent =
false;
632 for(
const ThingPtr& thing : m_things) {
633 if(thing->isTranslucent() || thing->hasLensHelp()) {