本文整理汇总了C++中Planet::IsSuperType方法的典型用法代码示例。如果您正苦于以下问题:C++ Planet::IsSuperType方法的具体用法?C++ Planet::IsSuperType怎么用?C++ Planet::IsSuperType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Planet
的用法示例。
在下文中一共展示了Planet::IsSuperType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StaticUpdate
void Ship::StaticUpdate(const float timeStep)
{
AITimeStep(timeStep); // moved to correct place, maybe
if (GetHullTemperature() > 1.0) {
Space::KillBody(this);
}
UpdateAlertState();
/* FUEL SCOOPING!!!!!!!!! */
if (m_equipment.Get(Equip::SLOT_FUELSCOOP) != Equip::NONE) {
Body *astro = GetFrame()->m_astroBody;
if (astro && astro->IsType(Object::PLANET)) {
Planet *p = static_cast<Planet*>(astro);
if (p->IsSuperType(SBody::SUPERTYPE_GAS_GIANT)) {
double dist = GetPosition().Length();
double pressure, density;
p->GetAtmosphericState(dist, &pressure, &density);
double speed = GetVelocity().Length();
vector3d vdir = GetVelocity().Normalized();
matrix4x4d rot;
GetRotMatrix(rot);
vector3d pdir = -vector3d(rot[8], rot[9], rot[10]).Normalized();
double dot = vdir.Dot(pdir);
if ((m_stats.free_capacity) && (dot > 0.95) && (speed > 2000.0) && (density > 1.0)) {
double rate = speed*density*0.00001f;
if (Pi::rng.Double() < rate) {
m_equipment.Add(Equip::HYDROGEN);
if (this == reinterpret_cast<Ship*>(Pi::player)) {
Pi::Message(stringf(Lang::FUEL_SCOOP_ACTIVE_N_TONNES_H_COLLECTED,
formatarg("quantity", m_equipment.Count(Equip::SLOT_CARGO, Equip::HYDROGEN))));
}
UpdateMass();
}
}
}
}
}
// Cargo bay life support
if (m_equipment.Get(Equip::SLOT_CARGOLIFESUPPORT) != Equip::CARGO_LIFE_SUPPORT) {
// Hull is pressure-sealed, it just doesn't provide
// temperature regulation and breathable atmosphere
// kill stuff roughly every 5 seconds
if ((!m_dockedWith) && (5.0*Pi::rng.Double() < timeStep)) {
Equip::Type t = (Pi::rng.Int32(2) ? Equip::LIVE_ANIMALS : Equip::SLAVES);
if (m_equipment.Remove(t, 1)) {
m_equipment.Add(Equip::FERTILIZER);
if (this == reinterpret_cast<Ship*>(Pi::player)) {
Pi::Message(Lang::CARGO_BAY_LIFE_SUPPORT_LOST);
}
}
}
}
if (m_flightState == FLYING)
m_launchLockTimeout -= timeStep;
if (m_launchLockTimeout < 0) m_launchLockTimeout = 0;
/* can't orient ships in SetDockedWith() because it gets
* called from collision handler, and collision system gets a bit
* weirded out if bodies are moved in the middle of collision detection
*/
if (m_dockedWith) m_dockedWith->OrientDockedShip(this, m_dockedWithPort);
// lasers
for (int i=0; i<ShipType::GUNMOUNT_MAX; i++) {
m_gunRecharge[i] -= timeStep;
float rateCooling = 0.01f;
if (m_equipment.Get(Equip::SLOT_LASERCOOLER) != Equip::NONE) {
rateCooling *= float(EquipType::types[ m_equipment.Get(Equip::SLOT_LASERCOOLER) ].pval);
}
m_gunTemperature[i] -= rateCooling*timeStep;
if (m_gunTemperature[i] < 0.0f) m_gunTemperature[i] = 0;
if (m_gunRecharge[i] < 0.0f) m_gunRecharge[i] = 0;
if (!m_gunState[i]) continue;
if (m_gunRecharge[i] > 0.0f) continue;
if (m_gunTemperature[i] > 1.0) continue;
FireWeapon(i);
}
if (m_ecmRecharge > 0.0f) {
m_ecmRecharge = std::max(0.0f, m_ecmRecharge - timeStep);
}
if (m_stats.shield_mass_left < m_stats.shield_mass) {
// 250 second recharge
float recharge_rate = 0.004f;
if (m_equipment.Get(Equip::SLOT_ENERGYBOOSTER) != Equip::NONE) {
recharge_rate *= float(EquipType::types[ m_equipment.Get(Equip::SLOT_ENERGYBOOSTER) ].pval);
}
m_stats.shield_mass_left += m_stats.shield_mass * recharge_rate * timeStep;
}
m_stats.shield_mass_left = Clamp(m_stats.shield_mass_left, 0.0f, m_stats.shield_mass);
//.........这里部分代码省略.........