当前位置: 首页>>代码示例>>C++>>正文


C++ Planet::RemoveSystem方法代码示例

本文整理汇总了C++中Planet::RemoveSystem方法的典型用法代码示例。如果您正苦于以下问题:C++ Planet::RemoveSystem方法的具体用法?C++ Planet::RemoveSystem怎么用?C++ Planet::RemoveSystem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Planet的用法示例。


在下文中一共展示了Planet::RemoveSystem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Load

// Load a system's description.
void System::Load(const DataNode &node, Set<Planet> &planets)
{
    if(node.Size() < 2)
        return;
    name = node.Token(1);

    // If this is truly a change and not just being called by Load(), these sets
    // of objects will be entirely replaced by any new ones, rather than adding
    // the new ones on to the end of the list:
    bool resetLinks = !links.empty();
    bool resetAsteroids = !asteroids.empty();
    bool resetFleets = !fleets.empty();
    bool resetObjects = !objects.empty();

    for(const DataNode &child : node)
    {
        if(child.Token(0) == "pos" && child.Size() >= 3)
            position.Set(child.Value(1), child.Value(2));
        else if(child.Token(0) == "government" && child.Size() >= 2)
            government = GameData::Governments().Get(child.Token(1));
        else if(child.Token(0) == "link")
        {
            if(resetLinks)
            {
                resetLinks = false;
                links.clear();
            }
            if(child.Size() >= 2)
                links.push_back(GameData::Systems().Get(child.Token(1)));
        }
        else if(child.Token(0) == "habitable" && child.Size() >= 2)
            habitable = child.Value(1);
        else if(child.Token(0) == "asteroids")
        {
            if(resetAsteroids)
            {
                resetAsteroids = false;
                asteroids.clear();
            }
            if(child.Size() >= 4)
                asteroids.emplace_back(child.Token(1), child.Value(2), child.Value(3));
        }
        else if(child.Token(0) == "trade" && child.Size() >= 3)
            trade[child.Token(1)].SetBase(child.Value(2));
        else if(child.Token(0) == "fleet")
        {
            if(resetFleets)
            {
                resetFleets = false;
                fleets.clear();
            }
            if(child.Size() >= 3)
                fleets.emplace_back(GameData::Fleets().Get(child.Token(1)), child.Value(2));
        }
        else if(child.Token(0) == "object")
        {
            if(resetObjects)
            {
                for(StellarObject &object : objects)
                    if(object.GetPlanet())
                    {
                        Planet *planet = planets.Get(object.GetPlanet()->Name());
                        planet->RemoveSystem(this);
                    }
                resetObjects = false;
                objects.clear();
            }
            LoadObject(child, planets);
        }
        else
            child.PrintTrace("Skipping unrecognized attribute:");
    }

    // Set planet messages based on what zone they are in.
    for(StellarObject &object : objects)
    {
        if(object.message || object.planet)
            continue;

        const StellarObject *root = &object;
        while(root->parent >= 0)
            root = &objects[root->parent];

        static const string STAR = "You cannot land on a star!";
        static const string HOTPLANET = "This planet is too hot to land on.";
        static const string COLDPLANET = "This planet is too cold to land on.";
        static const string UNINHABITEDPLANET = "This planet is uninhabited.";
        static const string HOTMOON = "This moon is too hot to land on.";
        static const string COLDMOON = "This moon is too cold to land on.";
        static const string UNINHABITEDMOON = "This moon is uninhabited.";
        static const string STATION = "This station cannot be docked with.";

        double fraction = root->distance / habitable;
        if(object.IsStar())
            object.message = &STAR;
        else if (object.IsStation())
            object.message = &STATION;
        else if (object.IsMoon())
        {
//.........这里部分代码省略.........
开发者ID:maxrd2,项目名称:endless-sky,代码行数:101,代码来源:System.cpp


注:本文中的Planet::RemoveSystem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。