From: <eg...@us...> - 2007-05-20 16:19:34
|
Revision: 489 http://svn.sourceforge.net/opengate/?rev=489&view=rev Author: egore Date: 2007-05-20 09:19:27 -0700 (Sun, 20 May 2007) Log Message: ----------- Add a few equipment parts that can be plugged into a vessel Add a generic stucture that all objects (after loading them from XML files) end in Modified Paths: -------------- branches/ogsector/src/VesselManager.h Added Paths: ----------- branches/ogsector/src/Entity.cpp branches/ogsector/src/Entity.h Added: branches/ogsector/src/Entity.cpp =================================================================== --- branches/ogsector/src/Entity.cpp (rev 0) +++ branches/ogsector/src/Entity.cpp 2007-05-20 16:19:27 UTC (rev 489) @@ -0,0 +1,22 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * eg...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "Entity.h" + Property changes on: branches/ogsector/src/Entity.cpp ___________________________________________________________________ Name: svn:mime-type + text/x-c++src Name: svn:eol-style + native Added: branches/ogsector/src/Entity.h =================================================================== --- branches/ogsector/src/Entity.h (rev 0) +++ branches/ogsector/src/Entity.h 2007-05-20 16:19:27 UTC (rev 489) @@ -0,0 +1,232 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by OpenGate development team * + * eg...@us... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _OPENGATE_ENTITY_H +#define _OPENGATE_ENTITY_H + +namespace OpenGate{ + +class Commodity; + +/*! + * \brief This class definies the basic structure of all entity templates. + * + * Opengate is able to load information about so called entities from XML files. + * These information are loaded into so called templates. These aren't "real" + * entities, but it's like a blueprint to construct an entity from. Every entity + * in Opengate is a child of this base entity template. + * \author Christoph Brill <eg...@us...> + */ +class EntityTemplate{ +public: + + inline void setFactionName( const std::string & name ) { factionName_ = name; } + inline std::string factionName( ) const { return factionName_; } + + inline void setName( const std::string & name ) { name_ = name; } + inline std::string name( ) const { return name_; } + + inline void setClassName( const std::string & name ) { className_ = name; } + inline std::string className( ) const { return className_; } + + inline void setTechLevel( int level ){ techLevel_ = level; } + inline int techLevel( ) const { return techLevel_; } + + inline void setMass( long mass ){ mass_ = mass; } + inline long mass( ) const { return mass_; } + +protected: + + EntityTemplate(): factionName_( "unknown" ), name_( "unknown" ), className_( "unknown" ) { + techLevel_ = 0; + mass_ = 0; + } + + std::string factionName_; + + std::string name_; + + std::string className_; + + int techLevel_; + /*! The mass of this entity. */ + long mass_; + +}; + +/** + * \brief This abstract class defines the basics for Eqiupment that is plugged + * into a vessel. + * + * So if you plug in an engine (which is a child class of this) you plug in an + * equipment part. It has power consumption, a size, etc. This class only + * defines whatever is common for all equipments parts (i.e. size). + * + * \author Christoph Brill <eg...@us...> + */ +class EquipmentTemplate : public EntityTemplate{ +public: + + inline void setSize( short size ){ size_ = size; } + inline short size( ) const { return size_; } + +protected: + EquipmentTemplate(): EntityTemplate() { + size_ = 0; + } + + std::string _description; + // TODO: Company* _manufacturer; + // TODO: std::vector<char*> _productioncenter; + + /*! The amount of slots necessary to plug in such a device. */ + short size_; + + std::vector<Commodity> _requierd_component[]; + +}; + +/*! + * \brief This class stores the basical information of a capactitor + * + * This class, like all other equipment classes, is filled by loading the + * information from an XML file. It defines the details for a capacitor, which + * is a component that is plugged into the ship. + * \author Christoph Brill <eg...@us...> + */ +class Capacitor : public EquipmentTemplate{ +public: + + Capacitor(): EquipmentTemplate() { + efficiency_ = 0; + capacity_ = 0; + } + + inline void setEfficiency( long efficiency ) { efficiency_ = efficiency; } + inline long efficiency( ) { return efficiency_; } + + inline void setCapacity( long capacity ) { capacity_ = capacity; } + inline long capacity( ) { return capacity_; } + +private: + /*! Stores the efficiency of a capacitor */ + long efficiency_; + /*! Stores the capacity of a capacitor */ + long capacity_; +}; + +/*! + * \brief This class stores the basical information of an ECM (Evasion and Counter Measures) + * + * This class, like all other equipment classes, is filled by loading the + * information from an XML file. It defines the details for a ECM, which + * is a component that is plugged into the ship. + * \author Christoph Brill <eg...@us...> + */ +class ECM : public EquipmentTemplate{ +public: + + ECM(): EquipmentTemplate() { + sensorLevel_ = 0; + powerConsumption_ = 0; + } + + inline void setSensorLevel( short sensorLevel ) { sensorLevel_ = sensorLevel; } + inline short sensorLevel( ) { return sensorLevel_; } + + inline void setPowerConsumption( long powerConsumption ) { powerConsumption_ = powerConsumption; } + inline long powerConsumption( ) { return powerConsumption_; } + +private: + /*! Stores the sensorlevel of this ECM */ + short sensorLevel_; + /*! Stores the power consumption of this ECM */ + long powerConsumption_; +}; + +/*! + * \brief This class stores the basical information of an engine + * + * This class, like all other equipment classes, is filled by loading the + * information from an XML file. It defines the details for an engine, which + * is a component that is plugged into the ship. + * \author Christoph Brill <eg...@us...> + */ +class Engine : public EquipmentTemplate { +public: + + Engine(): EquipmentTemplate() { + efficiency_ = 0.0; + maxThrust_ = 0; + } + + inline void setEfficiency( double efficiency ) { efficiency_ = efficiency; } + inline double efficiency( ) { return efficiency_; } + + inline void setMaxThrust( long maxThrust ) { maxThrust_ = maxThrust; } + inline long maxThrust( ) { return maxThrust_; } + +private: + /*! Stores the efficiency of this engine */ + double efficiency_; + /*! Stores the maximum thrust of this engine */ + long maxThrust_; +}; + +/*! + * \brief This class defines a commodity (goods, ore, etc. to build stuff from) + * + * This class is handled like equipment. But since it's not plugable into a + * ship it's a seperate class. This stores some information about a commodity, + * like its mass, its melting point, etc. + * \author Christoph Brill <eg...@us...> + */ +class Commodity : public EntityTemplate{ +public: + + Commodity(): EntityTemplate(), id_( "unknown" ) { + meltingPoint_ = 0; + graviticSig_ = 0.0; + } + + inline void setProductionCenters( const std::vector<std::string> & productionCenter ) { productionCenter_ = productionCenter; } + inline std::vector<std::string> productionCenters( ) const { return productionCenter_; } + + inline void setId( const std::string & id ) { id_ = id; } + inline std::string id( ) const { return id_; } + + inline void setMeltingPoint( int meltingPoint ){ meltingPoint_ = meltingPoint; } + inline int meltingPoint( ) const { return meltingPoint_; } + + inline void setGraviticSig( double graviticSig ){ graviticSig_ = graviticSig; } + inline double graviticSig( ) const { return graviticSig_; } + +protected: + std::vector<std::string> productionCenter_; + std::string id_; + + int meltingPoint_; + double graviticSig_; +}; + +} // namespace OpenGate + +#endif //_OPENGATE_ENTITY_H + Property changes on: branches/ogsector/src/Entity.h ___________________________________________________________________ Name: svn:mime-type + text/x-c++hdr Name: svn:eol-style + native Modified: branches/ogsector/src/VesselManager.h =================================================================== --- branches/ogsector/src/VesselManager.h 2007-05-20 14:56:59 UTC (rev 488) +++ branches/ogsector/src/VesselManager.h 2007-05-20 16:19:27 UTC (rev 489) @@ -28,6 +28,7 @@ #include <map> #include "LogManager.h" +#include "Entity.h" namespace OpenGate{ @@ -49,17 +50,15 @@ * vessel. * \author Carsten <spo...@us...> */ -class Vessel{ +class Vessel : public EntityTemplate{ public: /*! Constructor creating a dummy vessel */ - Vessel(): factionName_( "unknown" ), name_( "unknown" ), className_( "unknown" ){ + Vessel(): EntityTemplate(){ vesselID_ = 0; - techLevel_ = 0; vesselSize_ = 10.0; - vesselMass_ = 1.0; vesselArmor_ = 1.0; vesselYaw_ = 0; @@ -86,30 +85,15 @@ /*! Desctructor */ ~Vessel(){} - inline void setFactionName( const std::string & name ) { factionName_ = name; } - inline std::string factionName( ) const { return factionName_; } - - inline void setName( const std::string & name ) { name_ = name; } - inline std::string name( ) const { return name_; } - - inline void setClassName( const std::string & name ) { className_ = name; } - inline std::string className( ) const { return className_; } - inline void setVesselID( int id ){ vesselID_ = id; } inline int vesselID( ) const { return vesselID_; } - inline void setTechLevel( int level ){ techLevel_ = level; } - inline int techLevel( ) const { return techLevel_; } - inline void setBaseSize( float vesselSize ){ vesselSize_ = vesselSize; } inline float baseSize( ) const { return vesselSize_; } inline void setBaseYaw( float vesselYaw ){ vesselYaw_ = vesselYaw; } inline float baseYaw( ) const { return vesselYaw_; } - inline void setMass( float vesselMass ){ vesselMass_ = vesselMass; } - inline float mass( ) const { return vesselMass_; } - inline void setArmor( float vesselArmor ){ vesselArmor_ = vesselArmor; } inline float armor( ) const { return vesselArmor_; } @@ -177,14 +161,9 @@ Ogre::MeshPtr & meshPtr( ){ return pMesh_; } protected: - std::string factionName_; - std::string name_; - std::string className_; - int techLevel_; int vesselID_; float vesselSize_; - float vesselMass_; float vesselArmor_; float vesselYaw_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |