ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
Toggle main menu visibility
载入中...
搜索中...
未找到
EngineContext.h
浏览该文件的文档.
1
#pragma once
2
3
// 各子系统完整定义:EngineContext 按值持有全部实例
4
#include "
ShitEngine/Core/Game.h
"
5
#include "
ShitEngine/Core/Config.h
"
6
#include "
ShitEngine/Core/Window.h
"
7
#include "
ShitEngine/Core/Time.h
"
8
#include "
ShitEngine/Core/TextInputGate.h
"
9
#include "
ShitEngine/Input/Input.h
"
10
#include "
ShitEngine/Render/Renderer.h
"
11
#include "
ShitEngine/Resource/ResourceManager.h
"
12
#include "
ShitEngine/Audio/AudioPlayer.h
"
13
#include "
ShitEngine/Event/EventBus.h
"
14
#include "
ShitEngine/Scene/SceneManager.h
"
15
#include "
ShitEngine/Reflection/TypeRegistry.h
"
16
17
namespace
Shit
{
18
class
Log
;
// 日志为进程级全局(纯静态),不入上下文
19
40
class
SHIT_API
EngineContext
{
41
public
:
42
EngineContext
() =
default
;
43
~EngineContext
() =
default
;
44
45
EngineContext
(
const
EngineContext
&) =
delete
;
46
EngineContext
&
operator=
(
const
EngineContext
&) =
delete
;
47
EngineContext
(
EngineContext
&&) =
delete
;
48
EngineContext
&
operator=
(
EngineContext
&&) =
delete
;
49
50
// 子系统实例(声明顺序 = 构造顺序,析构逆序;生命周期由 Game::Init/Run/Destroy 驱动)
51
Game
game
;
52
Config
config
;
53
Window
window
;
54
Time
time
;
55
TextInputGate
textInputGate
;
56
Input
input
;
57
Renderer
renderer
;
58
ResourceManager
resources
;
59
AudioPlayer
audio
;
60
EventBus
eventBus
;
61
SceneManager
sceneManager
;
62
TypeRegistry
typeRegistry
;
63
64
// --- 当前上下文 ---
66
static
EngineContext
&
current
();
68
static
void
setCurrent
(
EngineContext
* ctx);
70
static
void
resetCurrent
();
71
72
private
:
73
static
EngineContext
* s_current;
74
};
75
}
AudioPlayer.h
Config.h
SHIT_API
#define SHIT_API
定义
Core.h:14
EventBus.h
Game.h
Input.h
Renderer.h
ResourceManager.h
SceneManager.h
TextInputGate.h
Time.h
TypeRegistry.h
Window.h
Shit::AudioPlayer
定义
AudioPlayer.h:35
Shit::Config
配置管理类
定义
Config.h:77
Shit::EngineContext::resetCurrent
static void resetCurrent()
恢复进程默认上下文
Shit::EngineContext::EngineContext
EngineContext(EngineContext &&)=delete
Shit::EngineContext::config
Config config
定义
EngineContext.h:52
Shit::EngineContext::EngineContext
EngineContext()=default
Shit::EngineContext::audio
AudioPlayer audio
定义
EngineContext.h:59
Shit::EngineContext::eventBus
EventBus eventBus
定义
EngineContext.h:60
Shit::EngineContext::setCurrent
static void setCurrent(EngineContext *ctx)
切换到指定上下文(多实例/编辑器预览用)
Shit::EngineContext::typeRegistry
TypeRegistry typeRegistry
定义
EngineContext.h:62
Shit::EngineContext::renderer
Renderer renderer
定义
EngineContext.h:57
Shit::EngineContext::operator=
EngineContext & operator=(const EngineContext &)=delete
Shit::EngineContext::sceneManager
SceneManager sceneManager
定义
EngineContext.h:61
Shit::EngineContext::operator=
EngineContext & operator=(EngineContext &&)=delete
Shit::EngineContext::window
Window window
定义
EngineContext.h:53
Shit::EngineContext::game
Game game
定义
EngineContext.h:51
Shit::EngineContext::EngineContext
EngineContext(const EngineContext &)=delete
Shit::EngineContext::input
Input input
定义
EngineContext.h:56
Shit::EngineContext::time
Time time
定义
EngineContext.h:54
Shit::EngineContext::resources
ResourceManager resources
定义
EngineContext.h:58
Shit::EngineContext::current
static EngineContext & current()
当前活动上下文;未设置时懒创建一个进程默认上下文(与旧单例行为一致)
Shit::EngineContext::textInputGate
TextInputGate textInputGate
定义
EngineContext.h:55
Shit::EngineContext::~EngineContext
~EngineContext()=default
Shit::EventBus
事件总线,缓冲队列模式
定义
EventBus.h:30
Shit::Game
引擎主控类
定义
Game.h:16
Shit::Input
输入管理(单例)
定义
Input.h:39
Shit::Log
日志封装类
定义
Log.h:16
Shit::Renderer
渲染器,封装 SDL3 绘制 API
定义
Renderer.h:21
Shit::ResourceManager
资源管理器(单例)
定义
ResourceManager.h:23
Shit::SceneManager
场景管理器(单例)
定义
SceneManager.h:19
Shit::TextInputGate
文本输入聚焦门(进程级单例)
定义
TextInputGate.h:24
Shit::Time
时间管理类
定义
Time.h:13
Shit::TypeRegistry
定义
TypeRegistry.h:24
Shit::Window
窗口管理类
定义
Window.h:14
Shit
定义
AudioPlayer.h:10
include
ShitEngine
Core
EngineContext.h
制作者
1.17.0