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


C++ Ship::FleetID方法代码示例

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


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

示例1: AddShip

void Fleet::AddShip(int ship_id) {
    if (this->Contains(ship_id)) {
        Logger().debugStream() << "Fleet::AddShip this fleet '" << this->Name() << "' already contained ship '" << ship_id << "'";
        return;
    }

    Ship* ship = GetShip(ship_id);
    if (!ship) {
        Logger().errorStream() << "Fleet::AddShips() : Attempted to add an id (" << ship_id << ") of a non-ship object to a fleet.";
        return;
    }

    //Logger().debugStream() << "Fleet '" << this->Name() << "' adding ship: " << ship_id;

    // remove ship from old fleet
    if (Fleet* old_fleet = GetFleet(ship->FleetID()))
        old_fleet->RemoveShip(ship_id);

    // ensure ship is in same system as this fleet
    int ship_system_id = ship->SystemID();
    int this_fleet_system_id = this->SystemID();
    if (ship_system_id != this_fleet_system_id)
        if (System* system = GetSystem(this_fleet_system_id))
            system->Insert(ship);   // sets ship's system, remove from old system (if any) and moves ship to system's location (if necessary)

    // add ship to this fleet, and set its internal fleet record

    ship->SetFleetID(ID());
    m_ships.insert(ship_id);

    RecalculateFleetSpeed();
    StateChangedSignal();
}
开发者ID:adesst,项目名称:freeorion,代码行数:33,代码来源:Fleet.cpp

示例2: RedoPlacementsButtonClicked

void CombatSetupWnd::RedoPlacementsButtonClicked() {
    const GG::Pt row_size = ListRowSize();
    for (std::map<int, Ogre::SceneNode*>::iterator it = m_placed_nodes.begin();
            it != m_placed_nodes.end();
            ++it) {
        Ship* ship = *Ogre::any_cast<Ship*>(&it->second->getUserAny());
        UniverseObject* o = m_combat_universe[ship->FleetID()];
        Fleet* fleet = boost::polymorphic_downcast<Fleet*>(o);
        ShipRow* row = new ShipRow(ship, fleet, row_size.x, row_size.y);
        m_listbox->Insert(row);
        m_remove_ship(it->first);
    }
    m_placed_nodes.clear();
}
开发者ID:anarsky,项目名称:freeorion,代码行数:14,代码来源:CombatSetupWnd.cpp


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