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
unit_functions.cpp File Reference
#include "unit.h"
#include "gfx/vec.h"
#include "gfx/animation.h"
#include "gfx/cockpit_generic.h"
#include "faction_generic.h"
#include "savegame.h"
#include "xml_support.h"
#include "unit_factory.h"
#include "gfx/halo.h"
#include "gfx/mesh.h"
#include "gfx/sphere.h"
#include "gfx/sprite.h"
#include "audiolib.h"
#include "collide2/CSopcodecollider.h"
#include "unit_collide.h"
#include <string>
#include <set>

Go to the source code of this file.

Functions

VSSpritecreateVSSprite (const char *file)
 
bool isVSSpriteLoaded (const VSSprite *sprite)
 
void deleteVSSprite (VSSprite *sprite)
 
int createSound (string file, bool val)
 
void cache_ani (string s)
 
void update_ani_cache ()
 
std::string getRandomCachedAniString ()
 
AnimationgetRandomCachedAni ()
 

Variables

static vsUMap< std::string,
Animation * > 
cached_ani
 
std::set< std::string > tempcache
 

Function Documentation

void cache_ani ( string  s)

Definition at line 47 of file unit_functions.cpp.

References tempcache.

Referenced by Unit::LoadRow().

48 {
49  tempcache.insert( s );
50 }
int createSound ( string  file,
bool  val 
)

Definition at line 38 of file unit_functions.cpp.

References AUDCreateSoundWAV().

39 {
40  return AUDCreateSoundWAV( file, val );
41 }
VSSprite* createVSSprite ( const char *  file)

Definition at line 25 of file unit_functions.cpp.

Referenced by Unit::LoadRow().

26 {
27  return new VSSprite( file );
28 }
void deleteVSSprite ( VSSprite sprite)

Definition at line 33 of file unit_functions.cpp.

Referenced by Unit::LoadRow().

34 {
35  delete sprite;
36 }
Animation* getRandomCachedAni ( )

Definition at line 71 of file unit_functions.cpp.

References cached_ani, i, and j.

72 {
73  if ( cached_ani.size() ) {
74  unsigned int rn = rand()%cached_ani.size();
75  vsUMap< std::string, Animation* >::iterator j = cached_ani.begin();
76  for (unsigned int i = 0; i < rn; i++)
77  j++;
78  return (*j).second;
79  } else {
80  return NULL;
81  }
82 }
std::string getRandomCachedAniString ( )

Definition at line 59 of file unit_functions.cpp.

References cached_ani, i, and j.

60 {
61  if ( cached_ani.size() ) {
62  unsigned int rn = rand()%cached_ani.size();
63  vsUMap< std::string, Animation* >::iterator j = cached_ani.begin();
64  for (unsigned int i = 0; i < rn; i++)
65  j++;
66  return (*j).first;
67  } else {
68  return "";
69  }
70 }
bool isVSSpriteLoaded ( const VSSprite sprite)

Definition at line 29 of file unit_functions.cpp.

Referenced by Unit::LoadRow().

30 {
31  return sprite->LoadSuccess();
32 }
void update_ani_cache ( )

Definition at line 51 of file unit_functions.cpp.

Referenced by UpdateAnimatedTexture().

52 {
53  for (std::set< std::string >::iterator it = tempcache.begin(); it != tempcache.end(); it++)
54  if ( cached_ani.find( *it ) == cached_ani.end() )
55  cached_ani.insert( std::pair< std::string, Animation* > ( *it,
56  new Animation( (*it).c_str(), false, .1, BILINEAR, false ) ) );
57  tempcache.clear();
58 }

Variable Documentation

vsUMap< std::string, Animation* > cached_ani
static
std::set< std::string > tempcache

Definition at line 46 of file unit_functions.cpp.

Referenced by cache_ani(), and update_ani_cache().