载入中...
搜索中...
未找到
SceneComponent.h
浏览该文件的文档.
1#pragma once
2
3#include "scene/NodeDesc.h"
4#include "scene/SceneHost.h"
5
6#include <memory>
7#include <string>
8
9namespace eve::scene {
10namespace detail {
11struct ComponentSchedule;
17} // namespace detail
18
24public:
27 SceneComponent(const SceneComponent &) = delete;
32 virtual ~SceneComponent();
33
35 virtual NodeDesc build() = 0;
36
38 virtual void onMount(SceneHost *host) {}
39
41 void attach(SceneHost *host);
43 void mountAs(const std::string &hostName);
52 SceneHost *host() const;
53
57 void rebuild(bool forceFull = false);
58
62 void markDirty();
64 bool isDirty() const { return dirty_; }
65
69 bool updateIfDirty();
70
71protected:
73 void setState() { markDirty(); }
74
75private:
76 ecs::EntityHandle hostHandle_{};
77 bool dirty_ = true;
78 bool building_ = false;
79 std::shared_ptr<detail::ComponentSchedule> schedule_;
80};
81
82} // namespace eve::scene
#define EVENGINE_API_PLATFORM
Definition Export.h:107
int detail
UIHostHandle host
React-style scene component: implement build(); setState / markDirty schedules one update before tran...
SceneComponent(SceneComponent &&)=delete
SceneComponent & operator=(SceneComponent &&)=delete
SceneComponent(const SceneComponent &)=delete
virtual void onMount(SceneHost *host)
Called once when the component is attached to a host.
virtual NodeDesc build()=0
Builds .
void setState()
Subclasses call after mutating local state that affects build().
SceneComponent & operator=(const SceneComponent &)=delete
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
void flushPendingComponents()
Flush one batch of live dirty components before host traversal. @thread Owner thread; newly queued ed...
Declarative scene-node description (build once / on dirty → flatten into SceneHost::Tree)....
Definition NodeDesc.h:19