ScummVM API documentation
scene_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 HARVESTER_SCENE_ENTITIES_H
23 #define HARVESTER_SCENE_ENTITIES_H
24 
25 #include "harvester/scene/room_support.h"
26 #include "harvester/entity.h"
27 
28 namespace Harvester {
29 
30 // Borrows the materialized room state; live entities remain owned by EntityManager.
32 public:
33  SceneEntities(RoomSetupState &state, Script *script, ResourceManager *resources, EntityManager *entityManager);
34 
35  static bool loadRoomSceneResources(const RoomSetupState &state, ResourceManager &resources, SceneState &scene);
36  bool loadSceneResources(const RoomSetupState &state, SceneState &scene) const;
37  bool reconcileSceneEntitiesInPlace(const SceneState &previousScene,
38  RoomSetupState &updatedState, const SceneState &updatedScene);
39  void syncCurrentRoomRuntimeState(const Common::Array<RegionRecord> &sceneRegions);
40  void syncGlobalTimerEntities(const Common::Array<TimerRecord> &previousTimerRecords,
41  bool includeCurrentRoomTimers = false);
42  void populateRoomRegions();
43  void populateRoomObjects(const Common::Array<ObjectRecord> &drawableObjects);
44  void populateRoomNpcs();
45  void populateRoomMonsters();
46  void restoreRoomMonsterAnimations();
47 
48  static const ObjectRecord *findSceneObjectByName(const Common::Array<ObjectRecord> &objects,
49  const Common::String &objectName);
50  static ObjectRecord *findSceneObjectByName(Common::Array<ObjectRecord> &objects,
51  const Common::String &objectName);
52  static const RegionRecord *findSceneRegionByName(const Common::Array<RegionRecord> &regions,
53  const Common::String &regionName);
54  static const NpcRecord *findSceneNpcByName(const Common::Array<NpcRecord> &npcs,
55  const Common::String &npcName);
56 
57  void removeSceneEntityByName(const Common::String &entityName);
58  static Common::Rect getSceneObjectBounds(const ObjectRecord &object);
59  static Common::String resolveSceneObjectSpritePathLocal(const ObjectRecord &object);
60  void spawnSceneObjectEntityFromRecord(const ObjectRecord &object);
61  void spawnSceneRegionEntityFromRecord(const RegionRecord &region);
62  static bool shouldSpawnRoomNpcEntity(const NpcRecord &npc);
63  static bool shouldSpawnRoomMonsterEntity(const MonsterRecord &monster);
64  Entity *spawnSceneNpcEntityFromRecord(const NpcRecord &npc);
65  Entity *spawnSceneMonsterEntityFromRecord(const RoomSetupState &roomState, const MonsterRecord &monster);
66 
67 private:
68  bool isTimerMaterializedInCurrentRoom(const Common::String &timerName) const;
69  Entity *createSceneObjectEntity(const ObjectRecord &object,
70  const Common::String &spritePath, const Common::Rect &hotspotBounds);
71  bool isInteractiveSceneHotspot(const ObjectRecord &object) const;
72  EntityClass resolveSceneObjectClassLocal(const ObjectRecord &object, const Entity *entity) const;
73  static Common::Rect getSceneRegionBounds(const RegionRecord &region);
74  Entity *createSceneRegionEntity(const RegionRecord &region,
75  const Common::Rect &bounds, const Common::String &diagnosticRoomName);
76  static bool applyRoomNpcPlacement(Entity &entity, const NpcRecord &npc);
77  static void configureRoomNpcAnimation(Entity &entity, const NpcRecord &npc, bool preservedCorpse);
78  Entity *createSceneMonsterEntity(const MonsterRecord &monster);
79 
80  RoomSetupState &_state;
81  Script *_script;
82  ResourceManager *_resources;
83  EntityManager *_entityManager;
84 };
85 
86 } // End of namespace Harvester
87 
88 #endif // HARVESTER_SCENE_ENTITIES_H
Definition: script.h:237
Definition: str.h:59
Definition: art.h:31
Definition: script.h:132
Definition: array.h:52
Definition: script.h:342
Definition: room_support.h:46
Definition: rect.h:536
Definition: script.h:86
Definition: entity.h:66
Definition: entity.h:184
Definition: scene_entities.h:31
Definition: resources.h:32
Definition: script.h:164
Definition: monster.h:31