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
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
00099
00100 bool isSelected;
00101 bool selectable;
00102
00103
00104
00105
00106
00107
00108
00109 private:
00110 void reset();
00111
00112
00113 public:
00114 Entity(Engine *eng, EntityType entType) ;
00115
00116 virtual void init();
00117
00118 UnitAspect *getAspect(UnitAspectType i);
00119 void removeAspect(UnitAspectType i);
00120 void addAspect(UnitAspect* asp);
00121 void switchState(EntityState newState);
00122
00123 virtual void print();
00124 virtual void tick(double dt);
00125
00126
00127
00128
00129 virtual void gestatingTick(double dt);
00130 virtual void aliveTick(double dt);
00131 virtual void dyingTick(double dt);
00132 virtual void deadTick(double dt);
00133
00134 virtual bool raising(double dt);
00135 virtual bool sinking(double dt);
00136
00137 };
00138
00139
00140 class Marine : public Entity {
00141
00142 public:
00143
00144 Marine(Engine *eng) : Entity(eng, MARINE) {
00145 meshName = "cigarette.mesh";
00146 uiname = "Cigarette.";
00147 uiname.append(boost::lexical_cast<std::string>(count++));
00148
00149
00150
00151 length = meters(20.0f);
00152 width = meters(4.0f);
00153 height = meters(6.0f);
00154
00155 maxSpeed = knots(45.0f);
00156 minSpeed = knots(0.0f);
00157 speedRange = maxSpeed - minSpeed + EPSILON;
00158 maxAcceleration = feetPerSecondSquared(15.0f);
00159 maxRotationalSpeed = degreesPerSecond(6.5f);
00160 turningRadius = 10;
00161 mass = pounds(1100);
00162
00163 selectable = true;
00164
00165 entityId.side = RED;
00166
00167 }
00168 };
00169
00170 class Reaper : public Entity {
00171
00172 public:
00173
00174 Reaper(Engine *eng) : Entity(eng, REAPER) {
00175 meshName = "boat.mesh";
00176 uiname = "SpeedBoat.";
00177 uiname.append(boost::lexical_cast<std::string>(count++));
00178
00179
00180
00181 length = 10.0f;
00182 width = 4.0f;
00183 height = 6.0f;
00184 maxSpeed = knots(40.0f);
00185 minSpeed = knots(0.0f);
00186 speedRange = maxSpeed - minSpeed + EPSILON;
00187 maxAcceleration = 20.0f;
00188 maxRotationalSpeed = 2.5f;
00189 turningRadius = 10;
00190 mass = pounds(1100);
00191
00192 selectable = true;
00193
00194 entityId.side = RED;
00195
00196 }
00197 };
00198
00199 class Tank : public Entity {
00200
00201 public:
00202
00203 Tank(Engine *eng) : Entity(eng, TANK) {
00204 meshName = "ddg51.mesh";
00205 uiname = "DDG51.";
00206 uiname.append(boost::lexical_cast<std::string>(count++));
00207
00208
00209 length = feet(466.0f);
00210 width = feet(59.0f);
00211 height = feet(100.0f);
00212 maxSpeed = knots(30.0f);
00213 minSpeed = knots(0.0f);
00214 speedRange = maxSpeed - minSpeed + EPSILON;
00215 maxAcceleration = feetPerSecondSquared(10.0f);
00216 maxRotationalSpeed = degreesPerSecond(1.0f);
00217 turningRadius = 750;
00218 mass = tons(842);
00219
00220 selectable = true;
00221
00222 entityId.side = BLUE;
00223
00224
00225 }
00226 };
00227
00228
00229 class Thor : public Entity {
00230
00231 public:
00232
00233 Thor(Engine *eng) : Entity(eng, THOR) {
00234 meshName = "cvn68.mesh";
00235 uiname = "CVN68.";
00236 uiname.append(boost::lexical_cast<std::string>(count++));
00237
00238
00239 length = meters(332.0f);
00240 width = meters(200.0f);
00241 height = meters(100.0f);
00242
00243 maxSpeed = knots(30.0f);
00244 minSpeed = knots(0.0f);
00245 speedRange = maxSpeed - minSpeed + EPSILON;
00246
00247 maxAcceleration = feetPerSecondSquared(9.0f);
00248 maxRotationalSpeed = degreesPerSecond(0.5f);
00249 turningRadius = 100;
00250 mass = tons(1100);
00251
00252 selectable = true;
00253
00254 entityId.side = BLUE;
00255 }
00256 };
00257
00258 class Marauder : public Entity {
00259
00260 public:
00261
00262 Marauder(Engine *eng) : Entity(eng, MARAUDER) {
00263 meshName = "sleek.mesh";
00264 uiname = "Sleek.";
00265 uiname.append(boost::lexical_cast<std::string>(count++));
00266
00267
00268 length = meters(30.0f);
00269 width = meters(20.0f);
00270 height = meters(10.0f);
00271 maxSpeed = knots(40.0f);
00272 minSpeed = knots(0.0f);
00273 speedRange = maxSpeed - minSpeed + EPSILON;
00274
00275 maxAcceleration = feetPerSecondSquared(20.0f);
00276 maxRotationalSpeed = degreesPerSecond(1.5f);
00277 turningRadius = 10;
00278 mass = tons(75);
00279
00280 selectable = true;
00281
00282 entityId.side = BLUE;
00283
00284 }
00285 };
00286
00287 class Helion : public Entity {
00288
00289 public:
00290
00291 Helion(Engine *eng) : Entity(eng, HELLION) {
00292 meshName = "alienship.mesh";
00293 uiname = "AlienShip.";
00294 uiname.append(boost::lexical_cast<std::string>(count++));
00295
00296
00297 length = meters(5.0f);
00298 width = meters(2.0f);
00299 height = meters(5.0f);
00300 maxSpeed = knots(60.0f);
00301 minSpeed = knots(0.0f);
00302 speedRange = maxSpeed - minSpeed + EPSILON;
00303
00304 maxAcceleration = feetPerSecondSquared(20.0f);
00305 maxRotationalSpeed = degreesPerSecond(2.5f);
00306 turningRadius = 8;
00307 mass = tons(0.6);
00308
00309 selectable = true;
00310
00311 entityId.side = YELLOW;
00312
00313 }
00314 };
00315
00316
00317 class SCVehicle : public Entity {
00318
00319 public:
00320
00321 float mineralCount;
00322 float mineralOccupyTime;
00323 float maxMineralCount;
00324 float mineralGatherRate;
00325
00326 float gasCount;
00327 float gasOccupyTime;
00328 float maxGasCount;
00329 float gasGatherRate;
00330
00331 SCVehicle(Engine *eng) : Entity(eng, SCV) {
00332 meshName = "scv.mesh";
00333 uiname = "SpaceConstructionVehicle";
00334 uiname.append(boost::lexical_cast<std::string>(count++));
00335
00336
00337 length = meters(30.0f);
00338 width = meters(2.0f);
00339 height = meters(5.0f);
00340 maxSpeed = knots(20.0f);
00341 minSpeed = knots(0.0f);
00342 speedRange = maxSpeed - minSpeed + EPSILON;
00343 speed = 0.0f;
00344 desiredSpeed = 0.0f;
00345
00346 maxAcceleration = feetPerSecondSquared(20.0f);
00347 maxRotationalSpeed = degreesPerSecond(5.5f);
00348 turningRadius = 100;
00349 mass = tons(0.5);
00350
00351 selectable = true;
00352
00353 entityId.side = YELLOW;
00354
00355
00356 mineralCount = 0;
00357 maxMineralCount = 5;
00358 mineralOccupyTime = 2.786;
00359 mineralGatherRate = maxMineralCount/mineralOccupyTime;
00360
00361 gasCount = 0;
00362 maxGasCount = 4;
00363 gasOccupyTime = 1.981;
00364 gasGatherRate = maxGasCount/gasOccupyTime;
00365 }
00366 };
00367
00368
00369 }
00370
00371 #endif