ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
Prefab.h
浏览该文件的文档.
1#pragma once
2#include "GameObject.h"
3#include <functional>
4
5namespace Shit {
6
7class Scene;
8
21class Prefab {
22public:
23 using Builder = std::function<void(GameObject*)>;
24
25 static Prefab Build(Builder builder) {
26 Prefab p;
27 p.m_builder = std::move(builder);
28 return p;
29 }
30
31 void apply(GameObject* go) const {
32 if (m_builder) m_builder(go);
33 }
34
35private:
36 Prefab() = default;
37 Builder m_builder;
38};
39
40} // namespace Shit
游戏物体类
定义 GameObject.h:22
预制体,可重复生成相同配置的 GameObject
定义 Prefab.h:21
static Prefab Build(Builder builder)
定义 Prefab.h:25
std::function< void(GameObject *)> Builder
定义 Prefab.h:23
void apply(GameObject *go) const
定义 Prefab.h:31
场景类
定义 Scene.h:34
定义 AudioPlayer.h:9