// Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include #include #include namespace anki { // Component of scripts. It can point to a resource with the script code or have the script code embedded to it. class ScriptComponent : public SceneComponent { ANKI_SCENE_COMPONENT(ScriptComponent) public: ScriptComponent(SceneNode* node); ~ScriptComponent(); void setScriptResourceFilename(CString fname); CString getScriptResourceFilename() const; void setScriptText(CString text); CString getScriptText() const; Bool hasScriptText() const { return !m_text.isEmpty(); } Bool hasScriptResource() const { return m_resource.isCreated(); } Bool isEnabled() const { return m_environments[0] || m_environments[1]; } private: ScriptResourcePtr m_resource; SceneString m_text; Array m_environments = {}; void update(SceneComponentUpdateInfo& info, Bool& updated) override; Error serialize(SceneSerializer& serializer) override; }; } // end namespace anki