Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Creature::canSee(const Position& myPos, const Position& pos, uint32_t viewRangeX, uint32_t viewRangeY)
- {
- if(myPos.z <= 7)
- {
- //we are on ground level or above (7 -> 0)
- //view is from 7 -> 0
- if(pos.z > 7)
- return false;
- }
- else if(myPos.z >= 8)
- {
- //we are underground (8 -> 15)
- //view is +/- 2 from the floor we stand on
- if(std::abs(myPos.z - pos.z) > 2)
- return false;
- }
- int32_t offsetz = myPos.z - pos.z;
- return (((uint32_t)pos.x >= myPos.x - viewRangeX + offsetz) && ((uint32_t)pos.x <= myPos.x + viewRangeX + offsetz) &&
- ((uint32_t)pos.y >= myPos.y - viewRangeY + offsetz) && ((uint32_t)pos.y <= myPos.y + viewRangeY + offsetz));
- }
Add Comment
Please, Sign In to add comment