本文整理汇总了C++中SpaceStation::GetSystemBody方法的典型用法代码示例。如果您正苦于以下问题:C++ SpaceStation::GetSystemBody方法的具体用法?C++ SpaceStation::GetSystemBody怎么用?C++ SpaceStation::GetSystemBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpaceStation
的用法示例。
在下文中一共展示了SpaceStation::GetSystemBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_space_spawn_ship_parked
/*
* Function: SpawnShipParked
*
* Create a ship and place it in one of the given <SpaceStation's> parking spots.
*
* > ship = Space.SpawnShipParked(type, station)
*
* For orbital stations the parking spots are some distance from the door, out
* of the path of ships entering and leaving the station. For group stations
* the parking spots are directly above the station, usually some distance
* away.
*
* Parameters:
*
* type - the name of the ship
*
* station - the <SpaceStation> to place the near
*
* Return:
*
* ship - a <Ship> object for the new ship, or nil if there was no space
* inside the station
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_space_spawn_ship_parked(lua_State *l)
{
if (!Pi::game)
luaL_error(l, "Game is not started");
LUA_DEBUG_START(l);
const char *type = luaL_checkstring(l, 1);
if (! ShipType::Get(type))
luaL_error(l, "Unknown ship type '%s'", type);
SpaceStation *station = LuaSpaceStation::CheckFromLua(2);
int slot;
if (!station->AllocateStaticSlot(slot))
return 0;
Ship *ship = new Ship(type);
assert(ship);
vector3d pos, vel;
matrix4x4d rot = matrix4x4d::Identity();
if (station->GetSystemBody()->type == SystemBody::TYPE_STARPORT_SURFACE) {
vel = vector3d(0.0);
// XXX on tiny planets eg asteroids force this to be larger so the
// are out of the docking path
pos = station->GetPosition() * 1.1;
station->GetRotMatrix(rot);
vector3d axis1, axis2;
axis1 = pos.Cross(vector3d(0.0,1.0,0.0));
axis2 = pos.Cross(axis1);
double ang = atan((140 + ship->GetLmrCollMesh()->GetBoundingRadius()) / pos.Length());
if (slot<2) ang = -ang;
vector3d axis = (slot == 0 || slot == 3) ? axis1 : axis2;
pos.ArbRotate(axis, ang);
}
else {
double dist = 100 + ship->GetLmrCollMesh()->GetBoundingRadius();
double xpos = (slot == 0 || slot == 3) ? -dist : dist;
double zpos = (slot == 0 || slot == 1) ? -dist : dist;
pos = vector3d(xpos,5000,zpos);
vel = vector3d(0.0);
rot.RotateX(M_PI/2);
}
ship->SetFrame(station->GetFrame());
ship->SetVelocity(vel);
ship->SetPosition(pos);
ship->SetRotMatrix(rot);
Pi::game->GetSpace()->AddBody(ship);
ship->AIHoldPosition();
LuaShip::PushToLua(ship);
LUA_DEBUG_END(l, 1);
return 1;
}