2010-03-13 22:10:45 +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_UNIT_H_
|
|
|
|
|
#define _GLEST_GAME_UNIT_H_
|
|
|
|
|
|
|
|
|
|
#include "model.h"
|
|
|
|
|
#include "upgrade_type.h"
|
|
|
|
|
#include "particle.h"
|
|
|
|
|
#include "skill_type.h"
|
2010-03-25 13:15:10 +01:00
|
|
|
|
#include "game_constants.h"
|
2010-04-18 09:35:48 +02:00
|
|
|
|
#include <set>
|
2010-10-17 10:50:27 +02:00
|
|
|
|
#include "platform_common.h"
|
2010-09-07 07:25:40 +02:00
|
|
|
|
#include "leak_dumper.h"
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
2010-10-17 10:50:27 +02:00
|
|
|
|
namespace Glest { namespace Game {
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
using Shared::Graphics::ParticleSystem;
|
|
|
|
|
using Shared::Graphics::UnitParticleSystem;
|
|
|
|
|
using Shared::Graphics::Vec4f;
|
|
|
|
|
using Shared::Graphics::Vec2f;
|
|
|
|
|
using Shared::Graphics::Vec3f;
|
|
|
|
|
using Shared::Graphics::Vec2i;
|
|
|
|
|
using Shared::Graphics::Model;
|
2010-10-17 10:50:27 +02:00
|
|
|
|
using Shared::PlatformCommon::Chrono;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
2010-04-18 09:35:48 +02:00
|
|
|
|
using std::set;
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
class Map;
|
|
|
|
|
class Faction;
|
|
|
|
|
class Unit;
|
|
|
|
|
class Command;
|
|
|
|
|
class SkillType;
|
|
|
|
|
class ResourceType;
|
|
|
|
|
class CommandType;
|
|
|
|
|
class SkillType;
|
|
|
|
|
class UnitType;
|
|
|
|
|
class TotalUpgrade;
|
|
|
|
|
class UpgradeType;
|
|
|
|
|
class Level;
|
|
|
|
|
class MorphCommandType;
|
2010-09-09 03:44:25 +02:00
|
|
|
|
class Game;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
enum CommandResult{
|
|
|
|
|
crSuccess,
|
|
|
|
|
crFailRes,
|
|
|
|
|
crFailReqs,
|
2010-08-22 23:09:35 +02:00
|
|
|
|
crFailUnitCount,
|
2010-03-13 22:10:45 +01:00
|
|
|
|
crFailUndefined,
|
|
|
|
|
crSomeFailed
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum InterestingUnitType{
|
|
|
|
|
iutIdleHarvester,
|
|
|
|
|
iutBuiltBuilding,
|
|
|
|
|
iutProducer,
|
|
|
|
|
iutDamaged,
|
|
|
|
|
iutStore
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class UnitObserver
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
|
|
class UnitObserver{
|
|
|
|
|
public:
|
|
|
|
|
enum Event{
|
|
|
|
|
eKill
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual ~UnitObserver() {}
|
|
|
|
|
virtual void unitEvent(Event event, const Unit *unit)=0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class UnitReference
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
|
|
|
|
class UnitReference{
|
|
|
|
|
private:
|
|
|
|
|
int id;
|
|
|
|
|
Faction *faction;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UnitReference();
|
|
|
|
|
|
|
|
|
|
void operator=(const Unit *unit);
|
|
|
|
|
Unit *getUnit() const;
|
2010-06-02 10:03:56 +02:00
|
|
|
|
|
|
|
|
|
int getUnitId() const { return id; }
|
|
|
|
|
Faction *getUnitFaction() const { return faction; }
|
2010-03-13 22:10:45 +01:00
|
|
|
|
};
|
|
|
|
|
|
2010-07-21 20:21:40 +02:00
|
|
|
|
class UnitPathInterface {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
virtual bool isBlocked() const = 0;
|
|
|
|
|
virtual bool isEmpty() const = 0;
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual bool isStuck() const = 0;
|
2010-07-21 20:21:40 +02:00
|
|
|
|
|
|
|
|
|
virtual void clear() = 0;
|
2010-08-28 03:46:26 +02:00
|
|
|
|
virtual void clearBlockCount() = 0;
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual void incBlockCount() = 0;
|
2010-09-07 23:01:22 +02:00
|
|
|
|
virtual void add(const Vec2i &path) = 0;
|
2010-07-21 21:17:45 +02:00
|
|
|
|
//virtual Vec2i pop() = 0;
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual int getBlockCount() const = 0;
|
|
|
|
|
virtual int getQueueCount() const = 0;
|
2010-07-21 20:21:40 +02:00
|
|
|
|
|
|
|
|
|
virtual std::string toString() const = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class UnitPathBasic : public UnitPathInterface {
|
|
|
|
|
private:
|
|
|
|
|
static const int maxBlockCount;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int blockCount;
|
|
|
|
|
vector<Vec2i> pathQueue;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UnitPathBasic();
|
|
|
|
|
virtual bool isBlocked() const;
|
|
|
|
|
virtual bool isEmpty() const;
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual bool isStuck() const;
|
2010-07-21 20:21:40 +02:00
|
|
|
|
|
|
|
|
|
virtual void clear();
|
2010-08-28 03:46:26 +02:00
|
|
|
|
virtual void clearBlockCount() { blockCount = 0; }
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual void incBlockCount();
|
2010-09-07 23:01:22 +02:00
|
|
|
|
virtual void add(const Vec2i &path);
|
2010-07-21 20:21:40 +02:00
|
|
|
|
Vec2i pop();
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual int getBlockCount() const { return blockCount; }
|
|
|
|
|
virtual int getQueueCount() const { return pathQueue.size(); }
|
2010-07-21 20:21:40 +02:00
|
|
|
|
|
|
|
|
|
virtual std::string toString() const;
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
// =====================================================
|
|
|
|
|
// class UnitPath
|
|
|
|
|
// =====================================================
|
2010-07-11 20:31:02 +02:00
|
|
|
|
/** Holds the next cells of a Unit movement
|
|
|
|
|
* @extends std::list<Shared::Math::Vec2i>
|
|
|
|
|
*/
|
2010-07-21 20:21:40 +02:00
|
|
|
|
class UnitPath : public list<Vec2i>, public UnitPathInterface {
|
2010-03-13 22:10:45 +01:00
|
|
|
|
private:
|
2010-07-11 20:31:02 +02:00
|
|
|
|
static const int maxBlockCount = 10; /**< number of command updates to wait on a blocked path */
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
private:
|
2010-07-11 20:31:02 +02:00
|
|
|
|
int blockCount; /**< number of command updates this path has been blocked */
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
public:
|
2010-07-11 20:31:02 +02:00
|
|
|
|
UnitPath() : blockCount(0) {} /**< Construct path object */
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual bool isBlocked() const {return blockCount >= maxBlockCount;} /**< is this path blocked */
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual bool isEmpty() const {return list<Vec2i>::empty();} /**< is path empty */
|
|
|
|
|
virtual bool isStuck() const {return false; }
|
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
int size() const {return list<Vec2i>::size();} /**< size of path */
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual void clear() {list<Vec2i>::clear(); blockCount = 0;} /**< clear the path */
|
2010-08-28 03:46:26 +02:00
|
|
|
|
virtual void clearBlockCount() { blockCount = 0; }
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual void incBlockCount() {++blockCount;} /**< increment block counter */
|
2010-09-07 23:01:22 +02:00
|
|
|
|
virtual void push(Vec2i &pos) {push_front(pos);} /**< push onto front of path */
|
2010-07-22 00:05:50 +02:00
|
|
|
|
bool empty() const {return list<Vec2i>::empty();} /**< is path empty */
|
2010-09-07 23:01:22 +02:00
|
|
|
|
virtual void add(const Vec2i &pos) { push_front(pos);} /**< push onto front of path */
|
2010-07-22 00:05:50 +02:00
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
|
2010-07-13 07:33:43 +02:00
|
|
|
|
#if 0
|
2010-07-11 20:31:02 +02:00
|
|
|
|
// old style, to work with original PathFinder
|
|
|
|
|
Vec2i peek() {return back();} /**< peek at the next position */
|
|
|
|
|
void pop() {this->pop_back();} /**< pop the next position off the path */
|
|
|
|
|
#else
|
|
|
|
|
// new style, for the new RoutePlanner
|
|
|
|
|
Vec2i peek() {return front();} /**< peek at the next position */
|
2010-07-21 21:17:45 +02:00
|
|
|
|
//virtual Vec2i pop() { Vec2i p= front(); erase(begin()); return p; } /**< pop the next position off the path */
|
|
|
|
|
void pop() { erase(begin()); } /**< pop the next position off the path */
|
2010-07-11 20:31:02 +02:00
|
|
|
|
#endif
|
2010-10-17 08:34:42 +02:00
|
|
|
|
virtual int getBlockCount() const { return blockCount; }
|
|
|
|
|
virtual int getQueueCount() const { return this->size(); }
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
2010-07-21 20:21:40 +02:00
|
|
|
|
virtual std::string toString() const;
|
2010-07-11 20:31:02 +02:00
|
|
|
|
};
|
2010-05-18 05:53:57 +02:00
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
class WaypointPath : public list<Vec2i> {
|
|
|
|
|
public:
|
|
|
|
|
WaypointPath() {}
|
|
|
|
|
void push(const Vec2i &pos) { push_front(pos); }
|
|
|
|
|
Vec2i peek() const {return front();}
|
|
|
|
|
void pop() {erase(begin());}
|
|
|
|
|
void condense();
|
2010-03-13 22:10:45 +01:00
|
|
|
|
};
|
|
|
|
|
|
2010-07-11 20:31:02 +02:00
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
// ===============================
|
|
|
|
|
// class Unit
|
|
|
|
|
//
|
|
|
|
|
/// A game unit or building
|
|
|
|
|
// ===============================
|
|
|
|
|
|
2010-08-28 03:46:26 +02:00
|
|
|
|
class Unit {
|
2010-03-13 22:10:45 +01:00
|
|
|
|
private:
|
|
|
|
|
typedef list<Command*> Commands;
|
|
|
|
|
typedef list<UnitObserver*> Observers;
|
2010-09-06 19:52:33 +02:00
|
|
|
|
typedef vector<UnitParticleSystem*> UnitParticleSystems;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
static const float speedDivider;
|
|
|
|
|
static const int maxDeadCount;
|
|
|
|
|
static const float highlightTime;
|
|
|
|
|
static const int invalidId;
|
|
|
|
|
|
2010-04-18 09:35:48 +02:00
|
|
|
|
static set<int> livingUnits;
|
|
|
|
|
static set<Unit*> livingUnitsp;
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
private:
|
2010-04-18 09:35:48 +02:00
|
|
|
|
const int id;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
int hp;
|
|
|
|
|
int ep;
|
|
|
|
|
int loadCount;
|
|
|
|
|
int deadCount;
|
|
|
|
|
float progress; //between 0 and 1
|
|
|
|
|
float lastAnimProgress; //between 0 and 1
|
|
|
|
|
float animProgress; //between 0 and 1
|
|
|
|
|
float highlight;
|
|
|
|
|
int progress2;
|
|
|
|
|
int kills;
|
|
|
|
|
|
|
|
|
|
UnitReference targetRef;
|
|
|
|
|
|
|
|
|
|
Field currField;
|
|
|
|
|
Field targetField;
|
|
|
|
|
const Level *level;
|
|
|
|
|
|
|
|
|
|
Vec2i pos;
|
|
|
|
|
Vec2i lastPos;
|
|
|
|
|
Vec2i targetPos; //absolute target pos
|
|
|
|
|
Vec3f targetVec;
|
|
|
|
|
Vec2i meetingPos;
|
|
|
|
|
|
|
|
|
|
float lastRotation; //in degrees
|
|
|
|
|
float targetRotation;
|
|
|
|
|
float rotation;
|
|
|
|
|
|
|
|
|
|
const UnitType *type;
|
|
|
|
|
const ResourceType *loadType;
|
|
|
|
|
const SkillType *currSkill;
|
|
|
|
|
|
|
|
|
|
bool toBeUndertaken;
|
|
|
|
|
bool alive;
|
|
|
|
|
bool showUnitParticles;
|
|
|
|
|
|
|
|
|
|
Faction *faction;
|
|
|
|
|
ParticleSystem *fire;
|
|
|
|
|
TotalUpgrade totalUpgrade;
|
|
|
|
|
Map *map;
|
|
|
|
|
|
2010-07-21 20:21:40 +02:00
|
|
|
|
UnitPathInterface *unitPath;
|
2010-07-11 20:31:02 +02:00
|
|
|
|
WaypointPath waypointPath;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
Commands commands;
|
|
|
|
|
Observers observers;
|
2010-09-06 19:52:33 +02:00
|
|
|
|
vector<UnitParticleSystem*> unitParticleSystems;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
UnitParticleSystems damageParticleSystems;
|
2010-09-06 19:52:33 +02:00
|
|
|
|
vector<ParticleSystem*> fireParticleSystems;
|
2010-04-18 09:35:48 +02:00
|
|
|
|
|
|
|
|
|
CardinalDir modelFacing;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
2010-04-27 05:36:36 +02:00
|
|
|
|
std::string lastSynchDataString;
|
2010-06-15 18:27:52 +02:00
|
|
|
|
int lastRenderFrame;
|
|
|
|
|
bool visible;
|
2010-04-27 05:36:36 +02:00
|
|
|
|
|
2010-08-28 03:46:26 +02:00
|
|
|
|
int retryCurrCommandCount;
|
|
|
|
|
|
2010-09-01 01:14:15 +02:00
|
|
|
|
Vec3f screenPos;
|
|
|
|
|
string currentUnitTitle;
|
|
|
|
|
|
2010-10-17 08:34:42 +02:00
|
|
|
|
bool inBailOutAttempt;
|
2010-10-17 10:50:27 +02:00
|
|
|
|
// This buffer stores a list of bad harvest cells, along with the start
|
|
|
|
|
// time of when it was detected. Typically this may be due to a unit
|
|
|
|
|
// constantly getting blocked from getting to the resource so this
|
|
|
|
|
// list may be used to tell areas of the game to ignore those cells for a
|
|
|
|
|
// period of time
|
|
|
|
|
std::vector<std::pair<Vec2i,Chrono> > badHarvestPosList;
|
|
|
|
|
std::pair<Vec2i,Chrono> lastHarvestResourceTarget;
|
2010-10-17 08:34:42 +02:00
|
|
|
|
|
2010-09-09 03:44:25 +02:00
|
|
|
|
static Game *game;
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
public:
|
2010-07-21 20:21:40 +02:00
|
|
|
|
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
|
2010-03-13 22:10:45 +01:00
|
|
|
|
~Unit();
|
|
|
|
|
|
2010-09-09 03:44:25 +02:00
|
|
|
|
static void setGame(Game *value) { game=value;}
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
//queries
|
|
|
|
|
int getId() const {return id;}
|
|
|
|
|
Field getCurrField() const {return currField;}
|
|
|
|
|
int getLoadCount() const {return loadCount;}
|
|
|
|
|
float getLastAnimProgress() const {return lastAnimProgress;}
|
|
|
|
|
float getProgress() const {return progress;}
|
|
|
|
|
float getAnimProgress() const {return animProgress;}
|
|
|
|
|
float getHightlight() const {return highlight;}
|
|
|
|
|
int getProgress2() const {return progress2;}
|
|
|
|
|
int getFactionIndex() const;
|
|
|
|
|
int getTeam() const;
|
|
|
|
|
int getHp() const {return hp;}
|
|
|
|
|
int getEp() const {return ep;}
|
|
|
|
|
int getProductionPercent() const;
|
|
|
|
|
float getHpRatio() const;
|
|
|
|
|
float getEpRatio() const;
|
|
|
|
|
bool getToBeUndertaken() const {return toBeUndertaken;}
|
|
|
|
|
Vec2i getTargetPos() const {return targetPos;}
|
|
|
|
|
Vec3f getTargetVec() const {return targetVec;}
|
|
|
|
|
Field getTargetField() const {return targetField;}
|
|
|
|
|
Vec2i getMeetingPos() const {return meetingPos;}
|
|
|
|
|
Faction *getFaction() const {return faction;}
|
|
|
|
|
const ResourceType *getLoadType() const {return loadType;}
|
|
|
|
|
const UnitType *getType() const {return type;}
|
|
|
|
|
const SkillType *getCurrSkill() const {return currSkill;}
|
|
|
|
|
const TotalUpgrade *getTotalUpgrade() const {return &totalUpgrade;}
|
|
|
|
|
float getRotation() const {return rotation;}
|
|
|
|
|
float getVerticalRotation() const;
|
|
|
|
|
ParticleSystem *getFire() const {return fire;}
|
|
|
|
|
int getKills() {return kills;}
|
|
|
|
|
const Level *getLevel() const {return level;}
|
|
|
|
|
const Level *getNextLevel() const;
|
|
|
|
|
string getFullName() const;
|
2010-07-21 20:21:40 +02:00
|
|
|
|
const UnitPathInterface *getPath() const {return unitPath;}
|
|
|
|
|
UnitPathInterface *getPath() {return unitPath;}
|
2010-07-11 20:31:02 +02:00
|
|
|
|
WaypointPath *getWaypointPath() {return &waypointPath;}
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
//pos
|
|
|
|
|
Vec2i getPos() const {return pos;}
|
|
|
|
|
Vec2i getLastPos() const {return lastPos;}
|
|
|
|
|
Vec2i getCenteredPos() const;
|
|
|
|
|
Vec2f getFloatCenteredPos() const;
|
|
|
|
|
Vec2i getCellPos() const;
|
|
|
|
|
|
|
|
|
|
//is
|
|
|
|
|
bool isHighlighted() const {return highlight>0.f;}
|
|
|
|
|
bool isDead() const {return !alive;}
|
|
|
|
|
bool isAlive() const {return alive;}
|
|
|
|
|
bool isOperative() const;
|
|
|
|
|
bool isBeingBuilt() const;
|
|
|
|
|
bool isBuilt() const;
|
|
|
|
|
bool isPutrefacting() const;
|
|
|
|
|
bool isAlly(const Unit *unit) const;
|
|
|
|
|
bool isDamaged() const;
|
|
|
|
|
bool isInteresting(InterestingUnitType iut) const;
|
|
|
|
|
|
|
|
|
|
//set
|
|
|
|
|
void setCurrField(Field currField) {this->currField= currField;}
|
|
|
|
|
void setCurrSkill(const SkillType *currSkill);
|
|
|
|
|
void setCurrSkill(SkillClass sc);
|
|
|
|
|
void setLoadCount(int loadCount) {this->loadCount= loadCount;}
|
|
|
|
|
void setLoadType(const ResourceType *loadType) {this->loadType= loadType;}
|
|
|
|
|
void setProgress2(int progress2) {this->progress2= progress2;}
|
|
|
|
|
void setPos(const Vec2i &pos);
|
|
|
|
|
void setTargetPos(const Vec2i &targetPos);
|
|
|
|
|
void setTarget(const Unit *unit);
|
2010-04-27 05:36:36 +02:00
|
|
|
|
void setTargetVec(const Vec3f &targetVec);
|
|
|
|
|
void setMeetingPos(const Vec2i &meetingPos);
|
2010-03-13 22:10:45 +01:00
|
|
|
|
void setVisible(const bool visible);
|
2010-06-15 18:27:52 +02:00
|
|
|
|
bool getVisible() const { return visible; }
|
2010-03-13 22:10:45 +01:00
|
|
|
|
|
|
|
|
|
//render related
|
|
|
|
|
const Model *getCurrentModel() const;
|
|
|
|
|
Vec3f getCurrVector() const;
|
|
|
|
|
Vec3f getCurrVectorFlat() const;
|
|
|
|
|
|
|
|
|
|
//command related
|
|
|
|
|
bool anyCommand() const;
|
|
|
|
|
Command *getCurrCommand() const;
|
2010-08-28 03:46:26 +02:00
|
|
|
|
void replaceCurrCommand(Command *cmd);
|
2010-08-22 23:09:35 +02:00
|
|
|
|
int getCountOfProducedUnits(const UnitType *ut) const;
|
2010-03-13 22:10:45 +01:00
|
|
|
|
unsigned int getCommandSize() const;
|
2010-04-18 09:35:48 +02:00
|
|
|
|
CommandResult giveCommand(Command *command, bool tryQueue = false); //give a command
|
2010-03-13 22:10:45 +01:00
|
|
|
|
CommandResult finishCommand(); //command finished
|
|
|
|
|
CommandResult cancelCommand(); //cancel canceled
|
|
|
|
|
|
|
|
|
|
//lifecycle
|
|
|
|
|
void create(bool startingUnit= false);
|
|
|
|
|
void born();
|
|
|
|
|
void kill();
|
|
|
|
|
void undertake();
|
|
|
|
|
|
|
|
|
|
//observers
|
|
|
|
|
void addObserver(UnitObserver *unitObserver) ;
|
|
|
|
|
void removeObserver(UnitObserver *unitObserver);
|
|
|
|
|
void notifyObservers(UnitObserver::Event event);
|
|
|
|
|
|
|
|
|
|
//other
|
|
|
|
|
void resetHighlight();
|
|
|
|
|
const CommandType *computeCommandType(const Vec2i &pos, const Unit *targetUnit= NULL) const;
|
|
|
|
|
string getDesc() const;
|
|
|
|
|
bool computeEp();
|
|
|
|
|
bool repair();
|
|
|
|
|
bool decHp(int i);
|
|
|
|
|
int update2();
|
|
|
|
|
bool update();
|
|
|
|
|
void tick();
|
|
|
|
|
void applyUpgrade(const UpgradeType *upgradeType);
|
|
|
|
|
void computeTotalUpgrade();
|
|
|
|
|
void incKills();
|
|
|
|
|
bool morph(const MorphCommandType *mct);
|
|
|
|
|
CommandResult checkCommand(Command *command) const;
|
|
|
|
|
void applyCommand(Command *command);
|
2010-04-18 09:35:48 +02:00
|
|
|
|
|
|
|
|
|
void setModelFacing(CardinalDir value);
|
2010-07-11 20:31:02 +02:00
|
|
|
|
CardinalDir getModelFacing() const { return modelFacing; }
|
2010-04-18 09:35:48 +02:00
|
|
|
|
|
2010-05-11 01:56:55 +02:00
|
|
|
|
bool isMeetingPointSettable() const;
|
|
|
|
|
|
2010-06-15 18:27:52 +02:00
|
|
|
|
int getLastRenderFrame() const { return lastRenderFrame; }
|
|
|
|
|
void setLastRenderFrame(int value) { lastRenderFrame = value; }
|
|
|
|
|
|
2010-08-28 03:46:26 +02:00
|
|
|
|
int getRetryCurrCommandCount() const { return retryCurrCommandCount; }
|
|
|
|
|
void setRetryCurrCommandCount(int value) { retryCurrCommandCount = value; }
|
|
|
|
|
|
2010-09-01 01:14:15 +02:00
|
|
|
|
Vec3f getScreenPos() const { return screenPos; }
|
|
|
|
|
void setScreenPos(Vec3f value) { screenPos = value; }
|
|
|
|
|
|
|
|
|
|
string getCurrentUnitTitle() const {return currentUnitTitle;}
|
|
|
|
|
void setCurrentUnitTitle(string value) { currentUnitTitle = value;}
|
|
|
|
|
|
2010-09-09 03:44:25 +02:00
|
|
|
|
void exploreCells();
|
|
|
|
|
|
2010-10-17 08:34:42 +02:00
|
|
|
|
bool getInBailOutAttempt() const { return inBailOutAttempt; }
|
|
|
|
|
void setInBailOutAttempt(bool value) { inBailOutAttempt = value; }
|
|
|
|
|
|
2010-10-17 10:50:27 +02:00
|
|
|
|
std::vector<std::pair<Vec2i,Chrono> > getBadHarvestPosList() const { return badHarvestPosList; }
|
|
|
|
|
void setBadHarvestPosList(std::vector<std::pair<Vec2i,Chrono> > value) { badHarvestPosList = value; }
|
|
|
|
|
void addBadHarvestPos(const Vec2i &value);
|
|
|
|
|
void removeBadHarvestPos(const Vec2i &value);
|
|
|
|
|
bool isBadHarvestPos(const Vec2i &value);
|
|
|
|
|
void cleanupOldBadHarvestPos();
|
|
|
|
|
|
|
|
|
|
void setLastHarvestResourceTarget(const Vec2i *pos);
|
|
|
|
|
std::pair<Vec2i,Chrono> getLastHarvestResourceTarget() const { return lastHarvestResourceTarget;}
|
|
|
|
|
|
2010-05-18 05:53:57 +02:00
|
|
|
|
std::string toString() const;
|
|
|
|
|
|
2010-03-13 22:10:45 +01:00
|
|
|
|
private:
|
|
|
|
|
float computeHeight(const Vec2i &pos) const;
|
|
|
|
|
void updateTarget();
|
|
|
|
|
void clearCommands();
|
|
|
|
|
CommandResult undoCommand(Command *command);
|
|
|
|
|
void stopDamageParticles();
|
|
|
|
|
void startDamageParticles();
|
2010-04-27 16:10:53 +02:00
|
|
|
|
|
2010-04-27 05:36:36 +02:00
|
|
|
|
void logSynchData(string source="");
|
2010-04-27 16:10:53 +02:00
|
|
|
|
int getFrameCount();
|
2010-03-13 22:10:45 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}}// end namespace
|
|
|
|
|
|
|
|
|
|
#endif
|