-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,13 +158,13 @@ int EngineAssist::GetResourceAmount(PlayerType p_playerIndex, ResourceType p_res | |
switch(p_resourceId) | ||
{ | ||
case RESOURCE_Supply: | ||
p_availableAmount = m_resources->Supply(); | ||
p_availableAmount = m_resources->AvailableSupply(); | ||
break; | ||
case RESOURCE_Primary: | ||
p_availableAmount = m_resources->Primary(); | ||
p_availableAmount = m_resources->AvailablePrimary(); | ||
break; | ||
case RESOURCE_Secondary: | ||
p_availableAmount = m_resources->Secondary(); | ||
p_availableAmount = m_resources->AvailableSecondary(); | ||
break; | ||
default: | ||
return ERR_InvalidParameterValue; | ||
|
@@ -622,4 +622,46 @@ void EngineAssist::GetPrerequisites(int p_entityOrResearchType, PlayerType p_pla | |
p_prerequisites.push_back(new ResourceExist(p_playerType, RESOURCE_Primary, pReqResources->Primary())); | ||
p_prerequisites.push_back(new ResourceExist(p_playerType, RESOURCE_Secondary, pReqResources->Secondary())); | ||
p_prerequisites.push_back(new ResourceExist(p_playerType, RESOURCE_Supply, pReqResources->Supply())); | ||
} | ||
//------------------------------------------------------------------------------------------------------------------------------------------------ | ||
void EngineAssist::ControlResource(int p_entityOrResearchType, PlayerType p_playerType, bool lock) | ||
This comment has been minimized.
Sorry, something went wrong.
MHesham
|
||
{ | ||
GamePlayer *pPlayer = nullptr; | ||
GameType *pEntityType = nullptr; | ||
GameResearch *pResearchType = nullptr; | ||
WorldResources *pReqResources = nullptr; | ||
|
||
pPlayer = g_Game->GetPlayer(p_playerType); | ||
assert(pPlayer); | ||
|
||
if (BELONG(ResearchType, p_entityOrResearchType)) | ||
{ | ||
pResearchType = g_Game->GetResearch((ResearchType)p_entityOrResearchType); | ||
assert(pResearchType); | ||
|
||
pReqResources = pResearchType->RequiredResources(); | ||
assert(pReqResources); | ||
} | ||
else if (BELONG(EntityClassType, p_entityOrResearchType)) | ||
{ | ||
pEntityType = g_Game->GetEntityType((EntityClassType)p_entityOrResearchType); | ||
assert(pEntityType); | ||
|
||
pReqResources = pEntityType->RequiredResources(); | ||
assert(pReqResources); | ||
} | ||
else assert(0); | ||
This comment has been minimized.
Sorry, something went wrong.
MHesham
|
||
|
||
if (lock) | ||
{ | ||
pPlayer->Resources()->Lock(RESOURCE_Primary, pReqResources->Primary()); | ||
pPlayer->Resources()->Lock(RESOURCE_Secondary, pReqResources->Secondary()); | ||
pPlayer->Resources()->Lock(RESOURCE_Supply, pReqResources->Supply()); | ||
} | ||
else | ||
{ | ||
pPlayer->Resources()->Unlock(RESOURCE_Primary, pReqResources->Primary()); | ||
pPlayer->Resources()->Unlock(RESOURCE_Secondary, pReqResources->Secondary()); | ||
pPlayer->Resources()->Unlock(RESOURCE_Supply, pReqResources->Supply()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,9 @@ bool ResearchAction::SuccessConditionsSatisfied(RtsGame& pRtsGame) | |
//---------------------------------------------------------------------------------------------- | ||
bool ResearchAction::ExecuteAux(RtsGame& pRtsGame, const WorldClock& p_clock) | ||
{ | ||
ResearchType researchType = (ResearchType)_params[PARAM_ResearchId]; | ||
GameEntity *pGameResearcher; | ||
AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); | ||
ResearchType researchType = (ResearchType)_params[PARAM_ResearchId]; | ||
GameEntity *pGameResearcher; | ||
AbstractAdapter *pAdapter = g_OnlineCaseBasedPlanner->Reasoner()->Adapter(); | ||
|
||
// Adapt researcher | ||
_researcherId = pAdapter->AdaptBuildingForResearch(researchType); | ||
|
@@ -57,6 +57,7 @@ bool ResearchAction::ExecuteAux(RtsGame& pRtsGame, const WorldClock& p_clock) | |
pGameResearcher = pRtsGame.Self()->GetEntity(_researcherId); | ||
assert(pGameResearcher); | ||
|
||
g_Assist.ControlResource(researchType, PLAYER_Self, false); | ||
This comment has been minimized.
Sorry, something went wrong.
MHesham
|
||
return pGameResearcher->Research(researchType); | ||
} | ||
//---------------------------------------------------------------------------------------------- | ||
|
@@ -77,3 +78,8 @@ void ResearchAction::InitializePreConditions() | |
g_Assist.GetPrerequisites(researchType, PLAYER_Self, m_terms); | ||
_preCondition = new And(m_terms); | ||
} | ||
//---------------------------------------------------------------------------------------------- | ||
void ResearchAction::PreExecution(RtsGame& pRtsGame) | ||
{ | ||
g_Assist.ControlResource(_params[PARAM_ResearchId], PLAYER_Self, true); | ||
} |
I expected from the name
PreExecution
that this method is executed by the base before ExecuteAux, now it is more confusing to me.Can you explain the design more?