Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. #include "PrimeEngine/APIAbstraction/APIAbstractionDefines.h"
  2. #include "PrimeEngine/Lua/LuaEnvironment.h"
  3. #include "PrimeEngine/Scene/MeshInstance.h"
  4. #include "PrimeEngine/Scene/RootSceneNode.h"
  5.  
  6. #include "Projectile.h"
  7. #include "SoldierNPC.h"
  8. #include "CharacterControl/ClientGameObjectManagerAddon.h"
  9. #include "PrimeEngine/Events/StandardEvents.h"
  10.  
  11. using namespace PE;
  12. using namespace PE::Components;
  13. using namespace CharacterControl::Events;
  14.  
  15. namespace CharacterControl
  16. {
  17. namespace Components
  18. {
  19. std::vector<Projectile *> Projectile::projectiles;
  20. PE_IMPLEMENT_CLASS1(Projectile, Component);
  21. Projectile::Projectile(PE::GameContext &context, PE::MemoryArena arena, PE::Handle hMyself)
  22. : Component(context, arena, hMyself)
  23. {
  24. projectiles.push_back(this);
  25. showTimer = 0.1f;
  26. }
  27.  
  28. void Projectile::addDefaultComponents()
  29. {
  30. Component::addDefaultComponents();
  31. PE_REGISTER_EVENT_HANDLER(PE::Events::Event_UPDATE, Projectile::do_UPDATE);
  32. }
  33.  
  34.  
  35. void Projectile::do_UPDATE(PE::Events::Event *pEvt)
  36. {
  37. if (isAlive)
  38. {
  39. PE::Events::Event_UPDATE *realEvt = (PE::Events::Event_UPDATE *)pEvt;
  40. //if (!meshInstance->m_display)
  41. //{
  42. // showTimer -= realEvt->m_frameTime;
  43.  
  44. // if (showTimer <= 0.0f)
  45. // {
  46. // meshInstance->m_display = true;
  47. // }
  48. //}
  49. meshInstance->m_display = true;
  50.  
  51. startPosition = sceneNode->m_base.getPos();
  52.  
  53. float dotTargetStart = (targetPosition - startPosition).dotProduct(targetPosition - sceneNode->m_base.getPos());
  54. //if (dotTargetStart < 0.0f)
  55. //{
  56. // disable();
  57. // return;
  58. //}
  59. //else
  60. //{
  61. Vector3 forwardVector = (targetPosition - startPosition);
  62. forwardVector.normalize();
  63. float velocity = 12.0f;
  64. sceneNode->m_base.setPos(sceneNode->m_base.getPos() + velocity * forwardVector * realEvt->m_frameTime);
  65. //m_base = sceneNode->m_base;
  66. //meshInstance->lifeProgress = 1 - (targetPosition - sceneNode->m_base.getPos()).length() / (targetPosition - startPosition).length();
  67. //}
  68.  
  69. // for (Component *currentEntity : ClientGameObjectManagerAddon::attackableEntities)
  70. // {
  71. // Component *target;
  72. // SceneNode *currentSN = NULL;
  73. // PE::Handle *pHC = currentEntity->m_components.getFirstPtr();
  74.  
  75. // for (PrimitiveTypes::UInt32 i = 0; i < currentEntity->m_components.m_size; i++, pHC++)
  76. // {
  77. // Component *pC = (*pHC).getObject<Component>();
  78. // if (pC->isInstanceOf<SceneNode>())
  79. // {
  80. // currentSN = (SceneNode *)(pC);
  81. // target = currentEntity;
  82. // break;
  83. // }
  84. // }
  85.  
  86. // Vector3 targetPos = currentSN->m_base.getPos();
  87. // Vector3 bulletPos = sceneNode->m_base.getPos();
  88. // float length = (bulletPos - targetPos).length();
  89. // if (length <= 1.5f)
  90. // {
  91. // SoldierNPC *targetNPC = (SoldierNPC *)target;
  92. // if (targetNPC->teamID == this->teamID)
  93. // {
  94. // continue;
  95. // }
  96. // targetNPC->health -= 1;
  97. // disable();
  98.  
  99. // if (targetNPC->health <= 0.0f)
  100. // {
  101. // targetNPC->meshInstance->dead = true;
  102. // ClientGameObjectManagerAddon::losingTeam = targetNPC->teamID;
  103. // ClientGameObjectManagerAddon::gameOver = true;
  104. // }
  105. // }
  106. //}
  107.  
  108. //using namespace Navigator;
  109. //initNodes();
  110. //// TODO(Rohan): this should proably use define from other file
  111. //extern Poly staticPolys[TOTAL_POLYS];
  112. //for (Poly poly : staticPolys)
  113. //{
  114. // Vector3 projectilePos = sceneNode->m_base.getPos();
  115. // projectilePos.m_y = 0;
  116. // if (isInsidePoly(poly, projectilePos))
  117. // {
  118. // disable();
  119. // }
  120. //}
  121. }
  122. }
  123. }
  124. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement