载入中...
搜索中...
未找到
SceneComponent.h
浏览该文件的文档.
1#pragma once
2
3#include "scene/NodeDesc.h"
4#include "scene/SceneHost.h"
5
6#include <string>
7
8namespace eve::scene {
9
16public:
18 virtual ~SceneComponent() = default;
19
21 virtual NodeDesc build() = 0;
22
24 virtual void onMount(SceneHost *host) {}
25
27 void attach(SceneHost *host);
29 void mountAs(const std::string &hostName);
38 SceneHost *host() const { return host_; }
39
41 void rebuild(bool forceFull = false);
42
44 void markDirty() { dirty_ = true; }
46 bool isDirty() const { return dirty_; }
47
49 bool updateIfDirty();
50
51protected:
53 void setState() { dirty_ = true; }
54
55private:
56 SceneHost *host_ = nullptr;
57 bool dirty_ = true;
58};
59
60} // namespace eve::scene
#define EVENGINE_API_PLATFORM
Definition Export.h:107
UIHostHandle host
React-style scene component: implement build(), call setState / markDirty, then rebuild()....
virtual ~SceneComponent()=default
Scene component.
SceneHost * host() const
Returns the currently attached host, or null before attach.
virtual void onMount(SceneHost *host)
Called once when the component is attached to a host.
virtual NodeDesc build()=0
Builds .
void markDirty()
Mark dirty.
void setState()
Subclasses call after mutating local state that affects build().
bool isDirty() const
True when dirty.
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
Definition SceneHost.h:89
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19