forked from fuzzie/unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversation.h
119 lines (91 loc) · 2.97 KB
/
conversation.h
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
110
111
112
113
114
115
116
117
118
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef UNITY_CONVERSATION_H
#define UNITY_CONVERSATION_H
#include "object.h"
#include "common/array.h"
#include "common/str.h"
namespace Common {
class SeekableReadStream;
}
namespace Unity {
class UnityEngine;
class UnityData;
class Conversation;
class ResponseBlock {
public:
virtual void execute(UnityEngine *_vm, Object *speaker, Conversation *src) = 0;
virtual ~ResponseBlock() { }
};
class WhoCanSayBlock {
protected:
objectID whocansay;
public:
bool match(UnityEngine *_vm, objectID speaker);
void readFrom(Common::SeekableReadStream *stream);
};
class ChangeActionBlock : public ResponseBlock {
public:
int type;
uint16 response_id, state_id;
void readFrom(Common::SeekableReadStream *stream, int _type);
void execute(UnityEngine *_vm, Object *speaker, Conversation *src);
};
class ResultBlock : public ResponseBlock {
public:
EntryList entries;
void readFrom(Common::SeekableReadStream *stream);
void execute(UnityEngine *_vm, Object *speaker, Conversation *src);
};
class TextBlock {
public:
Common::String text;
uint32 voice_id, voice_group;
uint16 voice_subgroup;
void readFrom(Common::SeekableReadStream *stream);
void execute(UnityEngine *_vm, Object *speaker);
};
class Response {
public:
Response();
~Response();
uint16 id, state;
Common::Array<ResponseBlock *> blocks;
Common::Array<TextBlock *> textblocks;
Common::Array<WhoCanSayBlock *> whocansayblocks;
byte response_state;
uint16 next_situation;
objectID target;
Common::String text;
uint32 voice_id, voice_group;
uint16 voice_subgroup;
bool validFor(UnityEngine *_vm, objectID speaker);
void readFrom(Common::SeekableReadStream *stream);
void execute(UnityEngine *_vm, Object *speaker, Conversation *src);
};
class Conversation {
public:
Conversation();
~Conversation();
Common::Array<Response *> responses;
unsigned int our_world, our_id;
void loadConversation(UnityData &data, unsigned int world, unsigned int id);
Response *getResponse(unsigned int response, unsigned int state);
Response *getEnabledResponse(UnityEngine *_vm, unsigned int response, objectID speaker);
void execute(UnityEngine *_vm, Object *speaker, unsigned int situation);
//void execute(UnityEngine *_vm, Object *speaker, unsigned int response, unsigned int state);
};
} // Unity
#endif