Kiwano Engine
v1.3.x
Module.h
1
// Copyright (c) 2016-2018 Kiwano - Nomango
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to deal
5
// in the Software without restriction, including without limitation the rights
6
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
// copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in
11
// all copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
// THE SOFTWARE.
20
21
#pragma once
22
#include <kiwano/core/Time.h>
23
24
namespace
kiwano
25
{
26
class
RenderContext;
27
class
Event;
28
class
Module;
29
32
typedef
Vector<Module*> ModuleList;
33
36
class
KGE_API
ModuleContext
37
{
38
public
:
39
void
Next();
40
41
protected
:
42
ModuleContext
(ModuleList& modules);
43
44
virtual
~ModuleContext
();
45
46
virtual
void
Handle(
Module
* m) = 0;
47
48
void
ResetIndex();
49
50
private
:
51
int
index_;
52
ModuleList& modules_;
53
};
54
57
class
KGE_API
RenderModuleContext
:
public
ModuleContext
58
{
59
public
:
60
RenderContext
& render_ctx;
61
62
RenderModuleContext
(ModuleList& modules,
RenderContext
& ctx);
63
64
virtual
~RenderModuleContext
();
65
66
protected
:
67
void
Handle(
Module
* m)
override
;
68
69
private
:
70
enum class
Step
71
{
72
Before,
73
Rendering,
74
After,
75
};
76
77
Step step_;
78
};
79
82
class
KGE_API
UpdateModuleContext
:
public
ModuleContext
83
{
84
public
:
85
Duration
dt;
86
87
UpdateModuleContext
(ModuleList& modules,
Duration
dt);
88
89
protected
:
90
void
Handle(
Module
* m)
override
;
91
};
92
95
class
KGE_API
EventModuleContext
:
public
ModuleContext
96
{
97
public
:
98
Event
* evt;
99
100
EventModuleContext
(ModuleList& modules,
Event
* evt);
101
102
protected
:
103
void
Handle(
Module
* m)
override
;
104
};
105
110
class
KGE_API
Module
:
Noncopyable
111
{
112
public
:
115
virtual
void
SetupModule();
116
119
virtual
void
DestroyModule();
120
124
virtual
void
OnUpdate(
UpdateModuleContext
& ctx);
125
129
virtual
void
HandleEvent(
EventModuleContext
& ctx);
130
134
virtual
void
BeforeRender(
RenderModuleContext
& ctx);
135
139
virtual
void
OnRender(
RenderModuleContext
& ctx);
140
144
virtual
void
AfterRender(
RenderModuleContext
& ctx);
145
146
protected
:
147
Module
();
148
};
149
150
}
// namespace kiwano
kiwano::EventModuleContext
时间模块上下文
Definition:
Module.h:96
kiwano::Event
事件
Definition:
Event.h:43
kiwano::ModuleContext
模块上下文
Definition:
Module.h:37
kiwano::Module
基础模块
Definition:
Module.h:111
kiwano::Noncopyable
不可拷贝对象
Definition:
Common.h:115
kiwano::RenderContext
渲染上下文
Definition:
RenderContext.h:62
kiwano::RenderModuleContext
渲染模块上下文
Definition:
Module.h:58
kiwano::UpdateModuleContext
更新模块上下文
Definition:
Module.h:83
kiwano::Duration
时间段
Definition:
Duration.h:48
src
kiwano
base
Module.h
制作者
1.9.4