1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #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);
- float maxSpeed = entity->getMaxSpeed();
- zWriter->schreibe((char*)&maxSpeed, 4);
- bool special = !entity->hasDefaultModel();
- zWriter->schreibe((char*)&special, 1);
- if (special)
- entity->getSpecialModel().writeTo(zWriter);
- }
- AddEntityUpdateType::AddEntityUpdateType()
- : WorldUpdateType(ID)
- {}
|