kick
|
00001 // 00002 // component.h 00003 // KickCPP 00004 // 00005 // Created by morten on 8/12/13. 00006 // Copyright (c) 2013 Morten Nobel-Joergensen. All rights reserved. 00007 // 00008 00009 #pragma once 00010 00011 #include <iostream> 00012 #include <vector> 00013 #include "kick/scene/engine_uniforms.h" 00014 #include "kick/core/event.h" 00015 00016 namespace kick { 00017 00018 class GameObject; 00019 class Transform; 00020 00021 enum class ComponentUpdateStatus { 00022 Created, 00023 Destroyed, 00024 Updated 00025 }; 00026 00027 class Component : public std::enable_shared_from_this<Component> { 00028 public: 00029 Component(GameObject* gameObject); 00030 Component(Component&& component); 00031 Component& operator=(const Component& other); 00032 virtual ~Component(); 00033 // deprecated 00034 virtual void activated() final {} 00035 virtual void deactivated(){} 00036 std::shared_ptr<Transform> transform(); 00037 GameObject* gameObject(); 00038 00039 bool enabled() const; 00040 void setEnabled(bool enabled); 00041 protected: 00042 GameObject*mGameObject; 00043 private: 00044 Component(const Component& component) = delete; 00045 bool mEnabled = true; 00046 }; 00047 00048 typedef std::vector<std::shared_ptr<Component>>::const_iterator ConstComponentIter; 00049 typedef std::vector<std::shared_ptr<Component>>::iterator ComponentIter; 00050 }