AIComponent.h 829 B

1234567891011121314151617181920212223242526272829
  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 "Component.h"
  10. #include <unordered_map>
  11. #include <string>
  12. class AIComponent : public Component
  13. {
  14. public:
  15. AIComponent(class Actor* owner);
  16. void Update(float deltaTime) override;
  17. void ChangeState(const std::string& name);
  18. // Add a new state to the map
  19. void RegisterState(class AIState* state);
  20. private:
  21. // Maps name of state to AIState instance
  22. std::unordered_map<std::string, class AIState*> mStateMap;
  23. // Current state we're in
  24. class AIState* mCurrentState;
  25. };