12345678910111213141516171819202122232425262728293031323334353637 |
- #include "AddEntityUpdate.h"
- #include "Dimension.h"
- #include "Entity.h"
- #include "EntityType.h"
- AddEntityUpdate::AddEntityUpdate(Entity* entity, int dimension)
- : WorldUpdate(WorldUpdateTypeEnum::ADD_ENTITY, dimension, entity->getLocation()),
- 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->zSpecialModel()->writeTo(zWriter);
- }
|