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
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef TEAM_H
#define TEAM_H
#include <string>
#include <vector>
#include <list>
#include "TeamBase.h"
#include "TeamStatistics.h"
#include "Sim/Misc/Resource.h"
#include "System/Color.h"
#include "ExternalAI/SkirmishAIKey.h"
#include "Lua/LuaRulesParams.h"
class CUnit;
class CTeam : public TeamBase
{
CR_DECLARE_DERIVED(CTeam)
public:
CTeam();
void ResetResourceState();
void SlowUpdate();
bool HaveResources(const SResourcePack& amount) const;
void AddResources(SResourcePack res, bool useIncomeMultiplier = true);
bool UseResources(const SResourcePack& res);
void AddMetal(float amount, bool useIncomeMultiplier = true);
void AddEnergy(float amount, bool useIncomeMultiplier = true);
bool UseEnergy(float amount);
bool UseMetal(float amount);
void GiveEverythingTo(const unsigned toTeam);
void Died(bool normalDeath = true);
void AddPlayer(int playerNum);
void KillAIs();
void UpdateControllerName() override;
void SetDefaultStartPos();
void ClampStartPosInStartBox(float3* pos) const;
void SetMaxUnits(unsigned int n) { maxUnits = n; }
unsigned int GetMaxUnits() const { return maxUnits; }
unsigned int GetNumUnits() const { return numUnits; }
bool AtUnitLimit() const { return (numUnits >= maxUnits); }
const TeamStatistics& GetCurrentStats() const { return statHistory.back(); }
TeamStatistics& GetCurrentStats() { return statHistory.back(); }
CTeam& operator = (const TeamBase& base) {
TeamBase::operator = (base);
return *this;
}
enum AddType {
AddBuilt,
AddCaptured,
AddGiven
};
enum RemoveType {
RemoveDied,
RemoveCaptured,
RemoveGiven
};
void AddUnit(CUnit* unit, AddType type);
void RemoveUnit(CUnit* unit, RemoveType type);
public:
int teamNum;
unsigned int numUnits; // number of units this team controls
unsigned int maxUnits; // maximum number of units this team can control
bool isDead;
bool gaia;
SResourcePack res;
SResourcePack resStorage;
SResourcePack resPull, resPrevPull;
SResourcePack resIncome, resPrevIncome;
SResourcePack resExpense, resPrevExpense;
SResourcePack resShare;
SResourcePack resDelayedShare; //< excess that might be shared next SlowUpdate
SResourcePack resSent, resPrevSent;
SResourcePack resReceived, resPrevReceived;
SResourcePack resPrevExcess;
int nextHistoryEntry;
std::vector<TeamStatistics> statHistory;
/// mod controlled parameters
LuaRulesParams::Params modParams;
/// unsynced
float highlight;
};
#endif /* TEAM_H */
|