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
24namespace kiwano
25{
26class RenderContext;
27class Event;
28class Module;
29
32typedef Vector<Module*> ModuleList;
33
36class KGE_API ModuleContext
37{
38public:
39 void Next();
40
41protected:
42 ModuleContext(ModuleList& modules);
43
44 virtual ~ModuleContext();
45
46 virtual void Handle(Module* m) = 0;
47
48 void ResetIndex();
49
50private:
51 int index_;
52 ModuleList& modules_;
53};
54
57class KGE_API RenderModuleContext : public ModuleContext
58{
59public:
60 RenderContext& render_ctx;
61
62 RenderModuleContext(ModuleList& modules, RenderContext& ctx);
63
64 virtual ~RenderModuleContext();
65
66protected:
67 void Handle(Module* m) override;
68
69private:
70 enum class Step
71 {
72 Before,
73 Rendering,
74 After,
75 };
76
77 Step step_;
78};
79
82class KGE_API UpdateModuleContext : public ModuleContext
83{
84public:
85 Duration dt;
86
87 UpdateModuleContext(ModuleList& modules, Duration dt);
88
89protected:
90 void Handle(Module* m) override;
91};
92
95class KGE_API EventModuleContext : public ModuleContext
96{
97public:
98 Event* evt;
99
100 EventModuleContext(ModuleList& modules, Event* evt);
101
102protected:
103 void Handle(Module* m) override;
104};
105
110class KGE_API Module : Noncopyable
111{
112public:
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
146protected:
147 Module();
148};
149
150} // namespace kiwano
时间模块上下文
Definition: Module.h:96
事件
Definition: Event.h:43
模块上下文
Definition: Module.h:37
基础模块
Definition: Module.h:111
不可拷贝对象
Definition: Common.h:115
渲染上下文
Definition: RenderContext.h:62
渲染模块上下文
Definition: Module.h:58
更新模块上下文
Definition: Module.h:83
时间段
Definition: Duration.h:48