ScummVM API documentation
scene.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TWINE_SCENE_SCENE_H
23 #define TWINE_SCENE_SCENE_H
24 
25 #include "common/scummsys.h"
26 #include "common/util.h"
27 #include "twine/scene/actor.h"
28 #include "twine/shared.h"
29 
30 namespace TwinE {
31 
32 #define NUM_SCENES_FLAGS 80
33 
34 #define NUM_MAX_ACTORS 100
35 #define NUM_MAX_ZONES 100
36 #define NUM_MAX_TRACKS 200
37 
38 enum class ScenePositionType {
39  kNoPosition = 0,
40  kZone = 1,
41  kScene = 2,
42  kReborn = 3
43 };
44 
45 // ZONES
46 
47 #define ZONE_INIT_ON 1
48 #define ZONE_ON 2
49 #define ZONE_ACTIVE 4
50 #define ZONE_OBLIGATOIRE 8
51 
55 struct ZoneStruct {
56  IVec3 mins;
57  IVec3 maxs;
58  ZoneType type = ZoneType::kCube;
59  int32 num;
60  union {
61  struct {
62  int32 x;
63  int32 y;
64  int32 z;
65  } ChangeScene;
66  struct {
67  int32 x;
68  int32 y;
69  int32 z;
70  } CameraView;
72  struct {
73  int32 textColor;
74  } DisplayText;
75  struct {
76  BonusParameter typesFlag;
77  int32 amount;
81  int32 used;
82  } Bonus;
83  struct {
84  int32 info0;
85  int32 info1;
86  int32 info2;
87  int32 info3;
88  int32 info4;
89  int32 info5;
90  int32 info6;
91  int32 info7;
92  } generic;
93  } infoData;
94 };
95 
96 class TwinEEngine;
97 
116 class Scene {
117 private:
118  TwinEEngine *_engine;
119 
121  void processZoneExtraBonus(ZoneStruct *zone);
122  void setActorStaticFlags(ActorStruct *act, uint32 staticFlags);
123  void setBonusParameterFlags(ActorStruct *act, uint16 bonusFlags);
124  bool loadSceneLBA1();
125  bool loadSceneLBA2();
126 
128  bool initScene(int32 index);
130  void resetScene();
131 
132  // the first actor is the own hero
133  ActorStruct _sceneActors[NUM_MAX_ACTORS]; // ListObjet
134  int32 _currentSceneSize = 0;
135  bool _isOutsideScene = false; // lba2
136 
138  int32 _sampleAmbienceTime = 0;
139  int16 _sampleAmbiance[4]{0};
140  int16 _sampleRepeat[4]{0};
141  int16 _sampleRound[4]{0};
142  int16 _sampleFrequency[4]{0}; // lba2
143  int16 _sampleVolume[4]{0}; // lba2
144  int16 _sampleMinDelay = 0;
145  int16 _sampleMinDelayRnd = 0;
146 
147  int16 _samplePlayed = 0;
148 
149  int16 _sceneMusic = 0;
150 
151  IVec3 _sceneHeroPos;
152  IVec3 _zoneHeroPos;
153 
154  int32 _currentGameOverScene = 0;
155 
156  uint8 *_currentScene = nullptr;
157  void dumpSceneScripts() const;
158  void dumpSceneScript(const char *type, int actorIdx, const uint8* script, int size) const;
159 public:
160  Scene(TwinEEngine *engine) : _engine(engine) {}
161  ~Scene();
162 
163  int32 _needChangeScene = LBA1SceneId::Citadel_Island_Prison;
164  int32 _currentSceneIdx = LBA1SceneId::Citadel_Island_Prison; // NumCube
165  int32 _previousSceneIdx = LBA1SceneId::Citadel_Island_Prison;
166 
167  int32 _planet = -1;
168 
169  int32 _holomapTrajectory = -1;
170 
171  TextBankId _sceneTextBank = TextBankId::None;
172  int32 _alphaLight = 0;
173  int32 _betaLight = 0;
174 
175  IVec3 _newHeroPos;
176 
178  int16 _startYFalling = 0;
179 
181  ScenePositionType _heroPositionType = ScenePositionType::kNoPosition; // twinsenPositionModeInNewCube
182 
183  // ACTORS
184  int32 _nbObjets = 0;
185  ActorStruct *_sceneHero = nullptr;
186 
188  int16 _mecaPenguinIdx = 0;
189 
191  int16 _currentlyFollowedActor = OWN_ACTOR_SCENE_INDEX;
193  bool _flagClimbing = false;
194  bool _enableEnhancements = false;
196  int16 _currentScriptValue = 0;
197 
198  int16 _talkingActor = 0;
199 
200  // TRACKS Tell the actor where to go
201  int32 _sceneNumTracks = 0;
202  IVec3 _sceneTracks[NUM_MAX_TRACKS];
203 
204  bool _enableGridTileRendering = true;
205 
206  uint8 _listFlagCube[NUM_SCENES_FLAGS]{0};
207 
208  int32 _sceneNumZones = 0;
209  ZoneStruct _sceneZones[NUM_MAX_ZONES];
210 
211  ActorStruct *getActor(int32 actorIdx);
212 
213  void playSceneMusic();
214 
215  void reloadCurrentScene();
216 
218  void changeScene();
219 
221  void processEnvironmentSound();
222  void initSceneVars();
223 
224  bool isGameRunning() const;
225  void stopRunningGame();
226 
231  void checkZoneSce(int32 actorIdx);
232 };
233 
234 inline bool Scene::isGameRunning() const {
235  return _currentScene != nullptr;
236 }
237 
238 } // namespace TwinE
239 
240 #endif
Definition: actor.h:145
Definition: shared.h:113
int32 used
Definition: scene.h:81
Definition: actor.h:125
Definition: scene.h:116
Definition: twine.h:200
Definition: achievements_tables.h:27
Definition: scene.h:55
int32 textColor
Definition: scene.h:73