WorldUpdate.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "WorldUpdate.h"
  2. WorldUpdate::WorldUpdate(int type, int dimensionId, Framework::Vec3<int> minAffected, Framework::Vec3<int> maxAffected)
  3. : ReferenceCounter(),
  4. affectedDimensionId(dimensionId),
  5. minAffected(minAffected),
  6. maxAffected(maxAffected),
  7. type(type)
  8. {}
  9. void WorldUpdate::writeAndCheck(Framework::StreamWriter* zWriter)
  10. {
  11. zWriter->schreibe((char*)&type, 4);
  12. this->write(zWriter);
  13. zWriter->schreibe((char*)&type, 4);
  14. }
  15. int WorldUpdate::getAffectedDimension() const
  16. {
  17. return affectedDimensionId;
  18. }
  19. const Framework::Vec3<int>& WorldUpdate::getMinAffectedPoint() const
  20. {
  21. return minAffected;
  22. }
  23. const Framework::Vec3<int>& WorldUpdate::getMaxAffectedPoint() const
  24. {
  25. return maxAffected;
  26. }
  27. int WorldUpdate::getType() const
  28. {
  29. return type;
  30. }
  31. int WorldUpdate::distanceTo(int x, int y) const
  32. {
  33. int xDist = MIN(abs(x - minAffected.x), abs(x - maxAffected.x));
  34. int yDist = MIN(abs(y - minAffected.y), abs(y - maxAffected.y));
  35. if (x >= minAffected.x && x <= maxAffected.x)
  36. xDist = 0;
  37. if (y >= minAffected.y && y <= maxAffected.y)
  38. yDist = 0;
  39. return MIN(xDist, yDist);
  40. }