12345678910111213141516171819202122232425262728293031323334353637 |
- #include "EntityChangedUpdate.h"
- #include "Game.h"
- #include "EntityType.h"
- EntityChangedUpdate::EntityChangedUpdate( int entityId, Framework::Vec3<int> pos, int dimension )
- : WorldUpdate( EntityChangedUpdateType::ID, dimension, pos, pos ),
- entityId( entityId )
- {}
- EntityChangedUpdate::~EntityChangedUpdate()
- {}
- void EntityChangedUpdate::onUpdate( Dimension* zDimension )
- {}
- void EntityChangedUpdate::write( Framework::StreamWriter* zWriter )
- {
- Entity* entity = Game::INSTANCE->zEntity( entityId, getAffectedDimension() );
- if( entity )
- {
- int type = entity->zType()->getId();
- zWriter->schreibe( (char*)&entityId, 4 );
- zWriter->schreibe( (char*)&type, 4 );
- StaticRegistry<EntityType>::INSTANCE.zElement( type )->saveEntity( entity, zWriter );
- }
- else
- {
- int id = -1;
- zWriter->schreibe( (char*)&id, 4 );
- }
- }
- EntityChangedUpdateType::EntityChangedUpdateType()
- : WorldUpdateType( ID )
- {}
|