123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "EntityType.h"
- #include "Entity.h"
- #include "Globals.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;
- }
|