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 
27 namespace StarTrek {
28 
29 class Room;
30 
31 enum 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 
57 struct Action {
58  int8 type;
59  byte b1;
60  byte b2;
61  byte b3;
62 
63  // ACTION_USE, ACTION_GET, ACTION_LOOK, ACTION_TALK
64  byte activeObject() const {
65  return b1;
66  }
67  byte passiveObject() const {
68  return b2;
69  }
70 
71  bool operator==(const Action &a) const {
72  return type == a.type && b1 == a.b1 && b2 == a.b2 && b3 == a.b3;
73  }
74 
75  uint32 getBitmask() const {
76  uint32 ret = 0;
77  if (type != -1)
78  ret |= (0xff << 24);
79  if (b1 != 0xff)
80  ret |= (0xff << 16);
81  if (b2 != 0xff)
82  ret |= (0xff << 8);
83  if (b3 != 0xff)
84  ret |= (0xff << 0);
85  return ret;
86  }
87 
88  uint32 toUint32() const {
89  return (type << 24) | (b1 << 16) | (b2 << 8) | (b3 << 0);
90  }
91 
92  void saveLoadWithSerializer(Common::Serializer &ser) {
93  ser.syncAsByte(type);
94  ser.syncAsByte(b1);
95  ser.syncAsByte(b2);
96  ser.syncAsByte(b3);
97  }
98 };
99 
100 } // End of namespace StarTrek
101 
102 #endif
Definition: room.h:67
Definition: serializer.h:79
Definition: action.h:57
Definition: action.h:27