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


C++ CUnit::PostInit方法代码示例

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


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

示例1: LoadUnit

CUnit* CUnitLoader::LoadUnit(const UnitLoadParams& cparams)
{
    CUnit* unit = NULL;
    UnitLoadParams& params = const_cast<UnitLoadParams&>(cparams);

    {
        GML_RECMUTEX_LOCK(sel); // LoadUnit - for anti deadlock purposes.
        GML_RECMUTEX_LOCK(quad); // LoadUnit - make sure other threads cannot access an incomplete unit

        const UnitDef* ud = params.unitDef;

        if (ud == NULL)
            return unit;
        // need to check this BEFORE creating the instance
        if (!unitHandler->CanAddUnit(cparams.unitID))
            return unit;

        if (params.teamID < 0) {
            // FIXME use gs->gaiaTeamID ?  (once it is always enabled)
            if ((params.teamID = teamHandler->GaiaTeamID()) < 0)
                throw content_error("Invalid team and no gaia team to put unit in");
        }

        if (ud->IsTransportUnit()) {
            unit = new CTransportUnit();
        } else if (ud->IsFactoryUnit()) {
            // special static builder structures that can always be given
            // move orders (which are passed on to all mobile buildees)
            unit = new CFactory();
        } else if (ud->IsMobileBuilderUnit() || ud->IsStaticBuilderUnit()) {
            // all other types of non-structure "builders", including hubs and
            // nano-towers (the latter should not have any build-options at all,
            // whereas the former should be unable to build any mobile units)
            unit = new CBuilder();
        } else if (ud->IsBuildingUnit()) {
            // static non-builder structures
            if (ud->IsExtractorUnit()) {
                unit = new CExtractorBuilding();
            } else {
                unit = new CBuilding();
            }
        } else {
            // regular mobile unit
            unit = new CUnit();
        }

        unit->PreInit(params);

        if (ud->IsTransportUnit()) {
            new CTransportCAI(unit);
        } else if (ud->IsFactoryUnit()) {
            new CFactoryCAI(unit);
        } else if (ud->IsMobileBuilderUnit() || ud->IsStaticBuilderUnit()) {
            new CBuilderCAI(unit);
        } else if (ud->IsStrafingAirUnit()) {
            // non-hovering fighter or bomber aircraft; coupled to StrafeAirMoveType
            new CAirCAI(unit);
        } else if (ud->IsAirUnit()) {
            // all other aircraft; coupled to HoverAirMoveType
            new CMobileCAI(unit);
        } else if (ud->IsGroundUnit()) {
            new CMobileCAI(unit);
        } else {
            new CCommandAI(unit);
        }
    }

    unit->PostInit(params.builder);
    (eventBatchHandler->GetUnitCreatedDestroyedBatch()).enqueue(EventBatchHandler::UD(unit, unit->isCloaked));

    if (params.flattenGround) {
        FlattenGround(unit);
    }

    return unit;
}
开发者ID:Dylan16807,项目名称:spring,代码行数:76,代码来源:UnitLoader.cpp

示例2: LoadUnit

CUnit* CUnitLoader::LoadUnit(const UnitDef* ud, const float3& pos, int team,
                             bool build, int facing, const CUnit* builder)
{
    CUnit* unit = NULL;

    SCOPED_TIMER("UnitLoader::LoadUnit");

    {
        GML_RECMUTEX_LOCK(sel); // LoadUnit - for anti deadlock purposes.
        GML_RECMUTEX_LOCK(quad); // LoadUnit - make sure other threads cannot access an incomplete unit

        if (team < 0) {
            team = teamHandler->GaiaTeamID(); // FIXME use gs->gaiaTeamID ?  (once it is always enabled)
            if (team < 0)
                throw content_error("Invalid team and no gaia team to put unit in");
        }

        if (ud->IsTransportUnit()) {
            unit = new CTransportUnit();
        } else if (ud->IsFactoryUnit()) {
            // special static builder structures that can always be given
            // move orders (which are passed on to all mobile buildees)
            unit = new CFactory();
        } else if (ud->IsMobileBuilderUnit() || ud->IsStaticBuilderUnit()) {
            // all other types of non-structure "builders", including hubs and
            // nano-towers (the latter should not have any build-options at all,
            // whereas the former should be unable to build any mobile units)
            unit = new CBuilder();
        } else if (ud->IsBuildingUnit()) {
            // static non-builder structures
            if (ud->IsExtractorUnit()) {
                unit = new CExtractorBuilding();
            } else {
                unit = new CBuilding();
            }
        } else {
            // regular mobile unit
            unit = new CUnit();
        }

        unit->PreInit(ud, team, facing, pos, build);

        if (ud->IsTransportUnit()) {
            new CTransportCAI(unit);
        } else if (ud->IsFactoryUnit()) {
            new CFactoryCAI(unit);
        } else if (ud->IsMobileBuilderUnit() || ud->IsStaticBuilderUnit()) {
            new CBuilderCAI(unit);
        } else if (ud->IsNonHoveringAirUnit()) {
            // non-hovering fighter or bomber aircraft; coupled to StrafeAirMoveType
            new CAirCAI(unit);
        } else if (ud->IsAirUnit()) {
            // all other aircraft; coupled to HoverAirMoveType
            new CMobileCAI(unit);
        } else if (ud->IsGroundUnit()) {
            new CMobileCAI(unit);
        } else {
            new CCommandAI(unit);
        }
    }

    unit->PostInit(builder);
    (eventBatchHandler->GetUnitCreatedDestroyedBatch()).enqueue(EventBatchHandler::UD(unit, unit->isCloaked));

    return unit;
}
开发者ID:azotlikid,项目名称:spring,代码行数:66,代码来源:UnitLoader.cpp


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