Component.h 896 B

12345678910111213141516171819202122232425262728293031
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include <cstdint>
  10. class Component
  11. {
  12. public:
  13. // Constructor
  14. // (the lower the update order, the earlier the component updates)
  15. Component(class Actor* owner, int updateOrder = 100);
  16. // Destructor
  17. virtual ~Component();
  18. // Update this component by delta time
  19. virtual void Update(float deltaTime);
  20. // Process input for this component
  21. virtual void ProcessInput(const uint8_t* keyState) {}
  22. int GetUpdateOrder() const { return mUpdateOrder; }
  23. protected:
  24. // Owning actor
  25. class Actor* mOwner;
  26. // Update order of component
  27. int mUpdateOrder;
  28. };