NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
GridMover.h
Go to the documentation of this file.
00001 
00011 #pragma once
00012 
00013 // Standard Includes
00014 #include <map>
00015 #include <string>
00016 #include <vector>
00017 
00018 // Library Includes
00019 
00020 // Local Includes
00021 #include "../../sharedbase/PointList.h"
00022 #include "../InterfaceUpdateable.h"
00023 #include "../../sharedbase/Envelope_fwd.h"
00024 
00025 // Forward Declarations
00026 class InterfaceUpdateable;
00027 class ModuleInterface;
00028 class Entity;
00029 class MessageRouter;
00030 
00031 // Typedefs
00032 
00033 // Constants
00034 
00035 // Classes
00036 namespace Physics {
00037   namespace TIMING {
00038     const unsigned int POINT_ENTER = 0;
00039     const unsigned int POINT_LEAVE = 1; 
00040   }
00041 
00042   struct HandlerData {
00043     std::string name;
00044     std::string type;
00045     std::string data;
00046   };
00047 
00048   class GridMover : public InterfaceUpdateable {
00049   public:
00050     GridMover(EntitySPTR owner, ModuleInterface* module, MessageRouter* msgrtr);
00051 
00052     ~GridMover();
00053 
00054     bool SetMovementScale(unsigned int size); // Sets the scale applied to the owner's location each update
00055     void AddPointActionHandler(unsigned int timing, unsigned int actionhandler); // Register the point action handler for a given timing
00056     void RemovePointActionHandler(unsigned int timing); // Removes the point action handler for a given timing
00057     bool LoadObjectData(EnvelopeSPTR data);
00058     bool SetPath(PointList* points); // Sets the current path to follow.
00059     void Update(double dt);
00060     
00061     void ActionComplete(EnvelopeSPTR env);
00062 
00063     bool SetPauseDelay(float d);
00064 
00065   private:
00066     unsigned int scale;
00067 
00068     Point currentPoint;
00069     Point nextPoint;
00070     PointList* path; // Stores the current path. We are storing a reference to it, so any change to the original list, is also reflected here.
00071     std::map< unsigned int, unsigned int > actionHandlers; // Point action handlers for a given timing (timing, actionahandler)
00072     std::map< Point, HandlerData > pointHandlerdata; // Stores the extra handler data for a given point
00073 
00074     bool preaction; // Waiting on the preaction to complete
00075     bool postaction; // Waiting on the postaction to complete
00076 
00077     MessageRouter* msgrouter;
00078 
00079     float pauseDelay; // Stores the time to pause on each point
00080     float currentDelay;  // Counter for the current delay
00081   };
00082 }