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
|
#ifndef TEAM_H
#define TEAM_H
// Team.h: interface for the CTeam class.
//
//////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include <map>
#include <list>
#include "TeamBase.h"
#include "TeamStatistics.h"
#include "Sim/Units/UnitSet.h"
#include "ExternalAI/SkirmishAIKey.h"
class CTeam : public TeamBase
{
CR_DECLARE(CTeam);
public:
CTeam();
~CTeam();
/**
* This has to be called for every team before SlowUpdates start,
* otherwise values get overwritten.
*/
void ResetFrameVariables();
void SlowUpdate();
void AddMetal(float amount, bool handicap = true);
void AddEnergy(float amount, bool handicap = true);
bool UseEnergy(float amount);
bool UseMetal(float amount);
bool UseEnergyUpkeep(float amount);
bool UseMetalUpkeep(float amount);
void GiveEverythingTo(const unsigned toTeam);
void Died();
void StartposMessage(const float3& pos);
void operator=(const TeamBase& base);
std::string GetControllerName() const;
enum AddType {
AddBuilt,
AddCaptured,
AddGiven
};
enum RemoveType {
RemoveDied,
RemoveCaptured,
RemoveGiven
};
void AddUnit(CUnit* unit, AddType type);
void RemoveUnit(CUnit* unit, RemoveType type);
int teamNum;
bool isDead;
bool gaia;
int lineageRoot;
/// color info is unsynced
unsigned char origColor[4];
CUnitSet units;
SyncedFloat metal;
SyncedFloat energy;
float metalPull, prevMetalPull;
float metalIncome, prevMetalIncome;
float metalExpense, prevMetalExpense;
float metalUpkeep, prevMetalUpkeep;
float energyPull, prevEnergyPull;
float energyIncome, prevEnergyIncome;
float energyExpense, prevEnergyExpense;
float energyUpkeep, prevEnergyUpkeep;
SyncedFloat metalStorage, energyStorage;
float metalShare, energyShare;
SyncedFloat delayedMetalShare, delayedEnergyShare; // excess that might be shared next SlowUpdate
float metalSent;
float metalReceived;
float energySent;
float energyReceived;
typedef TeamStatistics Statistics;
Statistics currentStats;
/// in intervalls of this many seconds, statistics are updated
static const int statsPeriod = 15;
int lastStatSave;
/// number of units with commander tag in team, if it reaches zero with cmd ends the team dies
int numCommanders;
std::list<Statistics> statHistory;
void CommanderDied(CUnit* commander);
void LeftLineage(CUnit* unit);
/// mod controlled parameters
std::vector<float> modParams;
/// name map for mod parameters
std::map<std::string, int> modParamsMap;
};
#endif /* TEAM_H */
|