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