Component.h 979 B

123456789101112131415161718192021222324252627282930313233
  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. // Called when world transform changes
  23. virtual void OnUpdateWorldTransform() { }
  24. int GetUpdateOrder() const { return mUpdateOrder; }
  25. protected:
  26. // Owning actor
  27. class Actor* mOwner;
  28. // Update order of component
  29. int mUpdateOrder;
  30. };