12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include "EntityType.h"
- #include "Entity.h"
- #include "Globals.h"
- #include "Registries.h"
- EntityType::EntityType(int id, ModelInfo model)
- : id(id),
- model(model)
- {}
- Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
- {
- int id;
- zReader->lese((char*)&id, 4);
- Framework::Vec3<float> position;
- zReader->lese((char*)&position.x, 4);
- zReader->lese((char*)&position.y, 4);
- zReader->lese((char*)&position.z, 4);
- float maxSpeed;
- zReader->lese((char*)&maxSpeed, 4);
- float gravityMultiplier;
- zReader->lese((char*)&gravityMultiplier, 4);
- float jumpSpeed;
- zReader->lese((char*)&jumpSpeed, 4);
- bool specialModel = 0;
- zReader->lese((char*)&specialModel, 1);
- Entity* e;
- if (specialModel)
- {
- ModelInfo model(zReader);
- e = new Entity(this,
- model.getModel(),
- model.getTexture(),
- id,
- position,
- maxSpeed,
- gravityMultiplier,
- jumpSpeed,
- model.getSize());
- }
- else
- {
- e = new Entity(this,
- model.getModel(),
- model.getTexture(),
- id,
- position,
- maxSpeed,
- gravityMultiplier,
- jumpSpeed,
- model.getSize());
- }
- if (World::INSTANCE->zKamera()->getEntityId() == id)
- {
- e->setPlayerControlled();
- }
- return e;
- }
- int EntityType::getId() const
- {
- return id;
- }
|