本文整理汇总了C++中Ship::Mass方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::Mass方法的具体用法?C++ Ship::Mass怎么用?C++ Ship::Mass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::Mass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckLock
void Projectile::CheckLock(const Ship &target)
{
double base = hasLock ? 1. : .5;
hasLock = false;
// For each tracking type, calculate the probability that a lock will be
// lost in a given five-second period. Then, since this check is done every
// second, test against the fifth root of that probability.
if(weapon->Tracking())
hasLock |= Check(weapon->Tracking(), base);
// Optical tracking is about 15% for interceptors and 75% for medium warships.
if(weapon->OpticalTracking())
{
double weight = target.Mass() * target.Mass();
double probability = weapon->OpticalTracking() * weight / (200000. + weight);
hasLock |= Check(probability, base);
}
// Infrared tracking is 10% when heat is zero and 100% when heat is full.
if(weapon->InfraredTracking())
{
double probability = weapon->InfraredTracking() * min(1., target.Heat() + .1);
hasLock |= Check(probability, base);
}
// Radar tracking depends on whether the target ship has jamming capabilities.
// Jamming of 1 is enough to increase your chance of dodging to 50%.
if(weapon->RadarTracking())
{
double probability = weapon->RadarTracking() / (1. + target.Attributes().Get("radar jamming"));
hasLock |= Check(probability, base);
}
}
示例2: UpdateAttributes
void ShipInfoDisplay::UpdateAttributes(const Ship &ship)
{
bool isGeneric = ship.Name().empty() || ship.GetPlanet();
attributeLabels.clear();
attributeValues.clear();
attributesHeight = 20;
const Outfit &attributes = ship.Attributes();
attributeLabels.push_back("cost:");
attributeValues.push_back(Format::Number(ship.Cost()));
attributesHeight += 20;
attributeLabels.push_back(string());
attributeValues.push_back(string());
attributesHeight += 10;
if(attributes.Get("shield generation"))
{
attributeLabels.push_back("shields charge / max:");
attributeValues.push_back(Format::Number(60. * attributes.Get("shield generation"))
+ " / " + Format::Number(attributes.Get("shields")));
}
else
{
attributeLabels.push_back("shields:");
attributeValues.push_back(Format::Number(attributes.Get("shields")));
}
attributesHeight += 20;
if(attributes.Get("hull repair rate"))
{
attributeLabels.push_back("hull repair / max:");
attributeValues.push_back(Format::Number(60. * attributes.Get("hull repair rate"))
+ " / " + Format::Number(attributes.Get("hull")));
}
else
{
attributeLabels.push_back("hull:");
attributeValues.push_back(Format::Number(attributes.Get("hull")));
}
attributesHeight += 20;
double emptyMass = ship.Mass();
attributeLabels.push_back(isGeneric ? "mass with no cargo:" : "mass:");
attributeValues.push_back(Format::Number(emptyMass));
attributesHeight += 20;
attributeLabels.push_back(isGeneric ? "cargo space:" : "cargo:");
if(isGeneric)
attributeValues.push_back(Format::Number(attributes.Get("cargo space")));
else
attributeValues.push_back(Format::Number(ship.Cargo().Used())
+ " / " + Format::Number(attributes.Get("cargo space")));
attributesHeight += 20;
attributeLabels.push_back("required crew / bunks:");
attributeValues.push_back(Format::Number(ship.RequiredCrew())
+ " / " + Format::Number(attributes.Get("bunks")));
attributesHeight += 20;
attributeLabels.push_back(isGeneric ? "fuel capacity:" : "fuel:");
double fuelCapacity = attributes.Get("fuel capacity");
if(isGeneric)
attributeValues.push_back(Format::Number(fuelCapacity));
else
attributeValues.push_back(Format::Number(ship.Fuel() * fuelCapacity)
+ " / " + Format::Number(fuelCapacity));
attributesHeight += 20;
double fullMass = emptyMass + (isGeneric ? attributes.Get("cargo space") : ship.Cargo().Used());
isGeneric &= (fullMass != emptyMass);
attributeLabels.push_back(string());
attributeValues.push_back(string());
attributesHeight += 10;
attributeLabels.push_back(isGeneric ? "movement, full / no cargo:" : "movement:");
attributeValues.push_back(string());
attributesHeight += 20;
attributeLabels.push_back("max speed:");
attributeValues.push_back(Format::Number(60. * attributes.Get("thrust") / attributes.Get("drag")));
attributesHeight += 20;
attributeLabels.push_back("acceleration:");
if(!isGeneric)
attributeValues.push_back(Format::Number(3600. * attributes.Get("thrust") / fullMass));
else
attributeValues.push_back(Format::Number(3600. * attributes.Get("thrust") / fullMass)
+ " / " + Format::Number(3600. * attributes.Get("thrust") / emptyMass));
attributesHeight += 20;
attributeLabels.push_back("turning:");
if(!isGeneric)
attributeValues.push_back(Format::Number(60. * attributes.Get("turn") / fullMass));
else
attributeValues.push_back(Format::Number(60. * attributes.Get("turn") / fullMass)
+ " / " + Format::Number(60. * attributes.Get("turn") / emptyMass));
attributesHeight += 20;
// Find out how much outfit, engine, and weapon space the chassis has.
map<string, double> chassis;
static const string names[] = {
"outfit space free:", "outfit space",
" weapon capacity:", "weapon capacity",
" engine capacity:", "engine capacity",
"gun ports free:", "gun ports",
//.........这里部分代码省略.........