EntityType.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include "EntityType.h"
  2. #include "Entity.h"
  3. #include "Globals.h"
  4. #include "Registries.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. float gravityMultiplier;
  20. zReader->lese((char*)&gravityMultiplier, 4);
  21. float jumpSpeed;
  22. zReader->lese((char*)&jumpSpeed, 4);
  23. bool specialModel = 0;
  24. zReader->lese((char*)&specialModel, 1);
  25. Entity* e;
  26. if (specialModel)
  27. {
  28. ModelInfo model(zReader);
  29. e = new Entity(this,
  30. model.getModel(),
  31. model.getTexture(),
  32. id,
  33. position,
  34. maxSpeed,
  35. gravityMultiplier,
  36. jumpSpeed,
  37. model.getSize());
  38. }
  39. else
  40. {
  41. e = new Entity(this,
  42. model.getModel(),
  43. model.getTexture(),
  44. id,
  45. position,
  46. maxSpeed,
  47. gravityMultiplier,
  48. jumpSpeed,
  49. model.getSize());
  50. }
  51. if (World::INSTANCE->zKamera()->getEntityId() == id)
  52. {
  53. e->setPlayerControlled();
  54. }
  55. return e;
  56. }
  57. int EntityType::getId() const
  58. {
  59. return id;
  60. }