ShitEngine 1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
System.h
浏览该文件的文档.
1#pragma once
4
5
6namespace Shit {
7 class Scene;
8 class Component;
19 class SHIT_API SHIT_REFLECT(WhiteList) System {
21 public:
22 System(int priority = 0);
23 virtual ~System();
24
25 virtual void init();
26 virtual void update() = 0;
27
31 virtual void fixedUpdate(float /*fixedDt*/) { }
32 virtual void destroy() = 0;
33
35 virtual void onFieldChanged(const std::string& fieldName) { (void)fieldName; }
36
37 // --- 组件生命周期回调(解耦:组件不再查具体系统类型,由 Scene 广播给所有系统) ---
39 virtual bool onComponentAttached(Component* component) { (void)component; return false; }
41 virtual void onComponentDetached(Component* component) { (void)component; }
42
43 // --- getter & setter ---
44 Scene* getScene() const { return m_scene; }
45 void setScene(Scene* scene) { m_scene = scene; }
46
47 int getPriority() const { return m_priority; }
48 void setPriority(int priority) { m_priority = priority; }
49
50 protected:
51 SHIT_META(Disable)
53 SHIT_META(Disable)
54 Scene* m_scene = nullptr;
55
60 };
61}
#define SHIT_API
定义 Core.h:14
反射标记宏(annotate 方案)——引擎反射系统的源码侧入口
#define SHIT_REFLECT_BODY(Type)
定义 Macros.h:89
#define SHIT_REFLECT(Mode)
定义 Macros.h:86
#define SHIT_META(...)
定义 Macros.h:95
组件基类
定义 Component.h:25
场景类
定义 Scene.h:36
virtual void onComponentDetached(Component *component)
组件卸下时调用。
定义 System.h:41
Scene * getScene() const
定义 System.h:44
void setPriority(int priority)
定义 System.h:48
void setScene(Scene *scene)
定义 System.h:45
virtual void onFieldChanged(const std::string &fieldName)
反射字段被编辑器直写后回调(供子系统把字段变更实时同步到运行时状态)
定义 System.h:35
System(int priority=0)
virtual bool onComponentAttached(Component *component)
组件挂载时调用。返回 true 表示本系统认领并处理了该组件(组件据此确定已注册)。
定义 System.h:39
Scene * m_scene
所属场景
定义 System.h:54
virtual void init()
初始化(可覆写)
virtual void update()=0
每帧更新(纯虚)
virtual ~System()
void resetComponent(Component *comp)
内部:把认领过的组件标记为未注册(系统销毁/注销时调用)。 否则组件 m_isRegistered 残留 true,同类系统重新注册时 System::init 补扫会跳过它们, 导致组件永久失去驱动系...
int getPriority() const
定义 System.h:47
int m_priority
优先级(小值先执行)
定义 System.h:52
virtual void fixedUpdate(float)
固定步长驱动(默认空实现,按需覆写):由 Scene 在固定步循环内按优先级顺序调用, 一个渲染帧可能执行 0~N 次(默认 60Hz,见 Scene::FIXED_TIME_STEP)。 与物理同拍/...
定义 System.h:31
virtual void destroy()=0
销毁(纯虚)
定义 AnimationClip.h:12