ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
System.h
浏览该文件的文档.
1
#pragma once
2
#include "
ShitEngine/Core/Core.h
"
3
4
5
namespace
Shit
{
6
class
Scene
;
7
class
Component
;
15
class
SHIT_API
System
{
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
:
38
int
m_priority
;
39
Scene
*
m_scene
=
nullptr
;
40
44
void
resetComponent
(
Component
* comp);
45
};
46
}
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:14
Shit::Component
组件基类
定义
Component.h:20
Shit::Scene
场景类
定义
Scene.h:34
Shit::System::onComponentDetached
virtual void onComponentDetached(Component *component)
组件卸下时调用。
定义
System.h:28
Shit::System::getScene
Scene * getScene() const
定义
System.h:31
Shit::System::setPriority
void setPriority(int priority)
定义
System.h:35
Shit::System::setScene
void setScene(Scene *scene)
定义
System.h:32
Shit::System::System
System(int priority=0)
Shit::System::onComponentAttached
virtual bool onComponentAttached(Component *component)
组件挂载时调用。返回 true 表示本系统认领并处理了该组件(组件据此确定已注册)。
定义
System.h:26
Shit::System::m_scene
Scene * m_scene
所属场景
定义
System.h:39
Shit::System::init
virtual void init()
初始化(可覆写)
Shit::System::update
virtual void update()=0
每帧更新(纯虚)
Shit::System::~System
virtual ~System()
Shit::System::resetComponent
void resetComponent(Component *comp)
内部:把认领过的组件标记为未注册(系统销毁/注销时调用)。 否则组件 m_isRegistered 残留 true,同类系统重新注册时 System::init 补扫会跳过它们, 导致组件永久失去驱动系...
Shit::System::getPriority
int getPriority() const
定义
System.h:34
Shit::System::m_priority
int m_priority
优先级(小值先执行)
定义
System.h:38
Shit::System::destroy
virtual void destroy()=0
销毁(纯虚)
Shit
定义
AudioPlayer.h:10
include
ShitEngine
System
System.h
制作者
1.17.0