123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include "AddEntityUpdate.h"
- #include "Dimension.h"
- #include "EntityType.h"
- #include "StaticRegistry.h"
- AddEntityUpdate::AddEntityUpdate(Entity* entity, int dimension)
- : WorldUpdate(AddEntityUpdateType::ID, dimension, entity->getPosition(), entity->getPosition()),
- entity(entity)
- {}
- AddEntityUpdate::~AddEntityUpdate()
- {
- entity->release();
- }
- void AddEntityUpdate::onUpdate(Dimension* zDimension)
- {
- zDimension->addEntity(dynamic_cast<Entity*>(entity->getThis()));
- }
- void AddEntityUpdate::write(Framework::StreamWriter* zWriter)
- {
- int id = entity->zType()->getId();
- zWriter->schreibe((char*)&id, 4);
- id = entity->getId();
- zWriter->schreibe((char*)&id, 4);
- Framework::Vec3<float> pos = entity->getPosition();
- zWriter->schreibe((char*)&pos.x, 4);
- zWriter->schreibe((char*)&pos.y, 4);
- zWriter->schreibe((char*)&pos.z, 4);
- bool special = !entity->hasDefaultModel();
- zWriter->schreibe((char*)&special, 1);
- if (special)
- entity->getSpecialModel().writeTo(zWriter);
- }
- AddEntityUpdateType::AddEntityUpdateType()
- : WorldUpdateType(ID)
- {}
|