本文整理汇总了C++中SystemPath::IsSameSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemPath::IsSameSystem方法的具体用法?C++ SystemPath::IsSameSystem怎么用?C++ SystemPath::IsSameSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemPath
的用法示例。
在下文中一共展示了SystemPath::IsSameSystem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateIconSelections
void SystemInfoView::UpdateIconSelections()
{
m_selectedBodyPath = SystemPath();
for (auto& bodyIcon : m_bodyIcons) {
bodyIcon.second->SetSelected(false);
RefCountedPtr<StarSystem> currentSys = Pi::game->GetSpace()->GetStarSystem();
if (currentSys && currentSys->GetPath() == m_system->GetPath()) {
//navtarget can be only set in current system
if (Body* navtarget = Pi::player->GetNavTarget()) {
const SystemPath& navpath = navtarget->GetSystemBody()->GetPath();
if (bodyIcon.first == navpath.bodyIndex) {
bodyIcon.second->SetSelectColor(Color(0, 255, 0, 255));
bodyIcon.second->SetSelected(true);
m_selectedBodyPath = navpath;
}
}
} else {
SystemPath selected = Pi::sectorView->GetSelected();
if (selected.IsSameSystem(m_system->GetPath()) && !selected.IsSystemPath()) {
if (bodyIcon.first == selected.bodyIndex) {
bodyIcon.second->SetSelectColor(Color(64, 96, 255, 255));
bodyIcon.second->SetSelected(true);
m_selectedBodyPath = selected;
}
}
}
}
}
示例2: l_sbodypath_is_same_system
/*
* Method: IsSameSystem
*
* Determine if two <SystemPath> objects point to objects in the same system.
*
* > is_same = path:IsSameSystem(otherpath)
*
* Parameters:
*
* otherpath - the <SystemPath> to compare with this path
*
* Return:
*
* is_same - true if the path's point to the same system, false otherwise
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_sbodypath_is_same_system(lua_State *l)
{
SystemPath *a = LuaObject<SystemPath>::CheckFromLua(1);
SystemPath *b = LuaObject<SystemPath>::CheckFromLua(2);
lua_pushboolean(l, a->IsSameSystem(b));
return 1;
}
示例3: l_sbodypath_is_same_system
/*
* Method: IsSameSystem
*
* Determine if two <SystemPath> objects point to objects in the same system.
*
* > is_same = path:IsSameSystem(otherpath)
*
* Parameters:
*
* otherpath - the <SystemPath> to compare with this path
*
* Return:
*
* is_same - true if the path's point to the same system, false otherwise
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_sbodypath_is_same_system(lua_State *l)
{
SystemPath *a = LuaObject<SystemPath>::CheckFromLua(1);
SystemPath *b = LuaObject<SystemPath>::CheckFromLua(2);
if (!a->HasValidSystem())
return luaL_error(l, "SystemPath:IsSameSystem() self argument does not refer to a system");
if (!b->HasValidSystem())
return luaL_error(l, "SystemPath:IsSameSystem() argument #1 does not refer to a system");
lua_pushboolean(l, a->IsSameSystem(b));
return 1;
}
示例4: GetHyperspaceExitPoint
vector3d Space::GetHyperspaceExitPoint(const SystemPath &source, const SystemPath &dest) const
{
assert(m_starSystem);
assert(source.IsSystemPath());
assert(dest.IsSameSystem(m_starSystem->GetPath()));
RefCountedPtr<const Sector> source_sec = m_sectorCache->GetCached(source);
RefCountedPtr<const Sector> dest_sec = m_sectorCache->GetCached(dest);
Sector::System source_sys = source_sec->m_systems[source.systemIndex];
Sector::System dest_sys = dest_sec->m_systems[dest.systemIndex];
const vector3d sourcePos = vector3d(source_sys.GetPosition()) + vector3d(source.sectorX, source.sectorY, source.sectorZ);
const vector3d destPos = vector3d(dest_sys.GetPosition()) + vector3d(dest.sectorX, dest.sectorY, dest.sectorZ);
Body *primary = 0;
if (dest.IsBodyPath()) {
assert(dest.bodyIndex < m_starSystem->GetNumBodies());
primary = FindBodyForPath(&dest);
while (primary && primary->GetSystemBody()->GetSuperType() != SystemBody::SUPERTYPE_STAR) {
SystemBody* parent = primary->GetSystemBody()->GetParent();
primary = parent ? FindBodyForPath(&parent->GetPath()) : 0;
}
}
if (!primary) {
// find the first non-gravpoint. should be the primary star
for (Body* b : GetBodies())
if (b->GetSystemBody()->GetType() != SystemBody::TYPE_GRAVPOINT) {
primary = b;
break;
}
}
assert(primary);
// point along the line between source and dest, a reasonable distance
// away based on the radius (don't want to end up inside black holes, and
// then mix it up so that ships don't end up on top of each other
vector3d pos = (sourcePos - destPos).Normalized() * (primary->GetSystemBody()->GetRadius()/AU+1.0)*11.0*AU*Pi::rng.Double(0.95,1.2) + MathUtil::RandomPointOnSphere(5.0,20.0)*1000.0;
assert(pos.Length() > primary->GetSystemBody()->GetRadius());
return pos + primary->GetPositionRelTo(GetRootFrame());
}
示例5: UpdateSystemLabels
void SectorView::UpdateSystemLabels(SystemLabels &labels, const SystemPath &path)
{
PROFILE_SCOPED()
Sector *sec = GetCached(path.sectorX, path.sectorY, path.sectorZ);
Sector *playerSec = GetCached(m_current.sectorX, m_current.sectorY, m_current.sectorZ);
char format[256];
if (m_inSystem) {
const float dist = Sector::DistanceBetween(sec, path.systemIndex, playerSec, m_current.systemIndex);
int fuelRequired;
double dur;
enum Ship::HyperjumpStatus jumpStatus
= Pi::player->GetHyperspaceDetails(&path, fuelRequired, dur);
const double DaysNeeded = dur*(1.0 / (24*60*60));
const double HoursNeeded = (DaysNeeded - floor(DaysNeeded))*24;
switch (jumpStatus) {
case Ship::HYPERJUMP_OK:
snprintf(format, sizeof(format), "[ %s | %s | %s, %s ]", Lang::NUMBER_LY, Lang::NUMBER_TONNES, Lang::NUMBER_DAYS, Lang::NUMBER_HOURS);
labels.distance->SetText(stringf(format,
formatarg("distance", dist), formatarg("mass", fuelRequired), formatarg("days", floor(DaysNeeded)), formatarg("hours", HoursNeeded)));
labels.distance->Color(0, 255, 51);
m_jumpLine.SetColor(Color(0, 255, 51, 255));
break;
case Ship::HYPERJUMP_INSUFFICIENT_FUEL:
snprintf(format, sizeof(format), "[ %s | %s ]", Lang::NUMBER_LY, Lang::NUMBER_TONNES);
labels.distance->SetText(stringf(format,
formatarg("distance", dist), formatarg("mass", fuelRequired)));
labels.distance->Color(255, 255, 0);
m_jumpLine.SetColor(Color::YELLOW);
break;
case Ship::HYPERJUMP_OUT_OF_RANGE:
snprintf(format, sizeof(format), "[ %s ]", Lang::NUMBER_LY);
labels.distance->SetText(stringf(format,
formatarg("distance", dist)));
labels.distance->Color(255, 0, 0);
m_jumpLine.SetColor(Color::RED);
break;
default:
labels.distance->SetText("");
break;
}
}
else if (path.IsSameSystem(Pi::player->GetHyperspaceDest())) {
snprintf(format, sizeof(format), "[ %s ]", Lang::IN_TRANSIT);
labels.distance->SetText(format);
labels.distance->Color(102, 102, 255);
}
else
labels.distance->SetText("");
RefCountedPtr<StarSystem> sys = StarSystem::GetCached(path);
std::string desc;
if (sys->GetNumStars() == 4) {
desc = Lang::QUADRUPLE_SYSTEM;
} else if (sys->GetNumStars() == 3) {
desc = Lang::TRIPLE_SYSTEM;
} else if (sys->GetNumStars() == 2) {
desc = Lang::BINARY_SYSTEM;
} else {
desc = sys->rootBody->GetAstroDescription();
}
labels.starType->SetText(desc);
labels.systemName->SetText(sys->GetName());
labels.shortDesc->SetText(sys->GetShortDescription());
if (m_detailBoxVisible == DETAILBOX_INFO) m_infoBox->ShowAll();
}