Entity.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. #include "Entity.h"
  2. #include <Text.h>
  3. #include "BlockType.h"
  4. #include "Dimension.h"
  5. #include "EntityRemovedUpdate.h"
  6. #include "Game.h"
  7. #include "ItemSkill.h"
  8. #include "NoBlock.h"
  9. ActionTarget::ActionTarget(Vec3<int> blockPos, Direction blockSide)
  10. : blockPos(blockPos),
  11. targetBlockSide(blockSide),
  12. entityId(-1)
  13. {}
  14. ActionTarget::ActionTarget(int entityId)
  15. : entityId(entityId)
  16. {}
  17. bool ActionTarget::isBlock(
  18. Framework::Vec3<int> blockPos, Direction blockSide) const
  19. {
  20. return this->entityId == -1 && this->blockPos == blockPos
  21. && (this->targetBlockSide == targetBlockSide
  22. || blockSide == NO_DIRECTION);
  23. }
  24. bool ActionTarget::isEntity(int entityId) const
  25. {
  26. return this->entityId == entityId;
  27. }
  28. void ActionTarget::useItemSkillOnTarget(
  29. Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem)
  30. {
  31. if (entityId >= 0)
  32. {
  33. Entity* target = Game::INSTANCE->zEntity(entityId);
  34. if (target) zItemSkill->use(zActor, zUsedItem, target);
  35. }
  36. else
  37. {
  38. Block* block = Game::INSTANCE->zRealBlockInstance(
  39. blockPos, zActor->getDimensionId());
  40. if (block) zItemSkill->use(zActor, zUsedItem, block);
  41. }
  42. }
  43. void ActionTarget::interactItemSkillOnTarget(
  44. Entity* zActor, ItemSkill* zItemSkill, Item* zUsedItem)
  45. {
  46. if (zItemSkill)
  47. {
  48. if (entityId >= 0)
  49. {
  50. Entity* target = Game::INSTANCE->zEntity(entityId);
  51. if (target) zItemSkill->interact(zActor, zUsedItem, target);
  52. }
  53. else
  54. {
  55. Block* block = Game::INSTANCE->zRealBlockInstance(
  56. blockPos, zActor->getDimensionId());
  57. if (block) zItemSkill->interact(zActor, zUsedItem, block);
  58. }
  59. }
  60. else
  61. {
  62. if (entityId >= 0)
  63. {
  64. Block* block = Game::INSTANCE->zRealBlockInstance(
  65. blockPos, zActor->getDimensionId());
  66. if (block) block->interact(zUsedItem, zActor);
  67. }
  68. else
  69. {
  70. Block* block = Game::INSTANCE->zRealBlockInstance(
  71. blockPos, zActor->getDimensionId());
  72. if (block) block->interact(zUsedItem, zActor);
  73. }
  74. }
  75. }
  76. void ActionTarget::placeBlock(Entity* zActor, Item* zItem)
  77. {
  78. if (zActor->getStamina() > 0.2f)
  79. {
  80. if (zItem->canBePlacedAt(zActor->getDimensionId(),
  81. blockPos + getDirection(targetBlockSide)))
  82. {
  83. Block* block = zItem->zPlacedBlockType()->createBlockAt(
  84. blockPos + getDirection(targetBlockSide),
  85. zActor->getDimensionId(),
  86. zItem);
  87. if (block)
  88. {
  89. Game::INSTANCE->zDimension(zActor->getDimensionId())
  90. ->placeBlock(block->getPos(), block);
  91. zItem->onPlaced();
  92. zActor->setStamina(zActor->getStamina() - 0.2f);
  93. }
  94. }
  95. }
  96. }
  97. void ActionTarget::toMessage(
  98. const ActionTarget* zTarget, int dimensionId, NetworkMessage* zMsg)
  99. {
  100. if (zTarget)
  101. {
  102. if (zTarget->entityId >= 0)
  103. {
  104. char* message = new char[6];
  105. message[0] = 3;
  106. message[1] = 1;
  107. *(int*)(message + 2) = zTarget->entityId;
  108. zMsg->setMessage(message, 6);
  109. }
  110. else
  111. {
  112. Framework::Text targetUIML = "";
  113. auto block
  114. = Game::INSTANCE->zBlockAt(zTarget->blockPos, dimensionId);
  115. if (block.isA())
  116. {
  117. targetUIML = block.getA()->getTargetUIML();
  118. }
  119. else if (block.isB())
  120. {
  121. targetUIML = StaticRegistry<BlockType>::INSTANCE
  122. .zElement(block.getB())
  123. ->getTargetUIML();
  124. }
  125. char* message = new char[18 + targetUIML.getLength() + 2];
  126. message[0] = 3;
  127. message[1] = 2;
  128. *(int*)(message + 2) = zTarget->blockPos.x;
  129. *(int*)(message + 6) = zTarget->blockPos.y;
  130. *(int*)(message + 10) = zTarget->blockPos.z;
  131. *(int*)(message + 14) = zTarget->targetBlockSide;
  132. short len = (short)targetUIML.getLength();
  133. *(short*)(message + 18) = len;
  134. memcpy(message + 20, targetUIML.getText(), len);
  135. zMsg->setMessage(message, 18 + len + 2);
  136. }
  137. }
  138. else
  139. {
  140. char* message = new char[2];
  141. message[0] = 3;
  142. message[1] = 0;
  143. zMsg->setMessage(message, 2);
  144. }
  145. }
  146. void ActionTarget::save(ActionTarget* zTarget, Framework::StreamWriter* zWriter)
  147. {
  148. if (zTarget)
  149. {
  150. if (zTarget->entityId >= 0)
  151. {
  152. char b = 1;
  153. zWriter->schreibe(&b, 1);
  154. zWriter->schreibe((char*)&zTarget->entityId, 4);
  155. }
  156. else
  157. {
  158. char b = 2;
  159. zWriter->schreibe(&b, 1);
  160. zWriter->schreibe((char*)&zTarget->blockPos.x, 4);
  161. zWriter->schreibe((char*)&zTarget->blockPos.y, 4);
  162. zWriter->schreibe((char*)&zTarget->blockPos.z, 4);
  163. zWriter->schreibe((char*)&zTarget->targetBlockSide, 4);
  164. }
  165. }
  166. else
  167. {
  168. char b = 0;
  169. zWriter->schreibe(&b, 1);
  170. }
  171. }
  172. ActionTarget* ActionTarget::load(Framework::StreamReader* zReader)
  173. {
  174. char b;
  175. zReader->lese(&b, 1);
  176. if (b == 1)
  177. {
  178. int id;
  179. zReader->lese((char*)&id, 4);
  180. return new ActionTarget(id);
  181. }
  182. else if (b == 2)
  183. {
  184. Framework::Vec3<int> pos;
  185. Direction side;
  186. zReader->lese((char*)&pos.x, 4);
  187. zReader->lese((char*)&pos.y, 4);
  188. zReader->lese((char*)&pos.z, 4);
  189. zReader->lese((char*)&side, 4);
  190. return new ActionTarget(pos, side);
  191. }
  192. return 0;
  193. }
  194. Entity::Entity(
  195. int typeId, Framework::Vec3<float> location, int dimensionId, int entityId)
  196. : Inventory(location, dimensionId, true),
  197. chatSecurityLevel(0),
  198. speed(0, 0, 0),
  199. faceDir(1, 0, 0),
  200. target(0),
  201. typeId(typeId),
  202. removed(0),
  203. gravityMultiplier(1.f),
  204. id(entityId),
  205. placeBlockCooldown(0)
  206. {}
  207. void Entity::onDeath()
  208. {
  209. removed = 1;
  210. Game::INSTANCE->requestWorldUpdate(
  211. new EntityRemovedUpdate(id, dimensionId, location));
  212. }
  213. void Entity::useItem(int typeId, Item* zItem, bool left)
  214. {
  215. if (left)
  216. {
  217. if (!zItem || zItem->isUsable())
  218. {
  219. cs.lock();
  220. if (target)
  221. {
  222. ItemSkill* selected = zSkill(typeId);
  223. if (!selected)
  224. {
  225. selected
  226. = StaticRegistry<ItemType>::INSTANCE.zElement(typeId)
  227. ->createDefaultItemSkill();
  228. if (selected) skills.add(selected);
  229. }
  230. if (!selected)
  231. {
  232. selected = zSkill(ItemTypeEnum::PLAYER_HAND);
  233. }
  234. target->useItemSkillOnTarget(this, selected, zItem);
  235. }
  236. cs.unlock();
  237. }
  238. else if (left)
  239. {
  240. useItem(ItemTypeEnum::PLAYER_HAND, 0, left);
  241. }
  242. }
  243. else
  244. {
  245. if (zItem && zItem->isEatable())
  246. { // eat item
  247. zItem->applyFoodEffects(this);
  248. }
  249. else if (zItem && zItem->isPlaceable())
  250. { // place item
  251. if (placeBlockCooldown <= 0)
  252. {
  253. cs.lock();
  254. if (target)
  255. {
  256. target->placeBlock(this, zItem);
  257. placeBlockCooldown = 15;
  258. }
  259. cs.unlock();
  260. }
  261. }
  262. else if (!zItem || zItem->isUsable())
  263. { // use item skill
  264. cs.lock();
  265. if (target)
  266. {
  267. ItemSkill* selected = zSkill(typeId);
  268. if (!selected)
  269. {
  270. selected
  271. = StaticRegistry<ItemType>::INSTANCE.zElement(typeId)
  272. ->createDefaultItemSkill();
  273. if (selected) skills.add(selected);
  274. }
  275. target->interactItemSkillOnTarget(this, selected, zItem);
  276. }
  277. cs.unlock();
  278. }
  279. }
  280. }
  281. void Entity::onTargetChange() {}
  282. void Entity::interact(Item* zItem, Entity* zActor) {}
  283. void Entity::addMovementFrame(MovementFrame& frame)
  284. {
  285. cs.lock();
  286. movements.add(frame);
  287. cs.unlock();
  288. NetworkMessage* message = new NetworkMessage();
  289. message->addressEntity(this);
  290. char* msg = new char[37];
  291. msg[0] = 0;
  292. *(float*)(msg + 1) = frame.direction.x;
  293. *(float*)(msg + 5) = frame.direction.y;
  294. *(float*)(msg + 9) = frame.direction.z;
  295. *(float*)(msg + 13) = frame.targetPosition.x;
  296. *(float*)(msg + 17) = frame.targetPosition.y;
  297. *(float*)(msg + 21) = frame.targetPosition.z;
  298. *(int*)(msg + 25) = frame.movementFlags;
  299. *(double*)(msg + 29) = frame.duration;
  300. message->setMessage(msg, 37);
  301. Game::INSTANCE->broadcastMessage(message);
  302. faceDir = frame.direction;
  303. // TODO implement subscription system to notify only interested clients
  304. }
  305. void Entity::calculateTarget(Framework::Vec3<float> basePos,
  306. Framework::Vec3<float> direction,
  307. const Item* zItem)
  308. {
  309. Vec3<float> headPosition = basePos + faceOffset;
  310. int px = (int)floor(headPosition.x);
  311. int py = (int)floor(headPosition.y);
  312. int pz = (int)floor(headPosition.z);
  313. direction.normalize();
  314. Direction dir = BOTTOM;
  315. while (true)
  316. {
  317. if (getDefaultBlock(Game::INSTANCE->zBlockAt(Vec3<int>{px, py, pz}, dimensionId))
  318. ->isInteractable(zItem))
  319. {
  320. if (!target || !target->isBlock({px, py, pz}, dir))
  321. {
  322. cs.lock();
  323. delete target;
  324. target = new ActionTarget({px, py, pz}, dir);
  325. cs.unlock();
  326. onTargetChange();
  327. }
  328. break;
  329. }
  330. // collision to neighbor of current block
  331. if (direction.x > 0)
  332. {
  333. float xt = ((float)px + 1.f - headPosition.x) / direction.x;
  334. Vec3<float> tmp = headPosition + direction * xt;
  335. if (xt <= targetDistanceLimit && tmp.y >= (float)py
  336. && tmp.y < (float)py + 1.f && tmp.z >= (float)pz
  337. && tmp.z < (float)pz + 1.f)
  338. {
  339. dir = WEST;
  340. px++;
  341. continue;
  342. }
  343. }
  344. if (direction.x < 0)
  345. {
  346. float xt = ((float)px - headPosition.x) / direction.x;
  347. Vec3<float> tmp = headPosition + direction * xt;
  348. if (xt <= targetDistanceLimit && tmp.y >= (float)py
  349. && tmp.y < (float)py + 1.f && tmp.z >= (float)pz
  350. && tmp.z < (float)pz + 1.f)
  351. {
  352. dir = EAST;
  353. px--;
  354. continue;
  355. }
  356. }
  357. if (direction.y > 0)
  358. {
  359. float yt = ((float)py + 1.f - headPosition.y) / direction.y;
  360. Vec3<float> tmp = headPosition + direction * yt;
  361. if (yt <= targetDistanceLimit && tmp.x >= (float)px
  362. && tmp.x < (float)px + 1.f && tmp.z >= (float)pz
  363. && tmp.z < (float)pz + 1.f)
  364. {
  365. dir = NORTH;
  366. py++;
  367. continue;
  368. }
  369. }
  370. if (direction.y < 0)
  371. {
  372. float yt = ((float)py - headPosition.y) / direction.y;
  373. Vec3<float> tmp = headPosition + direction * yt;
  374. if (yt <= targetDistanceLimit && tmp.x >= (float)px
  375. && tmp.x < (float)px + 1.f && tmp.z >= (float)pz
  376. && tmp.z < (float)pz + 1.f)
  377. {
  378. dir = SOUTH;
  379. py--;
  380. continue;
  381. }
  382. }
  383. if (direction.z > 0)
  384. {
  385. float zt = ((float)pz + 1.f - headPosition.z) / direction.z;
  386. Vec3<float> tmp = headPosition + direction * zt;
  387. if (zt <= targetDistanceLimit && tmp.x >= (float)px
  388. && tmp.x < (float)px + 1.f && tmp.y >= (float)py
  389. && tmp.y < (float)py + 1.f)
  390. {
  391. dir = BOTTOM;
  392. pz++;
  393. continue;
  394. }
  395. }
  396. if (direction.z < 0)
  397. {
  398. float zt = ((float)pz - headPosition.z) / direction.z;
  399. Vec3<float> tmp = headPosition + direction * zt;
  400. if (zt <= targetDistanceLimit && tmp.x >= (float)px
  401. && tmp.x < (float)px + 1.f && tmp.y >= (float)py
  402. && tmp.y < (float)py + 1)
  403. {
  404. dir = TOP;
  405. pz--;
  406. continue;
  407. }
  408. }
  409. if (target)
  410. {
  411. cs.lock();
  412. delete target;
  413. target = 0;
  414. cs.unlock();
  415. onTargetChange();
  416. }
  417. break;
  418. }
  419. }
  420. void Entity::removeStatusBarObserver(Entity* zSource, Framework::Text id)
  421. {
  422. cs.lock();
  423. int index = 0;
  424. for (auto observer : statusBarObservers)
  425. {
  426. if (observer.getFirst() == zSource->getId()
  427. && observer.getSecond().istGleich(id))
  428. {
  429. statusBarObservers.remove(index);
  430. break;
  431. }
  432. index++;
  433. }
  434. cs.unlock();
  435. }
  436. void Entity::addStatusBarObserver(Entity* zSource, Framework::Text id)
  437. {
  438. cs.lock();
  439. for (auto observer : statusBarObservers)
  440. {
  441. if (observer.getFirst() == zSource->getId()
  442. && observer.getSecond().istGleich(id))
  443. {
  444. cs.unlock();
  445. return;
  446. }
  447. }
  448. statusBarObservers.add(ImmutablePair<int, Text>(zSource->getId(), id));
  449. cs.unlock();
  450. }
  451. void Entity::notifyStatusBarObservers(NetworkMessage* msg)
  452. {
  453. cs.lock();
  454. int index = 0;
  455. Array<int> toDelete;
  456. for (auto observer : statusBarObservers)
  457. {
  458. Entity* e = Game::INSTANCE->zEntity(observer.getFirst());
  459. if (e)
  460. {
  461. msg->addressUIElement(observer.getSecond());
  462. Game::INSTANCE->sendMessage(msg->clone(), e);
  463. }
  464. else
  465. toDelete.add(index, 0);
  466. index++;
  467. }
  468. for (int i : toDelete)
  469. statusBarObservers.remove(i);
  470. cs.unlock();
  471. msg->release();
  472. }
  473. ItemSkill* Entity::zSkill(int itemType)
  474. {
  475. for (ItemSkill* skill : skills)
  476. {
  477. if (skill->getTypeId() == typeId)
  478. {
  479. return skill;
  480. }
  481. }
  482. return 0;
  483. }
  484. void Entity::prepareTick(const Dimension* zDimension) {}
  485. void Entity::tick(const Dimension* zDimension)
  486. {
  487. if (placeBlockCooldown > 0)
  488. {
  489. placeBlockCooldown--;
  490. }
  491. placeBlockCooldown--;
  492. if (time.isMeasuring())
  493. {
  494. time.messungEnde();
  495. if (movements.getEintragAnzahl() > 0)
  496. {
  497. MovementFrame currentFrame = movements.get(0);
  498. double seconds = time.getSekunden();
  499. while (seconds > 0)
  500. {
  501. if (currentFrame.duration <= 0)
  502. {
  503. cs.lock();
  504. movements.remove(0);
  505. cs.unlock();
  506. if (movements.getEintragAnzahl() > 0)
  507. currentFrame = movements.get(0);
  508. else
  509. break;
  510. }
  511. double t = MIN(currentFrame.duration, seconds);
  512. // TODO: add collision detection to reduce cheating capability
  513. location += (currentFrame.targetPosition - location)
  514. * (float)(t / currentFrame.duration);
  515. currentFrame.duration -= t;
  516. seconds -= t;
  517. if (currentFrame.duration <= 0)
  518. {
  519. location = currentFrame.targetPosition;
  520. }
  521. }
  522. if (currentFrame.duration > 0) movements.set(currentFrame, 0);
  523. if (getStamina() <= getMaxStamina() - 0.0025f)
  524. {
  525. if (getThirst() > 0 && getHunger() > 0)
  526. {
  527. setStamina(getStamina() + 0.0025f);
  528. setHunger(getHunger() - 0.0005f);
  529. setThirst(getThirst() - 0.0015f);
  530. }
  531. }
  532. }
  533. else
  534. {
  535. if (getStamina() <= getMaxStamina() - 0.005f)
  536. {
  537. if (getThirst() > 0 && getHunger() > 0)
  538. {
  539. setStamina(getStamina() + 0.005f);
  540. setHunger(getHunger() - 0.001f);
  541. setThirst(getThirst() - 0.003f);
  542. }
  543. }
  544. }
  545. }
  546. time.messungStart();
  547. }
  548. void Entity::api(Framework::StreamReader* zRequest,
  549. NetworkMessage* zResponse,
  550. Entity* zSource)
  551. {
  552. char type;
  553. zRequest->lese(&type, 1);
  554. switch (type)
  555. {
  556. case 0: // request status bar state
  557. {
  558. char len;
  559. zRequest->lese(&len, 1);
  560. char* guiId = new char[(int)len + 1];
  561. zRequest->lese(guiId, len);
  562. guiId[(int)len] = 0;
  563. zResponse->addressUIElement(guiId);
  564. addStatusBarObserver(zSource, guiId);
  565. char* msg = new char[33];
  566. msg[0] = 0;
  567. *(float*)(msg + 1) = getMaxHP();
  568. *(float*)(msg + 5) = getCurrentHP();
  569. *(float*)(msg + 9) = getMaxStamina();
  570. *(float*)(msg + 13) = getStamina();
  571. *(float*)(msg + 17) = getMaxHunger();
  572. *(float*)(msg + 21) = getHunger();
  573. *(float*)(msg + 25) = getMaxThirst();
  574. *(float*)(msg + 29) = getThirst();
  575. zResponse->setMessage(msg, 33);
  576. delete[] guiId;
  577. break;
  578. }
  579. case 1: // remove status bar observer
  580. {
  581. char len;
  582. zRequest->lese(&len, 1);
  583. char* guiId = new char[(int)len + 1];
  584. zRequest->lese(guiId, len);
  585. guiId[(int)len] = 0;
  586. removeStatusBarObserver(zSource, guiId);
  587. delete[] guiId;
  588. break;
  589. }
  590. }
  591. }
  592. void Entity::onFall(float collisionSpeed)
  593. {
  594. if (collisionSpeed > 5)
  595. {
  596. // TODO: take damage
  597. }
  598. }
  599. void Entity::setChatSecurityLevel(int level)
  600. {
  601. chatSecurityLevel = level;
  602. }
  603. void Entity::setPosition(Framework::Vec3<float> pos)
  604. {
  605. location = pos;
  606. }
  607. void Entity::setHP(float hp)
  608. {
  609. currentHP = MIN(MAX(hp, 0), maxHP);
  610. NetworkMessage* msg = new NetworkMessage();
  611. char* message = new char[9];
  612. message[0] = 1;
  613. *(float*)(message + 1) = getMaxHP();
  614. *(float*)(message + 5) = getCurrentHP();
  615. msg->setMessage(message, 9);
  616. notifyStatusBarObservers(msg);
  617. }
  618. void Entity::setStamina(float stamina)
  619. {
  620. this->stamina = MIN(MAX(stamina, 0), maxStamina);
  621. NetworkMessage* msg = new NetworkMessage();
  622. char* message = new char[9];
  623. message[0] = 2;
  624. *(float*)(message + 1) = getMaxStamina();
  625. *(float*)(message + 5) = getStamina();
  626. msg->setMessage(message, 9);
  627. notifyStatusBarObservers(msg);
  628. }
  629. void Entity::setHunger(float hunger)
  630. {
  631. this->hunger = MIN(MAX(hunger, 0), maxHunger);
  632. NetworkMessage* msg = new NetworkMessage();
  633. char* message = new char[9];
  634. message[0] = 3;
  635. *(float*)(message + 1) = getMaxHunger();
  636. *(float*)(message + 5) = getHunger();
  637. msg->setMessage(message, 9);
  638. notifyStatusBarObservers(msg);
  639. }
  640. void Entity::setThirst(float thirst)
  641. {
  642. this->thirst = MIN(MAX(thirst, 0), maxThirst);
  643. NetworkMessage* msg = new NetworkMessage();
  644. char* message = new char[9];
  645. message[0] = 4;
  646. *(float*)(message + 1) = getMaxThirst();
  647. *(float*)(message + 5) = getThirst();
  648. msg->setMessage(message, 9);
  649. notifyStatusBarObservers(msg);
  650. }
  651. float Entity::getMaxHP() const
  652. {
  653. return maxHP;
  654. }
  655. float Entity::getCurrentHP() const
  656. {
  657. return currentHP;
  658. }
  659. float Entity::getStamina() const
  660. {
  661. return stamina;
  662. }
  663. float Entity::getMaxStamina() const
  664. {
  665. return maxStamina;
  666. }
  667. float Entity::getHunger() const
  668. {
  669. return hunger;
  670. }
  671. float Entity::getMaxHunger() const
  672. {
  673. return maxHunger;
  674. }
  675. float Entity::getThirst() const
  676. {
  677. return thirst;
  678. }
  679. float Entity::getMaxThirst() const
  680. {
  681. return maxThirst;
  682. }
  683. Framework::Vec3<float> Entity::getSpeed() const
  684. {
  685. return speed;
  686. }
  687. Framework::Vec3<float> Entity::getFaceDir() const
  688. {
  689. return faceDir;
  690. }
  691. Framework::Vec3<float> Entity::getPosition() const
  692. {
  693. return location;
  694. }
  695. float Entity::getGravityMultiplier() const
  696. {
  697. return gravityMultiplier;
  698. }
  699. bool Entity::isRemoved() const
  700. {
  701. return removed;
  702. }
  703. const EntityType* Entity::zType() const
  704. {
  705. return StaticRegistry<EntityType>::INSTANCE.zElement(typeId);
  706. }
  707. const ActionTarget* Entity::zTarget() const
  708. {
  709. return target;
  710. }
  711. int Entity::getId() const
  712. {
  713. return id;
  714. }
  715. bool Entity::hasDefaultModel() const
  716. {
  717. return 1;
  718. }
  719. ModelInfo Entity::getSpecialModel() const
  720. {
  721. return ModelInfo("", "", 0);
  722. }
  723. float Entity::getMaxSpeed() const
  724. {
  725. return maxMovementSpeed;
  726. }
  727. bool Entity::isMoving() const
  728. {
  729. return movements.getEintragAnzahl() > 0;
  730. }
  731. int Entity::getChatSecurityLevel() const
  732. {
  733. return chatSecurityLevel;
  734. }