Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FSM::Node Struct Reference

#include <communication.h>

Public Member Functions

int GetSound (unsigned char sex, unsigned int multiple)
 
bool StopSound (unsigned char sex)
 
std::string GetMessage (unsigned int &multiple) const
 
void AddSound (std::string soundfile, unsigned char sex)
 
 Node (const vector< std::string > &message, float messagedel)
 

Static Public Member Functions

static Node MakeNode (std::string message, float messagedel)
 

Public Attributes

vector< std::string > messages
 
vector< std::string > soundfiles
 
vector< intsounds
 
float messagedelta
 
vector< unsigned intedges
 

Detailed Description

Definition at line 9 of file communication.h.

Constructor & Destructor Documentation

FSM::Node::Node ( const vector< std::string > &  message,
float  messagedel 
)
inline

Definition at line 20 of file communication.h.

References messages.

Referenced by MakeNode().

20  : messages( message )
21  , messagedelta( messagedel )
22  {
23  if (messages.size() == 0) messages.push_back( "<static>" );
24  }

Member Function Documentation

void FSM::Node::AddSound ( std::string  soundfile,
unsigned char  sex 
)

Definition at line 181 of file communication.cpp.

References vs_options::comm_preload, game_options, index, and int.

182 {
183  static std::string emptystr;
184 
185  for (int multiple = 0;; ++multiple) {
186  unsigned int index = ( (unsigned int) sex )*messages.size()+multiple;
187  while ( index >= sounds.size() ) {
188  sounds.push_back( -1 );
189  soundfiles.push_back(emptystr);
190  }
191 
192  if (soundfiles[index].empty()) {
193  soundfiles[index] = soundfile;
194 
195  // Preload sound if configured to do so
197  GetSound(sex, multiple);
198 
199  break;
200  }
201  }
202 }
std::string FSM::Node::GetMessage ( unsigned int multiple) const

Definition at line 135 of file communication.cpp.

References messages.

Referenced by DoSpeech().

136 {
137  multiple = rand()%messages.size();
138  return messages[multiple];
139 }
int FSM::Node::GetSound ( unsigned char  sex,
unsigned int  multiple 
)

Definition at line 145 of file communication.cpp.

References createSound(), index, and int.

Referenced by FireKeyboard::ProcessCommMessage().

146 {
147  unsigned int index = multiple+( (unsigned int) sex )*messages.size();
148  if ( index < sounds.size() ) {
149  if (sounds[index] < 0) {
151  return sounds[index];
152  } else {
153  return sounds[index];
154  }
155  } else {
156  return -1;
157  }
158 }
static Node FSM::Node::MakeNode ( std::string  message,
float  messagedel 
)
inlinestatic

Definition at line 25 of file communication.h.

References Node().

Referenced by FSM::FSM(), HelpOut(), and LeadMe().

26  {
27  vector< string >tmp;
28  tmp.push_back( message );
29  return Node( tmp, messagedel );
30  }
bool FSM::Node::StopSound ( unsigned char  sex)

Definition at line 160 of file communication.cpp.

References AUDIsPlaying(), AUDStopPlaying(), i, index, and int.

161 {
162  unsigned int index = ( (unsigned int) sex )*messages.size();
163  bool ret = false;
164  for (unsigned int i = index; i < index+messages.size() && i < sounds.size(); ++i)
165  if ( sounds[i] > 0 && AUDIsPlaying( sounds[i] ) ) {
166  AUDStopPlaying( sounds[i] );
167  ret = true;
168  }
169  return ret;
170 }

Member Data Documentation

float FSM::Node::messagedelta

Definition at line 14 of file communication.h.

Referenced by DoSpeech(), and FireKeyboard::DoSpeechAndAni().

vector< std::string > FSM::Node::messages

Definition at line 11 of file communication.h.

Referenced by GetMessage(), and Node().

vector< std::string > FSM::Node::soundfiles

Definition at line 12 of file communication.h.

vector< int > FSM::Node::sounds

Definition at line 13 of file communication.h.


The documentation for this struct was generated from the following files: