本文整理汇总了C++中StarSystem类的典型用法代码示例。如果您正苦于以下问题:C++ StarSystem类的具体用法?C++ StarSystem怎么用?C++ StarSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StarSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l_starsystem_export_to_lua
/*
* Method: ExportToLua
*
* Export of generated system for personal interest, customisation, etc
*
* Availability:
*
* alpha 33
*
* Status:
*
* experimental
*/
static int l_starsystem_export_to_lua(lua_State *l)
{
PROFILE_SCOPED()
LUA_DEBUG_START(l);
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
static const std::string EXPORTED_SYSTEMS_DIR_NAME("exported_systems");
if (!FileSystem::userFiles.MakeDirectory(EXPORTED_SYSTEMS_DIR_NAME)) {
throw CouldNotOpenFileException();
}
// construct the filename with folder and extension
try {
const std::string filename(EXPORTED_SYSTEMS_DIR_NAME + "/" + FileSystem::SanitiseFileName(s->GetName()) + ".lua");
const std::string finalPath = FileSystem::NormalisePath(
FileSystem::JoinPathBelow(FileSystem::GetUserDir(), filename));
s->ExportToLua(finalPath.c_str());
} catch (std::invalid_argument &) {
return luaL_error(l, "could not export system -- name forms an invalid path");
}
LUA_DEBUG_END(l, 0);
return 0;
}
示例2: l_starsystem_attr_name
/*
* Attribute: name
*
* The name of the system. This is usually the same as the name of the primary
* star.
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_starsystem_attr_name(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
lua_pushstring(l, s->GetName().c_str());
return 1;
}
示例3: sendHome
//Sends a fleet back to it's home planet
void TaeTurn::sendHome(uint32_t fleet) {
Game* game = Game::getGame();
ObjectManager* obm = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
PlayerManager::Ptr pm = game->getPlayerManager();
IGObject::Ptr fleetobj = obm->getObject(fleet);
//Check to make sure it is really a fleet
if(fleetobj->getType() != obtm->getObjectTypeByName("Fleet")) {
return;
}
//Get all the required objects
Fleet* f = (Fleet*) fleetobj->getObjectBehaviour();
Player::Ptr p = pm->getPlayer(f->getOwner());
IGObject::Ptr sys = obm->getObject(fleetobj->getParent());
StarSystem* sysData = (StarSystem*) sys->getObjectBehaviour();
//Remove fleet from system
sysData->setRegion(0);
fleetobj->removeFromParent();
//Find it's home planet
std::set<uint32_t> objects = obm->getAllIds();
std::set<uint32_t>::iterator itcurr;
for(itcurr = objects.begin(); itcurr != objects.end(); ++itcurr) {
IGObject::Ptr ob = obm->getObject(*itcurr);
if(ob->getName().compare(string(p->getName() + "'s Home Planet")) == 0) {
Planet* p = (Planet*) ob->getObjectBehaviour();
f->setPosition(p->getPosition());
fleetobj->addToParent(ob->getID());
}
}
}
示例4: l_starsystem_attr_path
/*
* Attribute: path
*
* The <SystemPath> to the system
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_starsystem_attr_path(lua_State *l)
{
StarSystem *s = LuaStarSystem::CheckFromLua(1);
SystemPath path = s->GetPath();
LuaSystemPath::PushToLua(&path);
return 1;
}
示例5: l_starsystem_attr_lawlessness
/*
* Attribute: lawlessness
*
* The lawlessness value for the system, 0 for peaceful, 1 for raging
* hordes of pirates
*
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_starsystem_attr_lawlessness(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
lua_pushnumber(l, s->GetSysPolit().lawlessness.ToDouble());
return 1;
}
示例6: l_starsystem_attr_population
/*
* Attribute: population
*
* The population of this system, in billions of people
*
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_starsystem_attr_population(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
lua_pushnumber(l, s->GetTotalPop().ToDouble());
return 1;
}
示例7: l_starsystem_attr_explored
static int l_starsystem_attr_explored(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
lua_pushboolean(l, !s->GetUnexplored());
return 1;
}
示例8: l_starsystem_attr_path
/*
* Attribute: path
*
* The <SystemPath> to the system
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_starsystem_attr_path(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
SystemPath path = s->GetPath();
LuaObject<SystemPath>::PushToLua(&path);
return 1;
}
示例9: l_sbodypath_get_star_system
/*
* Method: GetStarSystem
*
* Get a <StarSystem> object for the system that this path points to
*
* > system = path:GetStarSystem()
*
* Return:
*
* system - the <StarSystem>
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_sbodypath_get_star_system(lua_State *l)
{
SystemPath *path = LuaSystemPath::GetFromLua(1);
StarSystem *s = StarSystem::GetCached(path);
LuaStarSystem::PushToLua(s);
s->Release();
return 1;
}
示例10: l_sbodypath_get_system_body
/*
* Method: GetSystemBody
*
* Get a <SystemBody> object for the body that this path points to
*
* > body = path:GetSystemBody()
*
* Return:
*
* body - the <SystemBody>
*
* Availability:
*
* alpha 10
*
* Status:
*
* stable
*/
static int l_sbodypath_get_system_body(lua_State *l)
{
SystemPath *path = LuaSystemPath::GetFromLua(1);
StarSystem *s = StarSystem::GetCached(path);
SBody *sbody = s->GetBodyByPath(path);
LuaSBody::PushToLua(sbody);
s->Release();
return 1;
}
示例11: getStarSystem
StarSystem* Universe::getStarSystem( string name )
{
vector< StarSystem* >::iterator iter;
for (iter = star_system.begin(); iter != star_system.end(); iter++) {
StarSystem *ss = *iter;
if (ss->getName() == name)
return ss;
}
return NULL;
}
示例12: l_starsystem_attr_faction
/*
* Attribute: faction
*
* The faction that controls this system
*
* Availability:
*
* alpha 28
*
* Status:
*
* experimental
*/
static int l_starsystem_attr_faction(lua_State *l)
{
StarSystem *s = LuaStarSystem::CheckFromLua(1);
if (s->GetFaction()->IsValid()) {
LuaFaction::PushToLua(s->GetFaction());
return 1;
} else {
return 0;
}
}
示例13: l_starsystem_attr_faction
/*
* Attribute: faction
*
* The <Faction> that controls this system
*
* Availability:
*
* alpha 28
*
* Status:
*
* experimental
*/
static int l_starsystem_attr_faction(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
if (s->GetFaction()->IsValid()) {
LuaObject<Faction>::PushToLua(s->GetFaction());
return 1;
} else {
return 0;
}
}
示例14: l_starsystem_attr_faction
/*
* Attribute: faction
*
* The <Faction> that controls this system
*
* Availability:
*
* alpha 28
*
* Status:
*
* experimental
*/
static int l_starsystem_attr_faction(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
if (s->GetFaction()->IsValid()) {
LuaObject<Faction>::PushToLua(const_cast<Faction*>(s->GetFaction())); // XXX const-correctness violation
return 1;
} else {
return 0;
}
}
示例15: l_starsystem_is_commodity_legal
/*
* Method: IsCommodityLegal
*
* Determine if a given cargo item is legal for trade in this system
*
* > is_legal = system:IsCommodityLegal(cargo)
*
* Parameters:
*
* cargo - the wanted commodity (for instance, Equipment.cargo.hydrogen)
*
* Return:
*
* is_legal - true if the commodity is legal, otherwise false
*
* Availability:
*
* alpha 10
*
* Status:
*
* experimental
*/
static int l_starsystem_is_commodity_legal(lua_State *l)
{
PROFILE_SCOPED()
StarSystem *s = LuaObject<StarSystem>::CheckFromLua(1);
// XXX: Don't use the l10n_key hack, this is just UGLY!!
luaL_checktype(l, 2, LUA_TTABLE);
LuaTable(l, 2).PushValueToStack("l10n_key");
GalacticEconomy::Commodity e = static_cast<GalacticEconomy::Commodity>(
LuaConstants::GetConstantFromArg(l, "CommodityType", -1));
lua_pushboolean(l, s->IsCommodityLegal(e));
return 1;
}