WorldUpdate.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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::write( Framework::StreamWriter* zWriter )
  10. {
  11. zWriter->schreibe( (char*)&type, 4 );
  12. }
  13. int WorldUpdate::getAffectedDimension() const
  14. {
  15. return affectedDimensionId;
  16. }
  17. const Framework::Vec3<int>& WorldUpdate::getMinAffectedPoint() const
  18. {
  19. return minAffected;
  20. }
  21. const Framework::Vec3<int>& WorldUpdate::getMaxAffectedPoint() const
  22. {
  23. return maxAffected;
  24. }
  25. int WorldUpdate::getType() const
  26. {
  27. return type;
  28. }
  29. int WorldUpdate::distanceTo( int x, int y ) const
  30. {
  31. int xDist = MIN( abs( x - minAffected.x ), abs( x - maxAffected.x ) );
  32. int yDist = MIN( abs( y - minAffected.y ), abs( y - maxAffected.y ) );
  33. if( x >= minAffected.x && x <= maxAffected.x )
  34. xDist = 0;
  35. if( y >= minAffected.y && y <= maxAffected.y )
  36. yDist = 0;
  37. return MIN( xDist, yDist );
  38. }
  39. WorldUpdateType::WorldUpdateType( int id )
  40. : ReferenceCounter()
  41. {
  42. StaticRegistry<WorldUpdateType>::INSTANCE.registerT( this, id );
  43. }