载入中...
搜索中...
未找到
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:
17 virtual ~SceneComponent() = default;
18
19 virtual NodeDesc build() = 0;
20
22 virtual void onMount(SceneHost *host) {}
23
24 void attach(SceneHost *host);
25 void mountAs(const std::string &hostName);
26 SceneHost *host() const { return host_; }
27
29 void rebuild(bool forceFull = false);
30
31 void markDirty() { dirty_ = true; }
32 bool isDirty() const { return dirty_; }
33
35 bool updateIfDirty();
36
37protected:
39 void setState() { dirty_ = true; }
40
41private:
42 SceneHost *host_ = nullptr;
43 bool dirty_ = true;
44};
45
46} // namespace eve::scene
React-style scene component: implement build(), call setState / markDirty, then rebuild()....
virtual ~SceneComponent()=default
SceneHost * host() const
void mountAs(const std::string &hostName)
void attach(SceneHost *host)
virtual void onMount(SceneHost *host)
Called once when the component is attached to a host.
bool updateIfDirty()
If dirty, rebuild and clear flag. Returns true if rebuilt.
virtual NodeDesc build()=0
void setState()
Subclasses call after mutating local state that affects build().
void rebuild(bool forceFull=false)
Rebuild tree onto host (reconcile by key when possible).
ECS mount point for one scene graph (full scene or nested subtree root). Isomorphic to eve::ui::UIHos...
Definition SceneHost.h:80
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:15