ShitEngine
1.4.2
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
System.h
浏览该文件的文档.
1
#pragma once
2
#include "
ShitEngine/Core/Core.h
"
3
#include "
ShitEngine/Reflection/Macros.h
"
4
5
6
namespace
Shit
{
7
class
Scene
;
8
class
Component
;
19
class
SHIT_API
SHIT_REFLECT
(WhiteList)
System
{
20
SHIT_REFLECT_BODY
(
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)
52
int
m_priority
;
53
SHIT_META
(Disable)
54
Scene
*
m_scene
=
nullptr
;
55
59
void
resetComponent
(
Component
* comp);
60
};
61
}
Core.h
SHIT_API
#define SHIT_API
定义
Core.h:14
Macros.h
反射标记宏(annotate 方案)——引擎反射系统的源码侧入口
SHIT_REFLECT_BODY
#define SHIT_REFLECT_BODY(Type)
定义
Macros.h:89
SHIT_REFLECT
#define SHIT_REFLECT(Mode)
定义
Macros.h:86
SHIT_META
#define SHIT_META(...)
定义
Macros.h:95
Shit::Component
组件基类
定义
Component.h:25
Shit::Scene
场景类
定义
Scene.h:36
Shit::System::onComponentDetached
virtual void onComponentDetached(Component *component)
组件卸下时调用。
定义
System.h:41
Shit::System::getScene
Scene * getScene() const
定义
System.h:44
Shit::System::setPriority
void setPriority(int priority)
定义
System.h:48
Shit::System::setScene
void setScene(Scene *scene)
定义
System.h:45
Shit::System::onFieldChanged
virtual void onFieldChanged(const std::string &fieldName)
反射字段被编辑器直写后回调(供子系统把字段变更实时同步到运行时状态)
定义
System.h:35
Shit::System::System
System(int priority=0)
Shit::System::onComponentAttached
virtual bool onComponentAttached(Component *component)
组件挂载时调用。返回 true 表示本系统认领并处理了该组件(组件据此确定已注册)。
定义
System.h:39
Shit::System::m_scene
Scene * m_scene
所属场景
定义
System.h:54
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:47
Shit::System::m_priority
int m_priority
优先级(小值先执行)
定义
System.h:52
Shit::System::fixedUpdate
virtual void fixedUpdate(float)
固定步长驱动(默认空实现,按需覆写):由 Scene 在固定步循环内按优先级顺序调用, 一个渲染帧可能执行 0~N 次(默认 60Hz,见 Scene::FIXED_TIME_STEP)。 与物理同拍/...
定义
System.h:31
Shit::System::destroy
virtual void destroy()=0
销毁(纯虚)
Shit
定义
AnimationClip.h:12
include
ShitEngine
System
System.h
制作者
1.17.0