CSComponent.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // Copyright (c) 2008-2014 the Urho3D project.
  3. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include <Atomic/Script/ScriptComponent.h>
  25. #include "CSComponentAssembly.h"
  26. namespace Atomic
  27. {
  28. class ATOMIC_API CSComponent : public ScriptComponent
  29. {
  30. friend class CSComponentFactory;
  31. OBJECT(CSComponent)
  32. BASEOBJECT(ScriptComponent)
  33. public:
  34. /// Construct.
  35. CSComponent(Context* context);
  36. /// Destruct.
  37. virtual ~CSComponent();
  38. /// Register object factory.
  39. static void RegisterObject(Context* context);
  40. bool Load(Deserializer& source, bool setInstanceDefault);
  41. bool LoadXML(const XMLElement& source, bool setInstanceDefault);
  42. void ApplyAttributes();
  43. /// Handle enabled/disabled state change. Changes update event subscription.
  44. virtual void OnSetEnabled();
  45. void ApplyFieldValues();
  46. VariantMap& GetFieldValues() { return fieldValues_; }
  47. void SetComponentClassName(const String& name);
  48. const String& GetComponentClassName() const { return componentClassName_; }
  49. virtual ScriptComponentFile* GetComponentFile() { return assemblyFile_; }
  50. CSComponentAssembly* GetAssemblyFile() { return assemblyFile_; }
  51. void SetAssemblyFile(CSComponentAssembly* assemblyFile);
  52. ResourceRef GetAssemblyFileAttr() const;
  53. void SetAssemblyFileAttr(const ResourceRef& value);
  54. protected:
  55. /// Handle scene node being assigned at creation.
  56. virtual void OnNodeSet(Node* node);
  57. /// Handle scene being assigned.
  58. virtual void OnSceneSet(Scene* scene);
  59. private:
  60. void SendLoadEvent();
  61. String componentClassName_;
  62. SharedPtr<CSComponentAssembly> assemblyFile_;
  63. };
  64. }