Google
Web alhem.net

Robot.h

Go to the documentation of this file.
00001 #ifndef _ROBOT_H
00002 #define _ROBOT_H
00003 
00004 #include <string>
00005 #include <map>
00006 #include "MapObject.h"
00007 #include "Radar.h"
00008 #include "Turret.h"
00009 #include "Gun.h"
00010 #include "Shields.h"
00011 #include "Life.h"
00012 #include "RobotXMLFile.h"
00013 #include "CodeTool.h"
00014 class Map;
00015 
00016 
00017 class Robot : public MapObject
00018 {
00019 public:
00020         Robot(Map& ,const std::string& xmlfile);
00021         ~Robot();
00022 
00024         bool IsOk() { return m_config.IsOk(); }
00025 
00026         mapobject_t GetType() { return MAPOBJECT_ROBOT; }
00027         // MapObject::get_property
00028         long get_property(const std::string& );
00029 
00030         void Tick(long usec);
00031         Life& PartLife() { return m_life; }
00032         Radar& PartRadar() { return m_radar; }
00033         Turret& PartTurret() { return m_turret; }
00034         Gun& PartGun() { return m_gun; }
00035         Shields& PartShields() { return m_shields; }
00036 
00037         long get_property(int);
00038         void set_property(int,long);
00039         long call_method(int,stack_v&);
00040 
00041         // language
00042         void Call(const std::string& method);
00043 
00044         // inventory
00045         void AddObject(MapObject *);
00046         mapobject_v& GetInventory() { return m_inventory; } // robot.inventory
00047 
00048         // power
00049         int GetPower() { return (int)((m_power_level * 100) / m_max_power_level); } // robot.power
00050         int GetPowerLevel() { return (int)m_power_level; }
00051         int GetMaxPowerLevel() { return m_max_power_level; }
00052         void SetMaxPowerLevel(int x) { m_max_power_level = x; }
00053         bool Charging() { return GetPowerLevel() < GetMaxPowerLevel(); } // robot.charging
00054         int GetChargeRate() { return m_charge_rate; }
00055         void SetChargeRate(int x) { m_charge_rate = x; }
00056         bool UsePower(double units); // decrease power level, returns false and calls OnOutOfPower if failed
00057 
00058         // turn
00059         int GetCurrentHeading() { return (int)m_current_heading; }
00060         void SetHeading(double x) { m_set_heading = x; }
00061         double GetTurnRate() { return m_turn_rate; }
00062         void SetTurnRate(double x) { m_turn_rate = x; }
00063 
00064 private:
00065         RobotXMLFile m_config;
00066         CodeTool *m_code;
00067         // parts
00068         Life m_life; // Robot life
00069         Radar m_radar;
00070         Turret m_turret;
00071         Gun m_gun;
00072         Shields m_shields;
00073         // inventory...
00074         mapobject_v m_inventory;
00075         // power: initial charge_rate 1000 units/sec
00076         double m_power_level;
00077         int m_max_power_level;
00078         int m_charge_rate; // units/s (1000+)
00079         // turn: 550 power/sec, 12 degrees/sec
00080         double m_current_heading;
00081         double m_set_heading;
00082         double m_turn_rate; // 12
00083 };
00084 
00085 
00086 #endif // _ROBOT_H

Generated for Robot World by doxygen 1.3.6

Page, code, and content Copyright (C) 2004 by Anders Hedström