//----------------------------------------------------------------------------------------------
int BuildActionEx::ExecuteAux(unsigned long p_cycles)
{
	EntityClassType		builderType;
	EntityClassType		buildingType;
	GameEntity			*pGameBuilder;
	AbstractAdapter		*pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter();
	int					ret;

	builderType = g_Game->Self()->GetWorkerType();
	buildingType = (EntityClassType)_params[PARAM_BuildingClassId];

	// Initialize build state
	_buildStarted = false;

	// Adapt build position
	assert(pAdapter);
	_buildPosition = pAdapter->AdaptPositionForBuilding(buildingType);

	// Adapt builder
	_builderId = pAdapter->AdaptWorkerForBuild();

	// Issue build order
	pGameBuilder = g_Game->Self()->GetEntity(_builderId);
	assert(pGameBuilder);
	pGameBuilder->Lock();
	ret = pGameBuilder->Build(buildingType, _buildPosition.X, _buildPosition.Y);

	return ret;
}
Beispiel #2
0
bool BuildActionEx::ExecuteAux(RtsGame& game, const WorldClock& p_clock)
{
    EntityClassType buildingType;
    GameEntity *pGameBuilder;
    AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter();
    bool bOk = false;

    // Adapt builder
    _builderId = pAdapter->GetEntityObjectId(game.Self()->GetWorkerType(),AdapterEx::WorkerStatesRankVector);

    if (_builderId != INVALID_TID)
    {

        buildingType = (EntityClassType)_params[PARAM_EntityClassId];

        // Initialize build state
        _buildStarted = false;

        // Adapt build position
        assert(pAdapter);
        _buildArea = pAdapter->AdaptPositionForBuilding(buildingType);

        // Issue build order
        pGameBuilder = game.Self()->GetEntity(_builderId);
        assert(pGameBuilder);

        bOk = pGameBuilder->Build(buildingType, _buildArea.Pos());

        if (bOk)
        {
            _buildIssued = true;
            pGameBuilder->Lock(this);
            assert(!_buildArea.IsNull());
            _buildArea.Lock(this);
            assert(!_requiredResources.IsNull());
            _requiredResources.Lock(this);
        }
    }

    return bOk;
}