ScummVM API documentation
entities.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 LASTEXPRESS_ENTITIES_H
23 #define LASTEXPRESS_ENTITIES_H
24 
25 /*
26  Entities
27  --------
28 
29  The entities structure contains 40 Entity_t structures for each entity
30 
31 */
32 
33 #include "lastexpress/entities/entity.h"
34 
35 #include "lastexpress/shared.h"
36 
37 #include "common/rect.h"
38 #include "common/serializer.h"
39 
40 namespace LastExpress {
41 
42 class LastExpressEngine;
43 class Sequence;
44 
46 public:
47  Entities(LastExpressEngine *engine);
48  ~Entities() override;
49 
50  // Serializable
51  void saveLoadWithSerializer(Common::Serializer &ser) override;
52  void savePositions(Common::Serializer &ser);
53  void saveCompartments(Common::Serializer &ser);
54 
55  void setup(bool isFirstChapter, EntityIndex entity);
56  void setupChapter(ChapterIndex chapter);
57  void reset();
58 
59  // Update & drawing
60 
67  void resetState(EntityIndex entity);
68  void updateFields() const;
69  void updateSequences() const;
70  void updateCallbacks();
71 
72  EntityIndex canInteractWith(const Common::Point &point) const;
73  bool compare(EntityIndex entity1, EntityIndex entity2) const;
74 
80  void updateFrame(EntityIndex entity) const;
81  void updatePositionEnter(EntityIndex entity, CarIndex car, Position position);
82  void updatePositionExit(EntityIndex entity, CarIndex car, Position position);
83  void enterCompartment(EntityIndex entity, ObjectIndex compartment, bool useCompartment1 = false);
84  void exitCompartment(EntityIndex entity, ObjectIndex compartment, bool useCompartment1 = false);
85 
86  // Sequences
87  void drawSequenceLeft(EntityIndex index, const char *sequence) const;
88  void drawSequenceRight(EntityIndex index, const char *sequence) const;
89  void clearSequences(EntityIndex index) const;
90 
91  bool updateEntity(EntityIndex entity, CarIndex car, EntityPosition position) const;
92  bool hasValidFrame(EntityIndex entity) const;
93 
94  // Accessors
95  Entity *get(EntityIndex entity);
96  EntityData::EntityCallData *getData(EntityIndex entity) const;
97  int getPosition(CarIndex car, Position position) const;
98  int getCompartments(int index) const;
99  int getCompartments1(int index) const;
100 
101  // Scene
102  void loadSceneFromEntityPosition(CarIndex car, EntityPosition position, bool alternate = false) const;
103 
105  // Checks
107 
117  bool isInsideCompartment(EntityIndex entity, CarIndex car, EntityPosition position) const;
118 
119  bool checkFields2(ObjectIndex object) const;
120 
128  bool isInsideCompartments(EntityIndex entity) const;
129 
137  bool isPlayerPosition(CarIndex car, Position position) const;
138 
147  bool isInsideTrainCar(EntityIndex entity, CarIndex car) const;
148 
156  bool isInGreenCarEntrance(EntityIndex entity) const;
157 
165  bool isPlayerInCar(CarIndex car) const;
166 
174  bool isDirectionUpOrDown(EntityIndex entity) const;
175 
185  bool isDistanceBetweenEntities(EntityIndex entity1, EntityIndex entity2, uint distance) const;
186 
187  bool checkFields10(EntityIndex entity) const;
188 
195 
203  bool isInSalon(EntityIndex entity) const;
204 
212  bool isInRestaurant(EntityIndex entity) const;
213 
221  bool isInKronosSalon(EntityIndex entity) const;
222 
228  bool isOutsideAlexeiWindow() const;
229 
235  bool isOutsideAnnaWindow() const;
236 
244  bool isInKitchen(EntityIndex entity) const;
245 
254  bool isNobodyInCompartment(CarIndex car, EntityPosition position) const;
255 
256  bool checkFields19(EntityIndex entity, CarIndex car, EntityPosition position) const;
257 
265  bool isInBaggageCarEntrance(EntityIndex entity) const;
266 
274  bool isInBaggageCar(EntityIndex entity) const;
275 
283  bool isInKronosSanctum(EntityIndex entity) const;
284 
292  bool isInKronosCarEntrance(EntityIndex entity) const;
293 
303  bool checkDistanceFromPosition(EntityIndex entity, EntityPosition position, int distance) const;
304 
312  bool isWalkingOppositeToPlayer(EntityIndex entity) const;
313 
321  static bool isFemale(EntityIndex entity);
322 
330  static bool isMarried(EntityIndex entity);
331 
332 private:
333  static const int _compartmentsCount = 16;
334  static const int _positionsCount = 100 * 10; // 100 positions per train car
335 
336  LastExpressEngine *_engine;
337  EntityData *_header;
338  Common::Array<Entity *> _entities;
339 
340  // Compartments & positions
341  uint _compartments[_compartmentsCount];
342  uint _compartments1[_compartmentsCount];
343  uint _positions[_positionsCount];
344 
345  void executeCallbacks();
346  void incrementDirectionCounter(EntityData::EntityCallData *data) const;
347  void processEntity(EntityIndex entity);
348 
349  void drawSequence(EntityIndex entity, const char *sequence, EntityDirection direction) const;
350  void drawSequences(EntityIndex entity, EntityDirection direction, bool loadSequence) const;
351  void loadSequence2(EntityIndex entity, Common::String sequenceName, Common::String sequenceName2, byte field30, bool loadSequence) const;
352 
353  void clearEntitySequenceData(EntityData::EntityCallData *data, EntityDirection direction) const;
354  void computeCurrentFrame(EntityIndex entity) const;
355  int16 getCurrentFrame(EntityIndex entity, Sequence *sequence, EntityPosition position, bool doProcessing) const;
356  void processFrame(EntityIndex entity, bool keepPreviousFrame, bool dontPlaySound);
357  void drawNextSequence(EntityIndex entity) const;
358  void updateEntityPosition(EntityIndex entity) const;
359  void copySequenceData(EntityIndex entity) const;
360 
361  bool changeCar(EntityData::EntityCallData *data, EntityIndex entity, CarIndex car, EntityPosition position, bool increment, EntityPosition newPosition, CarIndex newCar) const;
362 
363  void getSequenceName(EntityIndex entity, EntityDirection direction, Common::String &sequence1, Common::String &sequence2) const;
364 
365  void updatePositionsEnter(EntityIndex entity, CarIndex car, Position position1, Position position2, Position position3, Position position4);
366  void updatePositionsExit(EntityIndex entity, CarIndex car, Position position1, Position position2);
367 
368  void resetSequences(EntityIndex entity) const;
369 
370  bool checkPosition(EntityPosition position) const;
371  bool checkSequenceFromPosition(EntityIndex entity) const;
372  EntityPosition getEntityPositionFromCurrentPosition() const;
373 };
374 
375 } // End of namespace LastExpress
376 
377 #endif // LASTEXPRESS_ENTITIES_H
static bool isMarried(EntityIndex entity)
Definition: str.h:59
bool isInKronosSalon(EntityIndex entity) const
Definition: lastexpress.h:69
bool isOutsideAlexeiWindow() const
void updateFrame(EntityIndex entity) const
Definition: array.h:52
bool isInKronosCarEntrance(EntityIndex entity) const
static bool isFemale(EntityIndex entity)
Definition: entities.h:45
Definition: animation.h:45
bool isWalkingOppositeToPlayer(EntityIndex entity) const
Definition: serializer.h:79
Definition: entity.h:919
bool isInSalon(EntityIndex entity) const
bool isSomebodyInsideRestaurantOrSalon() const
bool isInBaggageCarEntrance(EntityIndex entity) const
bool isInKitchen(EntityIndex entity) const
bool checkDistanceFromPosition(EntityIndex entity, EntityPosition position, int distance) const
bool isDistanceBetweenEntities(EntityIndex entity1, EntityIndex entity2, uint distance) const
Definition: sequence.h:151
Definition: rect.h:45
bool isDirectionUpOrDown(EntityIndex entity) const
bool isOutsideAnnaWindow() const
Definition: serializer.h:308
bool isPlayerInCar(CarIndex car) const
bool isInsideCompartments(EntityIndex entity) const
bool isInKronosSanctum(EntityIndex entity) const
bool isPlayerPosition(CarIndex car, Position position) const
bool isInRestaurant(EntityIndex entity) const
bool isInBaggageCar(EntityIndex entity) const
void resetState(EntityIndex entity)
bool isInGreenCarEntrance(EntityIndex entity) const
bool isNobodyInCompartment(CarIndex car, EntityPosition position) const
bool isInsideCompartment(EntityIndex entity, CarIndex car, EntityPosition position) const
Definition: entity.h:300
bool isInsideTrainCar(EntityIndex entity, CarIndex car) const