ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
System.h
浏览该文件的文档.
1#pragma once
3
4
5namespace Shit {
6 class Scene;
7 class Component;
16 public:
17 System(int priority = 0);
18 virtual ~System();
19
20 virtual void init();
21 virtual void update() = 0;
22 virtual void destroy() = 0;
23
24 // --- 组件生命周期回调(解耦:组件不再查具体系统类型,由 Scene 广播给所有系统) ---
26 virtual bool onComponentAttached(Component* component) { (void)component; return false; }
28 virtual void onComponentDetached(Component* component) { (void)component; }
29
30 // --- getter & setter ---
31 Scene* getScene() const { return m_scene; }
32 void setScene(Scene* scene) { m_scene = scene; }
33
34 int getPriority() const { return m_priority; }
35 void setPriority(int priority) { m_priority = priority; }
36
37 protected:
39 Scene* m_scene = nullptr;
40
45 };
46}
#define SHIT_API
定义 Core.h:14
组件基类
定义 Component.h:20
场景类
定义 Scene.h:34
virtual void onComponentDetached(Component *component)
组件卸下时调用。
定义 System.h:28
Scene * getScene() const
定义 System.h:31
void setPriority(int priority)
定义 System.h:35
void setScene(Scene *scene)
定义 System.h:32
System(int priority=0)
virtual bool onComponentAttached(Component *component)
组件挂载时调用。返回 true 表示本系统认领并处理了该组件(组件据此确定已注册)。
定义 System.h:26
Scene * m_scene
所属场景
定义 System.h:39
virtual void init()
初始化(可覆写)
virtual void update()=0
每帧更新(纯虚)
virtual ~System()
void resetComponent(Component *comp)
内部:把认领过的组件标记为未注册(系统销毁/注销时调用)。 否则组件 m_isRegistered 残留 true,同类系统重新注册时 System::init 补扫会跳过它们, 导致组件永久失去驱动系...
int getPriority() const
定义 System.h:34
int m_priority
优先级(小值先执行)
定义 System.h:38
virtual void destroy()=0
销毁(纯虚)
定义 AudioPlayer.h:10