ScummVM API documentation
action.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 STARTREK_ACTION_H
23#define STARTREK_ACTION_H
24
25#include "common/serializer.h"
26
27namespace StarTrek {
28
29class Room;
30
31enum ActionTypes {
32 ACTION_TICK = 0,
33
34 ACTION_WALK = 1, // Actions 1-5 are directly usable on away missions.
35 ACTION_USE = 2,
36 ACTION_GET = 3,
37 ACTION_LOOK = 4,
38 ACTION_TALK = 5,
39
40 ACTION_TOUCHED_WARP = 6,
41 ACTION_TOUCHED_HOTSPOT = 7, // Second kind of "hotspot" only relevant when an object touches them
42 ACTION_TIMER_EXPIRED = 8,
43
44 ACTION_DONE_ANIM = 10,
45 ACTION_DONE_WALK = 12,
46
47 // TODO: remove these as redundant. They only still exist so I don't need to redo the
48 // manual spacing in the room action lists.
49 ACTION_FINISHED_ANIMATION = 10,
50 ACTION_FINISHED_WALKING = 12,
51
52 ACTION_OPTIONS = 13, // Not really an action, but selectable from action menu
53
54 ACTION_LIST_END = -1
55};
56
57struct Action {
58 int8 type;
59 byte b1;
60 byte b2;
61 byte b3;
62 int32 dummy; // for memory alignment on 64-bit systems. See RoomAction struct
63
64 // ACTION_USE, ACTION_GET, ACTION_LOOK, ACTION_TALK
65 byte activeObject() const {
66 return b1;
67 }
68 byte passiveObject() const {
69 return b2;
70 }
71
72 bool operator==(const Action &a) const {
73 return type == a.type && b1 == a.b1 && b2 == a.b2 && b3 == a.b3;
74 }
75
76 uint32 getBitmask() const {
77 uint32 ret = 0;
78 if (type != -1)
79 ret |= (0xff << 24);
80 if (b1 != 0xff)
81 ret |= (0xff << 16);
82 if (b2 != 0xff)
83 ret |= (0xff << 8);
84 if (b3 != 0xff)
85 ret |= (0xff << 0);
86 return ret;
87 }
88
89 uint32 toUint32() const {
90 return (type << 24) | (b1 << 16) | (b2 << 8) | (b3 << 0);
91 }
92
93 void saveLoadWithSerializer(Common::Serializer &ser) {
94 ser.syncAsByte(type);
95 ser.syncAsByte(b1);
96 ser.syncAsByte(b2);
97 ser.syncAsByte(b3);
98 }
99};
100
101} // End of namespace StarTrek
102
103#endif
Definition: serializer.h:80
Definition: room.h:67
Definition: action.h:27
Definition: action.h:57