EntityType.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "EntityType.h"
  2. #include "Entity.h"
  3. #include "Globals.h"
  4. EntityType::EntityType(int id, ModelInfo model)
  5. : id(id),
  6. model(model)
  7. {}
  8. Entity* EntityType::loadEntity(Framework::StreamReader* zReader) const
  9. {
  10. int id;
  11. zReader->lese((char*)&id, 4);
  12. Framework::Vec3<float> position;
  13. zReader->lese((char*)&position.x, 4);
  14. zReader->lese((char*)&position.y, 4);
  15. zReader->lese((char*)&position.z, 4);
  16. float maxSpeed;
  17. zReader->lese((char*)&maxSpeed, 4);
  18. float gravityMultiplier;
  19. zReader->lese((char*)&gravityMultiplier, 4);
  20. float jumpSpeed;
  21. zReader->lese((char*)&jumpSpeed, 4);
  22. bool specialModel = 0;
  23. zReader->lese((char*)&specialModel, 1);
  24. Entity* e;
  25. if (specialModel)
  26. {
  27. ModelInfo model(zReader);
  28. e = new Entity(this,
  29. model.getModel(),
  30. model.getTexture(),
  31. id,
  32. position,
  33. maxSpeed,
  34. gravityMultiplier,
  35. jumpSpeed,
  36. model.getSize());
  37. }
  38. else
  39. {
  40. e = new Entity(this,
  41. model.getModel(),
  42. model.getTexture(),
  43. id,
  44. position,
  45. maxSpeed,
  46. gravityMultiplier,
  47. jumpSpeed,
  48. model.getSize());
  49. }
  50. if (World::INSTANCE->zKamera()->getEntityId() == id)
  51. {
  52. e->setPlayerControlled();
  53. }
  54. return e;
  55. }
  56. int EntityType::getId() const
  57. {
  58. return id;
  59. }