1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#include "lastexpress/game/object.h"
#include "lastexpress/game/logic.h"
#include "lastexpress/game/scenes.h"
#include "lastexpress/game/state.h"
#include "lastexpress/helpers.h"
#include "lastexpress/lastexpress.h"
namespace LastExpress {
Common::String Objects::Object::toString() {
return Common::String::format("{ %s - %d - %d - %d - %d }", ENTITY_NAME(entity), location, cursor, cursor2, location2);
}
Objects::Objects(LastExpressEngine *engine) : _engine(engine) {}
const Objects::Object Objects::get(ObjectIndex index) const {
if (index >= kObjectMax)
error("Objects::get - internal error: invalid object index (%d)", index);
return _objects[index];
}
void Objects::update(ObjectIndex index, EntityIndex entity, ObjectLocation location, CursorStyle cursor, CursorStyle cursor2) {
if (index >= kObjectMax)
return;
Object *object = &_objects[index];
// Store original location
ObjectLocation original_location = object->location;
// Update entity
object->entity = entity;
object->location = location;
if (cursor != kCursorKeepValue || cursor2 != kCursorKeepValue) {
if (cursor != kCursorKeepValue)
object->cursor = cursor;
if (cursor2 != kCursorKeepValue)
object->cursor2 = cursor2;
getLogic()->updateCursor();
}
getFlags()->flag_3 = true;
// Compartments
if (original_location != location && (original_location == kObjectLocation2 || location == kObjectLocation2))
if ((index >= kObjectCompartment1 && index <= kObjectCompartment8)
|| (index >= kObjectCompartmentA && index <= kObjectCompartmentF)) {
getScenes()->updateDoorsAndClock();
}
}
void Objects::updateLocation2(ObjectIndex index, ObjectLocation location2) {
if (index >= kObjectMax)
return;
_objects[index].location2 = location2;
}
//////////////////////////////////////////////////////////////////////////
// Serializable
//////////////////////////////////////////////////////////////////////////
void Objects::saveLoadWithSerializer(Common::Serializer &s) {
for (int i = 0; i < ARRAYSIZE(_objects); i++)
_objects[i].saveLoadWithSerializer(s);
}
//////////////////////////////////////////////////////////////////////////
// toString
//////////////////////////////////////////////////////////////////////////
Common::String Objects::toString() {
Common::String ret = "";
for (int i = 0; i < ARRAYSIZE(_objects); i++)
ret += Common::String::format("%d : %s\n", i, _objects[i].toString().c_str());
return ret;
}
} // End of namespace LastExpress
|