ScummVM API documentation
character.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, MojoTouch has
23  * exclusively licensed this code on March 23th, 2024, to be used in
24  * closed-source products.
25  * Therefore, any contributions (commits) to it will also be dual-licensed.
26  *
27  */
28 
29 #ifndef TOON_CHARACTER_H
30 #define TOON_CHARACTER_H
31 
32 #include "common/array.h"
33 #include "common/rect.h"
34 
35 #include "toon/toon.h"
36 
37 namespace Toon {
38 
39 class ToonEngine;
40 
42  char _filename[9]; // 0
43  byte _flag1; // 9
44  short _offsetX; // 10
45  short _offsetY; // 12
46  short _unused; // 14
47  short _unused2; // 16
48  byte _flags2; // 18
49  byte _flags3; // 19
50  byte _flags4; // 20
51  byte _flags5; // 21
52  byte _flags6; // 22
53  byte _flags7; // 23
54  byte _flags8; // 24
55  byte _flags9; // 25
56 };
57 
58 class Character {
59 public:
60  Character(ToonEngine *vm);
61  virtual ~Character();
62  virtual void init();
63  virtual int32 getId();
64  virtual void setId(int32 id);
65  virtual void setFacing(int32 facing);
66  virtual void forceFacing(int32 facing);
67  virtual int32 getFacing();
68  virtual void setAnimScript(int32 animScriptId);
69  virtual void setSceneAnimationId(int32 sceneAnimationId);
70  virtual void setDefaultSpecialAnimationId(int32 defaultAnimationId);
71  virtual int32 getAnimScript();
72  virtual int32 getSceneAnimationId();
73  virtual void setFlag(int flag);
74  virtual int32 getFlag();
75  virtual int32 getAnimFlag();
76  virtual void setAnimFlag(int32 flag);
77  virtual void setPosition(int16 x, int16 y);
78  virtual void forcePosition(int16 x, int16 y);
79  virtual int16 getX();
80  virtual int16 getY();
81  virtual int16 getFinalX();
82  virtual int16 getFinalY();
83  virtual bool walkTo(int16 newPosX, int16 newPosY);
84  virtual bool getVisible();
85  virtual void setVisible(bool visible);
86  virtual bool loadWalkAnimation(const Common::String &animName);
87  virtual bool loadIdleAnimation(const Common::String &animName);
88  virtual bool loadTalkAnimation(const Common::String &animName);
89  virtual bool loadShadowAnimation(const Common::String &animName);
90  virtual bool setupPalette();
91  virtual void playStandingAnim();
92  virtual void playWalkAnim(int32 start, int32 end);
93  virtual void playTalkAnim();
94  virtual void playAnim(int32 animId, int32 unused, int32 flags);
95  virtual void update(int32 timeIncrement);
96  virtual int32 getScale();
97  virtual AnimationInstance *getAnimationInstance();
98  virtual void setAnimationInstance(AnimationInstance *instance);
99  virtual void save(Common::WriteStream *stream);
100  virtual void load(Common::ReadStream *stream, int32 saveGameVersion);
101  virtual void stopWalk();
102  virtual void stopSpecialAnim();
103  virtual void updateIdle();
104  virtual int32 getRandomIdleAnim() { return 0; }
105  virtual void updateTimers(int32 relativeAdd);
106  virtual void setTalking(bool talking) { _isTalking = talking; }
107  virtual bool isTalking() { return _isTalking; }
108  virtual void resetScale() {}
109  virtual void plotPath(Graphics::Surface& surface);
110 
111  int32 getFacingFromDirection(int16 dx, int16 dy);
112  const SpecialCharacterAnimation *getSpecialAnimation(int32 characterId, int32 animationId);
113 
114 protected:
115  ToonEngine *_vm;
116 
117  int32 _id;
118  int32 _animScriptId;
119  int32 _animSpecialId;
120  int32 _animSpecialDefaultId;
121  int32 _sceneAnimationId;
122  int32 _lineToSayId;
123  int32 _time;
124  int16 _x;
125  int16 _y;
126  int32 _z;
127  int16 _finalX;
128  int16 _finalY;
129  int32 _facing;
130  int32 _flags;
131  int32 _animFlags;
132  int32 _scale;
133  int32 _nextIdleTime;
134  bool _visible;
135  bool _blockingWalk;
136  int32 _speed;
137  int32 _lastWalkTime;
138  int32 _numPixelToWalk;
139  bool _isTalking;
140 
141  AnimationInstance *_animationInstance;
142  AnimationInstance *_shadowAnimationInstance;
143  Animation *_walkAnim;
144  Animation *_idleAnim;
145  Animation *_talkAnim;
146  Animation *_shadowAnim;
147  Animation *_specialAnim;
148 
149  Common::Array<Common::Point> _currentPath;
150  uint32 _currentPathNode;
151  int32 _currentWalkStamp;
152  int32 _currentFacingStamp;
153 };
154 
155 } // End of namespace Toon
156 #endif
Definition: str.h:59
Definition: surface.h:67
Definition: stream.h:77
Definition: character.h:41
Definition: toon.h:118
Definition: stream.h:385
Definition: anim.h:39
Definition: anim.h:95
Definition: character.h:58
Definition: anim.h:54