WorldUpdate.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 dist = abs( x - minAffected.x );
  28. if( dist > abs( x - maxAffected.x ) )
  29. dist = abs( x - maxAffected.x );
  30. if( dist > abs( y - minAffected.y ) )
  31. dist = abs( y - minAffected.y );
  32. if( dist > abs( y - maxAffected.y ) )
  33. dist = abs( y - maxAffected.y );
  34. return dist;
  35. }
  36. WorldUpdateType::WorldUpdateType( int id )
  37. : ReferenceCounter()
  38. {
  39. StaticRegistry<WorldUpdateType>::INSTANCE.registerT( this, id );
  40. }