2
-canJump
-0
canSprint
0
+canJump
+0
bool isHit(void) const;
// returns true if this entity is near the one provided
- bool isNear(Entity e);
+ bool isNear(const Entity *e);
// returns true if the coordinate is within the entity
bool isInside(vec2 coord) const;
}
}
- if(e->isInside(ui::mouse) && player->isNear(*e)) {
+ if(e->isInside(ui::mouse) && player->isNear(e)) {
e->near = true;
if (e->type == OBJECTT)
ObjectSelected = true;
e->near = false;
}
} else if (e->type == MOBT) {
- e->near = player->isNear(*e);
+ e->near = player->isNear(e);
e->wander();
}
}
height = getItemHeight(iname);
}
-bool Entity::isNear(Entity e) {
- return pow(e.loc.x - loc.x, 2) + pow(e.loc.y - loc.y, 2) <= pow(HLINES(40), 2);
+bool Entity::isNear(const Entity *e) {
+ return pow(e->loc.x - loc.x, 2) + pow(e->loc.y - loc.y, 2) <= pow(HLINES(40), 2);
}
void NPC::drawThingy(void) const
inv = nullptr;
rider = nullptr;
canMove = true;
+ loc = 0;
}
Page::Page(void) : Mob()
{
auto n = std::find_if(std::begin(entity), std::end(entity), [&](Entity *&a) {
return ((a->type == MOBT) || (a->type == NPCT) || a->type == MERCHT) &&
- e.isNear(*a) && (e.left ? (a->loc.x < e.loc.x) : (a->loc.x > e.loc.x));
+ e.isNear(a) && (e.left ? (a->loc.x < e.loc.x) : (a->loc.x > e.loc.x));
});
return n == std::end(entity) ? nullptr : *n;
getNearMob(Entity &e)
{
auto n = std::find_if(std::begin(mob), std::end(mob), [&](Mob *&a) {
- return e.isNear(*a) && (e.left ? (a->loc.x < e.loc.x + e.width / 2) : (a->loc.x > e.loc.x + e.width / 2));
+ return e.isNear(a) && (e.left ? (a->loc.x < e.loc.x + e.width / 2) : (a->loc.x > e.loc.x + e.width / 2));
});
return n == std::end(mob) ? nullptr : *n;