00001
00002
00003
00004
00005
00006
00007
00008 #ifndef ENT_H_
00009 #define ENT_H_
00010
00011
00012 #include <iostream>
00013 #include <cstring>
00014 #include <assert.h>
00015
00016 #include <boost/lexical_cast.hpp>
00017
00018
00019 #include <OgreVector3.h>
00020 #include <OgreQuaternion.h>
00021
00022 #include <const.h>
00023 #include <utils.h>
00024
00025 #include <command.h>
00026 #include <unitWeapons.h>
00027 #include <unitAI.h>
00028 #include <physics.h>
00029
00030 #include <enums.h>
00031 #include <identity.h>
00032
00033
00034 #include <netAspect.h>
00035
00036
00037 namespace FastEcslent {
00038
00039 class Engine ;
00040 class UnitAspect ;
00041
00042
00043 class Entity {
00044
00045 public:
00046 static int count;
00047
00048
00049 Ogre::Vector3 pos;
00050 Ogre::Vector3 vel;
00051 Ogre::Vector3 acc;
00052
00053 Ogre::Vector3 potentialVec;
00054 double attractivePotential;
00055
00056 Ogre::Quaternion rot;
00057 float yaw;
00058 float desiredSpeed;
00059 float desiredHeading;
00060 float speed;
00061 float maxSpeed;
00062 float minSpeed;
00063 float speedRange;
00064 float heading;
00065 float maxAcceleration;
00066 float maxRotationalSpeed;
00067
00068
00069 float turningRadius;
00070
00071 float length, width, height, depth;
00072 float mass;
00073
00074 std::string uiname;
00075 std::string meshName;
00076
00077 Engine *engine;
00078 Identity entityId;
00079 int idNumber;
00080 EntityType entityType;
00081 EntityClass entityClass;
00082
00083
00084
00085 EntityState entityState;
00086 double gestationPeriod;
00087 double timeLeftToBirth;
00088 double timeLeftToDie;
00089
00090
00091 boost::mutex entLock;
00092
00093 std::deque<UnitAspect*> aspects;
00094
00095 Weapon* weapon;
00096 UnitAI* ai;
00097 Physics* physics;
00098 NetAspect* netAspect;
00099
00100
00101 bool isSelected;
00102 bool selectable;
00103
00104
00105
00106
00107
00108
00109
00110 private:
00111 void reset();
00112
00113
00114 public:
00115 Entity(Engine *eng, EntityType entType) ;
00116
00117 virtual void init();
00118
00119 UnitAspect *getAspect(UnitAspectType i);
00120 void removeAspect(UnitAspectType i);
00121 void addAspect(UnitAspect* asp);
00122 void switchState(EntityState newState);
00123
00124 virtual void print();
00125 virtual void tick(double dt);
00126
00127
00128
00129
00130 virtual void gestatingTick(double dt);
00131 virtual void aliveTick(double dt);
00132 virtual void dyingTick(double dt);
00133 virtual void deadTick(double dt);
00134
00135 virtual bool raising(double dt);
00136 virtual bool sinking(double dt);
00137
00138 };
00139
00140
00141 class Marine : public Entity {
00142
00143 public:
00144
00145 Marine(Engine *eng) : Entity(eng, MARINE) {
00146 meshName = "cigarette.mesh";
00147 uiname = "Cigarette.";
00148 uiname.append(boost::lexical_cast<std::string>(count++));
00149
00150
00151
00152 length = meters(20.0f);
00153 width = meters(4.0f);
00154 height = meters(6.0f);
00155
00156 maxSpeed = knots(45.0f);
00157 minSpeed = knots(0.0f);
00158 speedRange = maxSpeed - minSpeed + EPSILON;
00159 maxAcceleration = feetPerSecondSquared(15.0f);
00160 maxRotationalSpeed = degreesPerSecond(6.5f);
00161 turningRadius = 10;
00162 mass = pounds(1100);
00163
00164 selectable = true;
00165
00166 entityId.side = RED;
00167
00168 }
00169 };
00170
00171 class Reaper : public Entity {
00172
00173 public:
00174
00175 Reaper(Engine *eng) : Entity(eng, REAPER) {
00176 meshName = "boat.mesh";
00177 uiname = "SpeedBoat.";
00178 uiname.append(boost::lexical_cast<std::string>(count++));
00179
00180
00181
00182 length = 10.0f;
00183 width = 4.0f;
00184 height = 6.0f;
00185 maxSpeed = knots(40.0f);
00186 minSpeed = knots(0.0f);
00187 speedRange = maxSpeed - minSpeed + EPSILON;
00188 maxAcceleration = 20.0f;
00189 maxRotationalSpeed = 2.5f;
00190 turningRadius = 10;
00191 mass = pounds(1100);
00192
00193 selectable = true;
00194
00195 entityId.side = RED;
00196
00197 }
00198 };
00199
00200 class Tank : public Entity {
00201
00202 public:
00203
00204 Tank(Engine *eng) : Entity(eng, TANK) {
00205 meshName = "ddg51.mesh";
00206 uiname = "DDG51.";
00207 uiname.append(boost::lexical_cast<std::string>(count++));
00208
00209
00210 length = feet(466.0f);
00211 width = feet(59.0f);
00212 height = feet(100.0f);
00213 maxSpeed = knots(30.0f);
00214 minSpeed = knots(0.0f);
00215 speedRange = maxSpeed - minSpeed + EPSILON;
00216 maxAcceleration = feetPerSecondSquared(10.0f);
00217 maxRotationalSpeed = degreesPerSecond(1.0f);
00218 turningRadius = 750;
00219 mass = tons(842);
00220
00221 selectable = true;
00222
00223 entityId.side = BLUE;
00224
00225
00226 }
00227 };
00228
00229
00230 class Thor : public Entity {
00231
00232 public:
00233
00234 Thor(Engine *eng) : Entity(eng, THOR) {
00235 meshName = "cvn68.mesh";
00236 uiname = "CVN68.";
00237 uiname.append(boost::lexical_cast<std::string>(count++));
00238
00239
00240 length = meters(332.0f);
00241 width = meters(200.0f);
00242 height = meters(100.0f);
00243
00244 maxSpeed = knots(30.0f);
00245 minSpeed = knots(0.0f);
00246 speedRange = maxSpeed - minSpeed + EPSILON;
00247
00248 maxAcceleration = feetPerSecondSquared(9.0f);
00249 maxRotationalSpeed = degreesPerSecond(0.5f);
00250 turningRadius = 100;
00251 mass = tons(1100);
00252
00253 selectable = true;
00254
00255 entityId.side = BLUE;
00256 }
00257 };
00258
00259 class Marauder : public Entity {
00260
00261 public:
00262
00263 Marauder(Engine *eng) : Entity(eng, MARAUDER) {
00264 meshName = "sleek.mesh";
00265 uiname = "Sleek.";
00266 uiname.append(boost::lexical_cast<std::string>(count++));
00267
00268
00269 length = meters(30.0f);
00270 width = meters(20.0f);
00271 height = meters(10.0f);
00272 maxSpeed = knots(40.0f);
00273 minSpeed = knots(0.0f);
00274 speedRange = maxSpeed - minSpeed + EPSILON;
00275
00276 maxAcceleration = feetPerSecondSquared(20.0f);
00277 maxRotationalSpeed = degreesPerSecond(1.5f);
00278 turningRadius = 10;
00279 mass = tons(75);
00280
00281 selectable = true;
00282
00283 entityId.side = BLUE;
00284
00285 }
00286 };
00287
00288 class Helion : public Entity {
00289
00290 public:
00291
00292 Helion(Engine *eng) : Entity(eng, HELLION) {
00293 meshName = "alienship.mesh";
00294 uiname = "AlienShip.";
00295 uiname.append(boost::lexical_cast<std::string>(count++));
00296
00297
00298 length = meters(5.0f);
00299 width = meters(2.0f);
00300 height = meters(5.0f);
00301 maxSpeed = knots(60.0f);
00302 minSpeed = knots(0.0f);
00303 speedRange = maxSpeed - minSpeed + EPSILON;
00304
00305 maxAcceleration = feetPerSecondSquared(20.0f);
00306 maxRotationalSpeed = degreesPerSecond(2.5f);
00307 turningRadius = 8;
00308 mass = tons(0.6);
00309
00310 selectable = true;
00311
00312 entityId.side = YELLOW;
00313
00314 }
00315 };
00316
00317
00318 class SCVehicle : public Entity {
00319
00320 public:
00321
00322 float mineralCount;
00323 float mineralOccupyTime;
00324 float maxMineralCount;
00325 float mineralGatherRate;
00326
00327 float gasCount;
00328 float gasOccupyTime;
00329 float maxGasCount;
00330 float gasGatherRate;
00331
00332 SCVehicle(Engine *eng) : Entity(eng, SCV) {
00333 meshName = "scv.mesh";
00334 uiname = "SpaceConstructionVehicle";
00335 uiname.append(boost::lexical_cast<std::string>(count++));
00336
00337
00338 length = meters(30.0f);
00339 width = meters(2.0f);
00340 height = meters(5.0f);
00341 maxSpeed = knots(20.0f);
00342 minSpeed = knots(0.0f);
00343 speedRange = maxSpeed - minSpeed + EPSILON;
00344 speed = 0.0f;
00345 desiredSpeed = 0.0f;
00346
00347 maxAcceleration = feetPerSecondSquared(20.0f);
00348 maxRotationalSpeed = degreesPerSecond(5.5f);
00349 turningRadius = 100;
00350 mass = tons(0.5);
00351
00352 selectable = true;
00353
00354 entityId.side = YELLOW;
00355
00356
00357 mineralCount = 0;
00358 maxMineralCount = 5;
00359 mineralOccupyTime = 2.786;
00360 mineralGatherRate = maxMineralCount/mineralOccupyTime;
00361
00362 gasCount = 0;
00363 maxGasCount = 4;
00364 gasOccupyTime = 1.981;
00365 gasGatherRate = maxGasCount/gasOccupyTime;
00366 }
00367 };
00368
00369
00370 }
00371
00372 #endif