EntityType.cpp 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "EntityType.h"
  2. #include "Entity.h"
  3. #include "Registries.h"
  4. #include "Globals.h"
  5. EntityType::EntityType(int id, ModelInfo model)
  6. : id(id),
  7. model(model)
  8. {}
  9. Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
  10. {
  11. int id;
  12. zReader->lese((char*)&id, 4);
  13. Framework::Vec3<float> position;
  14. zReader->lese((char*)&position.x, 4);
  15. zReader->lese((char*)&position.y, 4);
  16. zReader->lese((char*)&position.z, 4);
  17. float maxSpeed;
  18. zReader->lese((char*)&maxSpeed, 4);
  19. bool specialModel = 0;
  20. zReader->lese((char*)&specialModel, 1);
  21. Entity* e;
  22. if (specialModel)
  23. {
  24. ModelInfo model(zReader);
  25. e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
  26. }
  27. else
  28. {
  29. e = new Entity(this, model.getModel(), model.getTexture(), id, position, maxSpeed);
  30. }
  31. if (currentGame->zKamera()->getEntityId() == id)
  32. {
  33. e->setPlayerControlled();
  34. }
  35. return e;
  36. }
  37. int EntityType::getId() const
  38. {
  39. return id;
  40. }