123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #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);
- float gravityMultiplier = entity->getGravityMultiplier();
- zWriter->schreibe((char*)&gravityMultiplier, 4);
- float jumpSpeed = entity->getJumpSpeed();
- zWriter->schreibe((char*)&jumpSpeed, 4);
- bool special = !entity->hasDefaultModel();
- zWriter->schreibe((char*)&special, 1);
- if (special) entity->zSpecialModel()->writeTo(zWriter);
- }
|