Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
TShipDesign Class Reference
TShipDesign saves the properties of a ship design.
More...
#include <shipdesign.h>
Inheritance diagram for TShipDesign:
[legend]Collaboration diagram for TShipDesign:
[legend]List of all members.
Detailed Description
TShipDesign saves the properties of a ship design.
-
Author:
-
Ralf Laue
-
Version:
-
-
Id:
-
shipdesign.h,v 1.20 2002/04/25 22:21:13 prolator Exp
-
See also:
-
TItem
The class TShipDesign handles the attributes of a ship design like the cost, the equipment onboard or the name. Because it is derived from TLinkable it has its own unique ID. The basic values like mass, free volume and surface, hit points can be set simply with the "set" methods. The items (they are sub classes of TItem) are added to the ship design with addItem. You can also specify the quantity of items of one type. The method removeItem works similar, but it removes the items instead. If you want to get all items which are on board of the ship design you can get a list of all items by using the method getItemList. All "get" methods (beside for name and hit points) exist in two versions: one only returns the basic values of the fuselage; the other includes the values of the items. For example you can get the hull mass with getHullMass and the total mass of the ship design with getTotalMass.
If at least one subfleet exists you can't change the ship design with the set???? methods. You can only change the ship design, if no ships/subfleets exist. Whether you the ship design is changeable (if no ships exits) you can read out with the method isChangeable as bool value. The number of existing subfleets can be read out with the method getUsageNumber. Because the ship design get get the number of subfleets through its TLinkable heritage, you don't have to worry about setting this values.
With the method AbleToLand you can set a flag which determines whether an actual ship of the design is able to fly in an atmosphere and to land on a planet. The flag can be read with the method isAtmospheric. If the design is able to land on a planet the cost for the hull is inreased by a factor. This factor can be set and read with setAtmosphericFactor and getAtmosphericFactor. It is given as double number and the cost is increased by this factor (i.e. if the ship shall cost 125% of the normal prize, the factor has to be 0.25). If the flag is true and you set a new hull cost, the cost is automatically inreased by n%. For example the factor 0.25 and you set the cost to 100. Then the cost is automatically set to 125. If you then change the factor to 0.35, the cost is set to 135. Of course, if isChangeable is true
, then neither the factor nor the flag for landing can be changed. FIXME, perhaps it is wished to make the changes mor eflexible (i.e. the rule set can decide whether cost or volume are concerned. Then it has to be changed here.
Member Typedef Documentation
typedef TPList<TItemPack>::const_iterator TShipDesign::tEquipmentConstIterator
|
|
|
A const iterator for the TPList which contains the equipment |
|
An iterator for the TPList which contains the equipment |
Constructor & Destructor Documentation
TShipDesign::TShipDesign |
( |
|
) |
|
|
|
This constructor creates a new ship prototype with all the attributes reseted. That means all attributes like name, cost and so on have to be set afterwards. This will be used when the parser reads a new ship type out of the script files or a new ship type is created (not by the player) because of a new tech level. |
TShipDesign::TShipDesign |
( |
const TShipDesign & |
OldDesign |
) |
|
|
|
This constructor creates also a new ship prototype, but the attributes are copied from the TShipDesign given in OldDesign. This will be used when the player generates a new prototype derived from an earlier prototype -
Parameters:
-
OldDesign |
the design which shall be copied |
|
virtual TShipDesign::~TShipDesign |
( |
|
) |
[virtual] |
|
|
Destructs the object. It has to be called for destruction of the object, because it releases the memory used for the equipment list. |
Member Function Documentation
virtual void TShipDesign::AbleToLand |
( |
bool |
CanLand |
) |
[virtual] |
|
|
With the method AbleToLand you can set a flag which determines whether ships of this design are able to fly through an atmosphere and to land on a planet. If the flag is changed, the hull cost is changed by an factor which can be set with the method setAtmosphericFactor and can be read with the method getAtmosphericFactorfactor. If changed from true to false the hull cost is decreased by n% and if changed from false to true , it is increased by n%. -
Parameters:
-
CanLand |
value that determines whether ships of this desgin can fly through an atmosphere and land on planets |
|
virtual int2 TShipDesign::AddItem |
( |
TItem * |
Item, |
|
|
const int2 |
AddAmount = 1 |
|
) |
[virtual] |
|
|
The method AddItem adds a number of items to the ship design and returns the number of added items, if the flag fChangeable is true . If the ship design has not enough volume or surface to add all requested items, the method will add as many items as fit on the ship design and return this number. This can also mean that 0 is returned if there is not enough volume or surface free to add one item. If the items coludn't be added, because this type of items is not allowed -1 is returned. If the flag fChangeable is false the method doesn't alter the design and returns 0. FIXME: Until now, there are no constraints which equipment can be put on which ship/hull. If in future such constraints are planned, they could be implemented here. -
Parameters:
-
Item |
the Item which should be mounted in the slot |
iNewAmount |
the number of items to be added; the parameter has a default of 1, so if it is omitted, only one item is added |
-
Returns:
-
the number of items that were successfully added or -1 if the item was of the wrong type
|
virtual double TShipDesign::getAtmosphericFactor |
( |
|
) |
const [virtual] |
|
|
With the method getAtmosphericFactor you can read out the factor the hull cost is increased, if ships of this design can fly through atmospheres and land on planets. -
Returns:
-
the factor the cost shall be increased by
|
virtual void TShipDesign::getDesignCost |
( |
TSubstanceSet * |
ReturnCost |
) |
const [virtual] |
|
|
With the method getDesignCost you can get the cost for the complete ship design. The costs for components are included. This method will be used, when you want to know how much the whole design will cost. -
Parameters:
-
ReturnCost |
In this variable the hull cost is returned, any old value is deleted. |
|
virtual const string& TShipDesign::getDesignName |
( |
|
) |
const [virtual] |
|
|
With the method getShipDesign you can get the name of the ship design. -
Returns:
-
the name of the ship design
|
virtual int2 TShipDesign::getFreeSurface |
( |
|
) |
const [virtual] |
|
|
With the method getFreeSurface you can get the surface area which is still free for additional equipment on the outside of the ship design. The method will be used to check whether there still is surface area free for more equipment. -
Returns:
-
the free surface on the ship design
|
virtual int2 TShipDesign::getFreeVolume |
( |
|
) |
const [virtual] |
|
|
With the method getFreeVolume you can get the volume which is still free for additional equipment in the ship design. The method will be used to check whether there still is space free for more equipment. -
Returns:
-
the free volume in the ship design
|
virtual void TShipDesign::getHullCost |
( |
TSubstanceSet * |
ReturnCost |
) |
const [virtual] |
|
|
With the method getHullCost you can get the cost for the empty hull of the ship design. The costs for components are not included. The interface of this method is made this way to make it similar to getDesignCost. -
Parameters:
-
ReturnCost |
In this variable the hull cost is returned, any old value is deleted. |
|
virtual int4 TShipDesign::getHullMass |
( |
|
) |
const [virtual] |
|
|
With the method getHullMass you can get the mass of the empty hull. The mass of already installed equipment is not accounted for. -
Returns:
-
the mass of the empty hull.
|
int2 TShipDesign::getHullSurface |
( |
|
) |
const |
|
|
With the method getHullSurface you can get the surface area which is free for equipment on the outside of an empty hull. The Surface area which is used by already installed equipment is not acounted for. -
Returns:
-
the free surface on the empty hull
|
virtual int2 TShipDesign::getHullVolume |
( |
|
) |
const [virtual] |
|
|
With the method getHullVolume you can get the volume which is free for equipment in an empty hull. Volume of already installed eqipment is not accounted for. -
Returns:
-
the free volume in the empty hull
|
virtual void TShipDesign::getItemList |
( |
TPList< TItemPack > * |
ReturnList, |
|
|
const int2 |
ItemType = -1 |
|
) |
const [virtual] |
|
|
The method getItemList returns a list with the types and amounts of items. This list is of type TItemList and contains structs of type tItemPack. The list is returned in the paramter ReturnList. Any existing content in the ReturnList is deleted before returning it. The second paramter ItemType determines which items are returned. If the second parameter is omitted, a list with all items is returned. If not only items with the chosen type are returned. The type has to be given as values TItem::STLENGINE and similar (see TItem). You can also get two (or more) different item types if you use two (or more) constants combine with OR. IMPORTANT: The caller is responsible to delete the TItemPack objects the list has stored pointers to. This can for example be done with the method deleteAll from TPList. -
Parameters:
-
ReturnList |
In this list the items are returend and any old values are deleted. |
ItemType |
the type of items in the list; it has the default value of 0xFFFFFFFF, si if this parameter is ommited, all items will be returend in the list. |
|
virtual int2 TShipDesign::getMaxHullHP |
( |
|
) |
const [virtual] |
|
|
With the method getMaxHullHP you can get the aximum amount of hit points the hull can take before being destroyed. -
Returns:
-
the maximu hit points of the hull
|
virtual int4 TShipDesign::getTotalMass |
( |
|
) |
const [virtual] |
|
|
With the method getTotalMass you can get the summarized mass of the hull and all the components. This method will be used, if you want to calcilate the acceleration accroding to engine power and ship mass. -
Returns:
-
the mass of the ship.
|
virtual int2 TShipDesign::getType |
( |
|
) |
const [virtual] |
|
|
This method is inherited from TType and reimplemented here. I returns TType::SHIPDESIGN. -
Returns:
-
the type of the class, here: TType::SHIPDESIGN
-
See also:
-
TType
Reimplemented from TLinkable. |
virtual const string& TShipDesign::getTypeName |
( |
|
) |
const [virtual] |
|
|
This method is inherited from TType and reimplemented here. I returns "TShipDesign". -
Returns:
-
the name of the class, here "TShipDesign"
-
See also:
-
TType
Reimplemented from TLinkable. |
int4 TShipDesign::getUsageNumber |
( |
|
) |
const |
|
|
With the method getUsageNumber you can get the number of existing subfleets of this ship design. If there is at least one subfleet, you can't change the ship design; the set???? methods will have no effect. -
Returns:
-
the number of existing subfleets of this ship design.
-
See also:
-
isChangeable
|
virtual bool TShipDesign::isAtmospheric |
( |
|
) |
const [virtual] |
|
|
With the method isAtmospheric you can read out the flag which determines whether ships of this design can fly through an atmosphere and land on planets. -
Returns:
-
true if it can land on planets, false if not |
virtual bool TShipDesign::isChangeable |
( |
|
) |
const [virtual] |
|
|
With the method isChangeable you can read out whether the design can be changed or not. -
Returns:
-
Returns
true is the design can be changed and false if the design can't be changed. In the latter case no methods of TShipDesign will alter the ship design.
-
See also:
-
getUsageNumber
|
|
The method "load" loads a TShipDesign object from the data packages in the list. For more information look in the documentation of the ancestors of TShipDesign from where this method is inherited. -
Parameters:
-
in |
the list of data packages |
-
Returns:
-
true means that everything was loaded correctly, otherwise this method will return false .
-
See also:
-
TLinkable
Reimplemented from TLinkable. |
virtual TShipDesign& TShipDesign::operator= |
( |
const TShipDesign & |
Design |
) |
[virtual] |
|
|
This is the assignment operator for TShipDesign |
virtual int2 TShipDesign::RemoveItem |
( |
TItem * |
Item, |
|
|
const int2 |
RemoveAmount |
|
) |
[virtual] |
|
|
The method RemoveItem tries to remove RemoveAmount items from the ship design, if the flag fChangeable is true . If there are less item in the slot than should be removed, it removes all items of this type from the ship design. The number of removed items is returned by the method. If no item of this type was on the ship design the method does nothing and returns 0. If the flag fChangeable is false the method doesn't alter the design and returns 0.
-
Parameters:
-
RemoveAmount |
the number of items to be removed |
-
Returns:
-
the number of successfully removed items
|
|
The method "save" saves a TShipDesign by adding the data packages to the list. For more information look in the documentation of the ancestors of TShipDesign, because the method Save is inherited from there. -
Parameters:
-
out |
the output stream of data packages |
-
Returns:
-
true means that everything was saved correctly, otherwise this method will return false .
-
See also:
-
TLinkable
Reimplemented from TLinkable. |
virtual void TShipDesign::setAtmosphericFactor |
( |
double |
Factor |
) |
[virtual] |
|
|
With the method setAtmosphericFactor you can set the factor the hull cost is increased, if ships of this design can fly through atmospheres and land on planets. The cost is increased by the factor, that means if oyu want to cost the design 125% of the normal cost, the factor has to be 0.25. If the design is already able to land on planets, the cost is adjusted to the new factor. -
Parameters:
-
Factor |
the new factor the cost shall be increased by |
|
virtual void TShipDesign::setDesignName |
( |
const string & |
Name |
) |
[virtual] |
|
|
With the method setDesignName you can set the name of the ship design if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
Parameters:
-
Name |
The new name for the ship design. |
|
virtual void TShipDesign::setHullCost |
( |
const TSubstanceSet & |
HullCost |
) |
[virtual] |
|
|
With the method setHullCost you can set the cost for the empty hull of the ship design, if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
Parameters:
-
HullCost |
the new cost for the hull |
|
virtual void TShipDesign::setHullMass |
( |
const int4 |
Mass |
) |
[virtual] |
|
|
With the method setHullMass you can set the mass of the empty hull, if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
amter Mass the new mass of the empty hull.
-
|
virtual void TShipDesign::setHullSurface |
( |
const int2 |
Surface |
) |
[virtual] |
|
|
With the method setSurface you can set the surface area which is free for equipment on the outside of an empty hull, if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
Parameters:
-
Surface |
the new free surface on the empty hull |
|
virtual void TShipDesign::setHullVolume |
( |
const int2 |
Volume |
) |
[virtual] |
|
|
With the method setVolume you can set the volume which is free for equipment in an empty hull, if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
Parameters:
-
Volume |
the new free volume in the empty hull |
|
virtual void TShipDesign::setMaxHullHP |
( |
const int2 |
HitPoints |
) |
[virtual] |
|
|
With the method setMaxHullHP you can set the maximum amount of hit points the hull can take, before it is destroyed, if the flag fChangeable is true . If the flag fChangeable is false this method has no effect. -
Parameters:
-
HitPoints |
the amount of hit points for the hull |
|
Member Data Documentation
bool TShipDesign::fAtmospheric [private]
|
|
|
the flag which determines whether ship of this design can land on planets or fly through atmospheres |
double TShipDesign::fAtmosphericFactor [private]
|
|
|
the factor the hull cost are increased if it can on planets |
string TShipDesign::fDesignName [private]
|
|
|
the name of the ship design |
|
the container with the installed equipment |
int4 TShipDesign::fHullMass [private]
|
|
|
the mass of the empty hull |
int4 TShipDesign::fHullSurface [private]
|
|
|
the free surface area on the outside of an empty hull |
int4 TShipDesign::fHullVolume [private]
|
|
|
the free volume in an empty hull |
int4 TShipDesign::fMaxHullHP [private]
|
|
|
the amount of hit point the hull can take before being destroyed |
The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:34 2002 for Stellar Legacy by
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001