本文整理汇总了C++中Ship::ResetFlavour方法的典型用法代码示例。如果您正苦于以下问题:C++ Ship::ResetFlavour方法的具体用法?C++ Ship::ResetFlavour怎么用?C++ Ship::ResetFlavour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ship
的用法示例。
在下文中一共展示了Ship::ResetFlavour方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoLawAndOrder
void SpaceStation::DoLawAndOrder()
{
Sint64 fine, crimeBitset;
Polit::GetCrime(&crimeBitset, &fine);
bool isDocked = static_cast<Ship*>(Pi::player)->GetDockedWith() ? true : false;
if (Pi::player->GetFlightState() != Ship::DOCKED
&& m_numPoliceDocked
&& (fine > 1000)
&& (GetPositionRelTo(static_cast<Body*>(Pi::player)).Length() < 100000.0)) {
int port = GetFreeDockingPort();
if (port != -1) {
m_numPoliceDocked--;
// Make police ship intent on killing the player
Ship *ship = new Ship(ShipType::LADYBIRD);
ship->AIKill(Pi::player);
ship->SetFrame(GetFrame());
ship->SetDockedWith(this, port);
Space::AddBody(ship);
{ // blue and white thang
ShipFlavour f;
f.type = ShipType::LADYBIRD;
strncpy(f.regid, "POLICE", 16);
f.price = ship->GetFlavour()->price;
LmrMaterial m;
m.diffuse[0] = 0.0f; m.diffuse[1] = 0.0f; m.diffuse[2] = 1.0f; m.diffuse[3] = 1.0f;
m.specular[0] = 0.0f; m.specular[1] = 0.0f; m.specular[2] = 1.0f; m.specular[3] = 1.0f;
m.emissive[0] = 0.0f; m.emissive[1] = 0.0f; m.emissive[2] = 0.0f; m.emissive[3] = 0.0f;
m.shininess = 50.0f;
f.primaryColor = m;
m.shininess = 0.0f;
m.diffuse[0] = 1.0f; m.diffuse[1] = 1.0f; m.diffuse[2] = 1.0f; m.diffuse[3] = 1.0f;
f.secondaryColor = m;
ship->ResetFlavour(&f);
}
ship->m_equipment.Set(Equip::SLOT_LASER, 0, Equip::PULSECANNON_DUAL_1MW);
ship->m_equipment.Add(Equip::SHIELD_GENERATOR);
ship->m_equipment.Add(Equip::LASER_COOLING_BOOSTER);
ship->m_equipment.Add(Equip::ATMOSPHERIC_SHIELDING);
ship->UpdateMass();
}
}
}
示例2: l_ship_set_type
/* Method: SetShipType
*
* Replaces the ship with a new ship of the specified type.
*
* > ship:SetShipType(newtype)
*
* Parameters:
*
* newtype - the name of the ship
*
* Example:
*
* > ship:SetShipType('sirius_interdictor')
*
* Availability:
*
* alpha 15
*
* Status:
*
* experimental
*/
static int l_ship_set_type(lua_State *l)
{
LUA_DEBUG_START(l);
Ship *s = LuaObject<Ship>::CheckFromLua(1);
const char *type = luaL_checkstring(l, 2);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
ShipFlavour f(type);
s->ResetFlavour(&f);
s->m_equipment.Set(Equip::SLOT_ENGINE, 0, ShipType::types[f.id].hyperdrive);
s->UpdateStats();
LUA_DEBUG_END(l, 0);
return 0;
}
示例3: DoLawAndOrder
// XXX this whole thing should be done by Lua
void SpaceStation::DoLawAndOrder(const double timeStep)
{
Sint64 fine, crimeBitset;
Polit::GetCrime(&crimeBitset, &fine);
if (Pi::player->GetFlightState() != Ship::DOCKED
&& m_numPoliceDocked
&& (fine > 1000)
&& (GetPositionRelTo(Pi::player).Length() < 100000.0)) {
int port = GetFreeDockingPort();
// at 60 Hz updates (ie, 1x time acceleration),
// this spawns a police ship with probability ~0.83% each frame
// This makes it unlikely (but not impossible) that police will spawn on top of each other
// the expected number of game-time seconds between spawns: 120 (2*60 Hz)
// variance is quite high though
if (port != -1 && 2.0*Pi::rng.Double() < timeStep) {
m_numPoliceDocked--;
// Make police ship intent on killing the player
Ship *ship = new Ship(ShipType::POLICE);
ship->AIKill(Pi::player);
ship->SetFrame(GetFrame());
ship->SetDockedWith(this, port);
Pi::game->GetSpace()->AddBody(ship);
{
ShipFlavour f;
f.id = ShipType::POLICE;
f.regid = Lang::POLICE_SHIP_REGISTRATION;
f.price = ship->GetFlavour()->price;
ship->ResetFlavour(&f);
}
ship->m_equipment.Set(Equip::SLOT_LASER, 0, Equip::PULSECANNON_DUAL_1MW);
ship->m_equipment.Add(Equip::LASER_COOLING_BOOSTER);
ship->m_equipment.Add(Equip::ATMOSPHERIC_SHIELDING);
ship->UpdateStats();
}
}
}