D:/simple_rts/include/TeamUnits.h

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <vector>
00004 using std::vector;
00005 
00006 #include "OgreVector3.h"
00007 #include "OgreSceneNode.h"
00008 #include "OgreString.h"
00009 #include "OgreIteratorWrappers.h"
00010 
00011 using Ogre::Vector3;
00012 using Ogre::VectorIterator;
00013 using Ogre::SceneNode;
00014 using Ogre::String;
00015 using Ogre::RaySceneQuery;
00016 
00017 
00018 // ----------------------------------------------------------------------------
00019 namespace ASR
00020 {
00021         class Unit;
00022         class UnitList;
00023         class Team;
00024 
00025         // TODO
00026         //      Refactor into a TeamObjects templated class
00027 
00028         // ----------------------------------------------------------------------------
00029         class TeamUnits
00030         {
00031         // Data Types
00032         // ----------------------------------------------------------------------------
00033         public:
00034                 typedef vector<Unit*>                           UnitList;
00035                 typedef VectorIterator<UnitList>        UnitIterator;
00036 
00037         // Data Storage
00038         // ----------------------------------------------------------------------------
00039         private:
00040                 SceneNode*                                      mTeamNode;
00041                 RaySceneQuery*                          mRaySceneQuery;
00042 
00043                 UnitList                                        mUnits;
00044 
00045                 static int                                      mNumTeams;
00046                 Team*                                           mTeam;
00047 
00048 
00049         // Spatial Unit Management Data
00050         // ----------------------------------------------------------------------------
00051         private:
00052                 typedef vector <UnitList>                       SpatialColumn;
00053                 typedef vector <SpatialColumn>          SpatialGrid;
00054                 SpatialGrid                                                     mUnitGrid;
00055 
00056 
00057         // Construction
00058         // ----------------------------------------------------------------------------
00059         public:
00060                 TeamUnits ( Team* parentTeam, unsigned int initialUnits = 0 );
00061                 ~TeamUnits ();
00062 
00063 
00064         // Combat
00065         // ----------------------------------------------------------------------------
00066         public:
00067                 void findTargets ();
00068 
00069 
00070         // List Maintenance
00071         // ----------------------------------------------------------------------------
00072         public:
00073                 Unit* createUnit ( String meshName );
00074                 void moveUnits ( float deltaTime );
00075                 void animateUnits ( float deltaTime );
00076 
00077                 UnitIterator getUnitIterator ();
00078                 Unit* getUnit ( size_t index );
00079                 size_t getNumUnits ();
00080 
00081 
00082         // Battle System
00083         // ----------------------------------------------------------------------------
00084         public:
00085                 void performAttacks ();
00086 
00087 
00088         // Spatial Management
00089         // ----------------------------------------------------------------------------
00090         public:
00091                 void setSpatialGridSize ( int numBucketsWide, int numBucketsHigh );
00092 
00099                 UnitList getAdjacentUnits ( const Vector3& worldPos, float radius );
00100 
00104                 void updateSpatialGrid ();
00105 
00106         private:
00110                 void _clearSpatialGrid ();
00111         };
00112 }

Generated on Sun Jun 25 19:23:43 2006 for Valors End by  doxygen 1.4.7