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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "ultima/ultima8/misc/pent_include.h"
24 
25 #include "ultima/ultima8/kernel/object_manager.h"
26 #include "ultima/ultima8/world/actors/main_actor.h"
27 #include "ultima/ultima8/gumps/gump.h"
28 #include "ultima/ultima8/world/world.h"
29 
30 namespace Ultima {
31 namespace Ultima8 {
32 
33 // utility functions for getting objects by ObjId in various forms
34 
getObject(ObjId id)35 Object *getObject(ObjId id) {
36 	return ObjectManager::get_instance()->getObject(id);
37 }
38 
getItem(ObjId id)39 Item *getItem(ObjId id) {
40 	return dynamic_cast<Item *>(ObjectManager::get_instance()->getObject(id));
41 }
42 
getContainer(ObjId id)43 Container *getContainer(ObjId id) {
44 	return dynamic_cast<Container *>(ObjectManager::get_instance()->getObject(id));
45 }
46 
getActor(ObjId id)47 Actor *getActor(ObjId id) {
48 	return dynamic_cast<Actor *>(ObjectManager::get_instance()->getObject(id));
49 }
50 
getMainActor()51 MainActor *getMainActor() {
52 	return dynamic_cast<MainActor *>(ObjectManager::get_instance()->getObject(1));
53 }
54 
getControlledActor()55 Actor *getControlledActor() {
56 	uint16 num = World::get_instance()->getControlledNPCNum();
57 	return dynamic_cast<Actor *>(ObjectManager::get_instance()->getObject(num));
58 }
59 
getGump(ObjId id)60 Gump *getGump(ObjId id) {
61 	return dynamic_cast<Gump *>(ObjectManager::get_instance()->getObject(id));
62 }
63 
64 } // End of namespace Ultima8
65 } // End of namespace Ultima
66