3 #ifndef __UNIT_GENERIC_H__
4 #define __UNIT_GENERIC_H__
32 #define CONTAINER_DEBUG
34 #ifdef CONTAINER_DEBUG
74 ,
color( 1, 1, 1, 1 ) {}
156 Mount(
const std::string &name,
194 signed char autotrack,
198 bool Fire(
Unit *firer,
void *
owner,
bool Missile =
false,
bool collide_only_with_target =
false );
208 template <
typename BOGUS >
212 struct PlanetaryOrbitData;
259 Unit( std::vector< Mesh* > &meshes,
bool Subunit,
int faction );
266 Unit(
const char *
filename,
bool SubUnit,
int faction, std::string customizedUnit = std::string(
277 void Init(
const char *filename,
bool SubUnit,
int faction, std::string customizedUnit = std::string(
281 void LoadRow(
class CSVRow&row, std::string unitMod, std::string*netxml = NULL );
320 double &percentage,
Unit*(*createupgradesubunit)(std::string s,
327 double &percentage );
334 double &percentage );
346 #define NO_MOUNT_STAR
357 unsigned SubUnit : 1;
387 bool forcetransaction,
389 const Unit *downgrade_min,
390 bool force_change_on_nothing,
391 bool gen_downgrade_list );
392 void ImportPartList(
const std::string &category,
float price,
float pricedev,
float quantity,
float quantdev );
408 const Unit *templ = NULL,
409 bool force_change_on_nothing =
false,
410 bool gen_downgrade_list =
true );
417 const Unit *templ = NULL,
418 bool force_change_on_nothing =
false,
419 bool gen_downgrade_list =
true );
426 virtual double Upgrade(
const std::string &
file,
int mountoffset,
int subunitoffset,
bool force,
bool loop_through_mounts );
431 const Unit *downgradelimit,
432 bool gen_downgrade_list =
true );
437 const Unit *downgradelimit,
438 bool gen_downgrade_list =
true );
520 std::string halo_type,
521 float activation ) {}
528 virtual bool Explode(
bool draw,
float timeit );
688 bool DoSightAndSound );
730 static void beginElement(
void *userData,
const XML_Char *
name,
const XML_Char **atts );
745 void WriteUnit(
const char *modificationname =
"" );
748 void LoadXML(
const char *filename,
const char *unitModifications =
"", std::string *xmlbuffer = NULL );
758 void RechargeEnergy();
851 , structurelimits( 0, 0, 0 )
879 return ( (
float)
cloaking )/2147483647;
882 virtual void Cloak(
bool cloak );
884 void Kill(
bool eraseFromSave =
true,
bool quitting =
false );
996 Unit *affectedSubUnit,
998 float phasedamage = 0 );
1005 Unit *affectedSubUnit,
1007 void *ownerDoNotDereference,
1008 float phasedamage = 0 );
1022 virtual void Thrust(
const Vector &amt,
bool afterburn =
false );
1049 const Vector &CumulativeVelocity,
1058 const Vector &CumulativeVelocity,
1064 const Vector &CumulativeVelocity,
1072 const Vector &CumulativeVelocity,
1204 void Fire(
unsigned int bitmask,
bool beams_target_owner =
false );
1223 return InRange( target, mm, cone, cap,
true );
1241 float cosAngleTo(
Unit *
target,
float &distance,
float speed = 0.001,
float range = 0.001,
bool turnmargin =
true )
const;
1272 int RemoveCargo(
unsigned int i,
int quantity,
bool eraseZero =
true );
1276 void GetSortedCargoCat(
const std::string &category,
size_t &catbegin,
size_t &catend );
1279 const Cargo *
GetCargo(
const std::string &s,
unsigned int &i )
const;
1281 std::string
GetManifest(
unsigned int i,
Unit *scanningUnit,
const Vector &original_velocity )
const;
1282 bool SellCargo(
unsigned int i,
int quantity,
float &creds,
Cargo &carg,
Unit *buyer );
1283 bool SellCargo(
const std::string &s,
int quantity,
float &creds,
Cargo &carg,
Unit *buyer );
1285 bool BuyCargo(
unsigned int i,
unsigned int quantity,
Unit *buyer,
float &creds );
1286 bool BuyCargo(
const std::string &cargo,
unsigned int quantity,
Unit *buyer,
float &creds );
1303 1 ),
const std::vector< struct mesh_polygon >* = NULL );
1401 bool bigasteroid =
false,
1402 bool smallasteroid =
false );
1407 const Vector &smallnormal,
1475 std::vector< class CargoColor >&
FilterDowngradeList( std::vector< class CargoColor > &mylist,
bool downgrade =
true );
1476 std::vector< class CargoColor >&
FilterUpgradeList( std::vector< class CargoColor > &mylist );
1492 unsigned char tractorability_flags;
1509 return filename.get();
1582 enum restr {YRESTR=1, PRESTR=2, RRESTR=4};
1598 #ifdef CONTAINER_DEBUG
1601 if ( unit->Killed() ) {
1609 #ifdef USE_OLD_COLLECTION
1610 inline void UnitCollection::UnitIterator::GetNextValidUnit()
1612 while (pos->next->unit ? pos->next->unit->Killed() :
false)
1650 static std::map< string, Unit * >
Units;
1654 bool Init(
const char *filename,
int faction,
Flightgroup *flightgrp = NULL,
const char *animationExt = NULL);
1656 static void UpdateFrames();
1658 void AnimationStep();
1664 string getAnimationName(
unsigned int animationNumber)
const;
1666 unsigned int getAnimationNumber(
const char *
name)
const;
1668 void ChangeAnimation(
const char *
name );
1670 void ChangeAnimation(
unsigned int AnimNumber );
1673 void StartAnimation(
unsigned int how_many_times = 0,
int numAnimation = 0 );
1675 void StopAnimation();
1677 bool isAnimatedMesh()
const;
1679 bool animationRuns()
const;
1681 unsigned int numAnimations();
1683 bool isContinuousLoop()
const;
1685 void addAnimation( std::vector<Mesh *> *meshes,
const char*
name );
1687 double framesPerSecond()
const;
1689 double timePerFrame()
const;
1691 void ToggleAnimatedMesh(
bool on );
1693 void SetAniSpeed(
float speed );