2010-03-25 13:15:10 +01:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
|
|
|
|
//
|
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_UNITTYPE_H_
|
|
|
|
|
#define _GLEST_GAME_UNITTYPE_H_
|
|
|
|
|
|
|
|
|
|
#include "element_type.h"
|
|
|
|
|
#include "command_type.h"
|
|
|
|
|
#include "damage_multiplier.h"
|
|
|
|
|
#include "sound_container.h"
|
|
|
|
|
#include "checksum.h"
|
|
|
|
|
#include "game_constants.h"
|
2011-01-15 00:51:15 +01:00
|
|
|
|
#include "platform_common.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
|
#include "leak_dumper.h"
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
using Shared::Sound::StaticSound;
|
|
|
|
|
using Shared::Util::Checksum;
|
2011-01-15 00:51:15 +01:00
|
|
|
|
using Shared::PlatformCommon::ValueCheckerVault;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
class UpgradeType;
|
|
|
|
|
class UnitType;
|
|
|
|
|
class UnitParticleSystemType;
|
|
|
|
|
class ResourceType;
|
|
|
|
|
class TechTree;
|
|
|
|
|
class FactionType;
|
2010-10-02 03:11:59 +02:00
|
|
|
|
class Faction;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class Level
|
|
|
|
|
// ===============================
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
class Level {
|
2010-03-25 13:15:10 +01:00
|
|
|
|
private:
|
|
|
|
|
string name;
|
|
|
|
|
int kills;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void init(string name, int kills);
|
|
|
|
|
|
|
|
|
|
const string &getName() const {return name;}
|
|
|
|
|
int getKills() const {return kills;}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ===============================
|
|
|
|
|
// class UnitType
|
|
|
|
|
//
|
|
|
|
|
/// A unit or building type
|
|
|
|
|
// ===============================
|
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
enum UnitClass {
|
2010-03-25 13:15:10 +01:00
|
|
|
|
ucWarrior,
|
|
|
|
|
ucWorker,
|
|
|
|
|
ucBuilding
|
|
|
|
|
};
|
|
|
|
|
|
2011-07-01 23:47:54 +02:00
|
|
|
|
typedef vector<UnitParticleSystemType*> DamageParticleSystemTypes;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
2011-01-15 00:51:15 +01:00
|
|
|
|
class UnitType: public ProducibleType, public ValueCheckerVault {
|
2010-03-25 13:15:10 +01:00
|
|
|
|
public:
|
2011-01-15 00:51:15 +01:00
|
|
|
|
enum Property {
|
2010-03-25 13:15:10 +01:00
|
|
|
|
pBurnable,
|
|
|
|
|
pRotatedClimb,
|
|
|
|
|
|
|
|
|
|
pCount
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const char *propertyNames[];
|
|
|
|
|
DamageParticleSystemTypes damageParticleSystemTypes;
|
|
|
|
|
private:
|
|
|
|
|
typedef vector<SkillType*> SkillTypes;
|
|
|
|
|
typedef vector<CommandType*> CommandTypes;
|
|
|
|
|
typedef vector<Resource> StoredResources;
|
|
|
|
|
typedef vector<Level> Levels;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
//basic
|
|
|
|
|
int id;
|
|
|
|
|
int maxHp;
|
|
|
|
|
int hpRegeneration;
|
|
|
|
|
int maxEp;
|
|
|
|
|
int epRegeneration;
|
2010-08-22 23:09:35 +02:00
|
|
|
|
int maxUnitCount;
|
2011-01-09 05:49:21 +01:00
|
|
|
|
|
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
///@todo remove fields, multiple fields are not supported by the engine
|
|
|
|
|
bool fields[fieldCount]; //fields: land, sea or air
|
|
|
|
|
Field field;
|
|
|
|
|
|
2010-03-25 13:15:10 +01:00
|
|
|
|
bool properties[pCount]; //properties
|
|
|
|
|
int armor; //armor
|
|
|
|
|
const ArmorType *armorType;
|
|
|
|
|
bool light;
|
|
|
|
|
Vec3f lightColor;
|
|
|
|
|
bool multiSelect;
|
|
|
|
|
int sight;
|
|
|
|
|
int size; //size in cells
|
|
|
|
|
int height;
|
|
|
|
|
float rotatedBuildPos;
|
2010-03-27 04:09:11 +01:00
|
|
|
|
bool rotationAllowed;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
//cellmap
|
|
|
|
|
bool *cellMap;
|
2010-10-30 10:54:00 +02:00
|
|
|
|
bool allowEmptyCellMap;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
//sounds
|
|
|
|
|
SoundContainer selectionSounds;
|
|
|
|
|
SoundContainer commandSounds;
|
|
|
|
|
|
|
|
|
|
//info
|
|
|
|
|
SkillTypes skillTypes;
|
|
|
|
|
CommandTypes commandTypes;
|
|
|
|
|
StoredResources storedResources;
|
|
|
|
|
Levels levels;
|
|
|
|
|
|
|
|
|
|
//meeting point
|
|
|
|
|
bool meetingPoint;
|
|
|
|
|
Texture2D *meetingPointImage;
|
|
|
|
|
|
|
|
|
|
//OPTIMIZATION: store first command type and skill type of each class
|
|
|
|
|
const CommandType *firstCommandTypeOfClass[ccCount];
|
|
|
|
|
const SkillType *firstSkillTypeOfClass[scCount];
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
//creation and loading
|
|
|
|
|
UnitType();
|
|
|
|
|
virtual ~UnitType();
|
|
|
|
|
void preLoad(const string &dir);
|
2011-03-15 16:30:28 +01:00
|
|
|
|
void load(int id, const string &dir, const TechTree *techTree,
|
|
|
|
|
const FactionType *factionType, Checksum* checksum,
|
2011-05-06 09:47:31 +02:00
|
|
|
|
Checksum* techtreeChecksum, std::map<string,vector<pair<string, string> > > &loadedFileList);
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
//get
|
|
|
|
|
int getId() const {return id;}
|
|
|
|
|
int getMaxHp() const {return maxHp;}
|
|
|
|
|
int getHpRegeneration() const {return hpRegeneration;}
|
|
|
|
|
int getMaxEp() const {return maxEp;}
|
|
|
|
|
int getEpRegeneration() const {return epRegeneration;}
|
2010-08-22 23:09:35 +02:00
|
|
|
|
int getMaxUnitCount() const {return maxUnitCount;}
|
2010-03-25 13:15:10 +01:00
|
|
|
|
bool getField(Field field) const {return fields[field];}
|
2010-07-11 20:31:02 +02:00
|
|
|
|
Field getField() const {return field;}
|
2010-03-25 13:15:10 +01:00
|
|
|
|
bool getProperty(Property property) const {return properties[property];}
|
|
|
|
|
int getArmor() const {return armor;}
|
|
|
|
|
const ArmorType *getArmorType() const {return armorType;}
|
|
|
|
|
const SkillType *getSkillType(int i) const {return skillTypes[i];}
|
2010-06-08 09:40:32 +02:00
|
|
|
|
const CommandType *getCommandType(int i) const;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
const Level *getLevel(int i) const {return &levels[i];}
|
|
|
|
|
int getSkillTypeCount() const {return skillTypes.size();}
|
|
|
|
|
int getCommandTypeCount() const {return commandTypes.size();}
|
|
|
|
|
int getLevelCount() const {return levels.size();}
|
|
|
|
|
bool getLight() const {return light;}
|
2010-03-27 04:09:11 +01:00
|
|
|
|
bool getRotationAllowed() const {return rotationAllowed;}
|
2010-03-25 13:15:10 +01:00
|
|
|
|
Vec3f getLightColor() const {return lightColor;}
|
|
|
|
|
bool getMultiSelect() const {return multiSelect;}
|
|
|
|
|
int getSight() const {return sight;}
|
|
|
|
|
int getSize() const {return size;}
|
|
|
|
|
int getHeight() const {return height;}
|
|
|
|
|
int getStoredResourceCount() const {return storedResources.size();}
|
|
|
|
|
const Resource *getStoredResource(int i) const {return &storedResources[i];}
|
|
|
|
|
bool getCellMapCell(int x, int y, CardinalDir facing) const;
|
|
|
|
|
bool getMeetingPoint() const {return meetingPoint;}
|
2010-10-21 19:42:45 +02:00
|
|
|
|
bool isMobile() const {return (firstSkillTypeOfClass[scMove] != NULL);}
|
2010-03-25 13:15:10 +01:00
|
|
|
|
Texture2D *getMeetingPointImage() const {return meetingPointImage;}
|
|
|
|
|
StaticSound *getSelectionSound() const {return selectionSounds.getRandSound();}
|
|
|
|
|
StaticSound *getCommandSound() const {return commandSounds.getRandSound();}
|
|
|
|
|
|
2011-04-09 05:14:05 +02:00
|
|
|
|
const SoundContainer & getSelectionSounds() const { return selectionSounds; }
|
|
|
|
|
const SoundContainer & getCommandSounds() const { return commandSounds; }
|
|
|
|
|
|
2010-03-25 13:15:10 +01:00
|
|
|
|
int getStore(const ResourceType *rt) const;
|
|
|
|
|
const SkillType *getSkillType(const string &skillName, SkillClass skillClass) const;
|
|
|
|
|
const SkillType *getFirstStOfClass(SkillClass skillClass) const;
|
|
|
|
|
const CommandType *getFirstCtOfClass(CommandClass commandClass) const;
|
2010-10-02 03:11:59 +02:00
|
|
|
|
const HarvestCommandType *getFirstHarvestCommand(const ResourceType *resourceType,const Faction *faction) const;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
const AttackCommandType *getFirstAttackCommand(Field field) const;
|
2011-03-28 23:04:47 +02:00
|
|
|
|
const AttackStoppedCommandType *getFirstAttackStoppedCommand(Field field) const;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
const RepairCommandType *getFirstRepairCommand(const UnitType *repaired) const;
|
|
|
|
|
|
|
|
|
|
//get totals
|
|
|
|
|
int getTotalMaxHp(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
int getTotalMaxEp(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
int getTotalArmor(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
int getTotalSight(const TotalUpgrade *totalUpgrade) const;
|
|
|
|
|
|
|
|
|
|
//has
|
|
|
|
|
bool hasCommandType(const CommandType *commandType) const;
|
|
|
|
|
bool hasCommandClass(CommandClass commandClass) const;
|
|
|
|
|
bool hasSkillType(const SkillType *skillType) const;
|
|
|
|
|
bool hasSkillClass(SkillClass skillClass) const;
|
|
|
|
|
bool hasCellMap() const {return cellMap!=NULL;}
|
2010-10-30 10:54:00 +02:00
|
|
|
|
bool getAllowEmptyCellMap() const {return allowEmptyCellMap;}
|
|
|
|
|
bool hasEmptyCellMap() const;
|
2011-05-01 07:36:04 +02:00
|
|
|
|
Vec2i getFirstOccupiedCellInCellMap(Vec2i currentPos) const;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
//is
|
|
|
|
|
bool isOfClass(UnitClass uc) const;
|
|
|
|
|
|
|
|
|
|
//find
|
|
|
|
|
const CommandType* findCommandTypeById(int id) const;
|
2010-04-20 04:19:37 +02:00
|
|
|
|
string getCommandTypeListDesc() const;
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
|
|
|
|
float getRotatedBuildPos() { return rotatedBuildPos; }
|
2010-05-01 22:14:25 +02:00
|
|
|
|
void setRotatedBuildPos(float value) { rotatedBuildPos = value; }
|
2010-03-25 13:15:10 +01:00
|
|
|
|
|
2010-08-22 23:09:35 +02:00
|
|
|
|
//other
|
|
|
|
|
virtual string getReqDesc() const;
|
2011-01-09 05:49:21 +01:00
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
|
std::string toString() const;
|
|
|
|
|
|
2010-03-25 13:15:10 +01:00
|
|
|
|
private:
|
|
|
|
|
void computeFirstStOfClass();
|
|
|
|
|
void computeFirstCtOfClass();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|