123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "WorldUpdate.h"
- WorldUpdate::WorldUpdate( int type, int dimensionId, Framework::Vec3<int> minAffected, Framework::Vec3<int> maxAffected )
- : ReferenceCounter(),
- affectedDimensionId( dimensionId ),
- minAffected( minAffected ),
- maxAffected( maxAffected ),
- type( type )
- {}
- void WorldUpdate::writeAndCheck( Framework::StreamWriter* zWriter )
- {
- zWriter->schreibe( (char*)&type, 4 );
- this->write( zWriter );
- zWriter->schreibe( (char*)&type, 4 );
- }
- int WorldUpdate::getAffectedDimension() const
- {
- return affectedDimensionId;
- }
- const Framework::Vec3<int>& WorldUpdate::getMinAffectedPoint() const
- {
- return minAffected;
- }
- const Framework::Vec3<int>& WorldUpdate::getMaxAffectedPoint() const
- {
- return maxAffected;
- }
- int WorldUpdate::getType() const
- {
- return type;
- }
- int WorldUpdate::distanceTo( int x, int y ) const
- {
- int xDist = MIN( abs( x - minAffected.x ), abs( x - maxAffected.x ) );
- int yDist = MIN( abs( y - minAffected.y ), abs( y - maxAffected.y ) );
- if( x >= minAffected.x && x <= maxAffected.x )
- xDist = 0;
- if( y >= minAffected.y && y <= maxAffected.y )
- yDist = 0;
- return MIN( xDist, yDist );
- }
- WorldUpdateType::WorldUpdateType( int id )
- : ReferenceCounter()
- {
- StaticRegistry<WorldUpdateType>::INSTANCE.registerT( this, id );
- }
|