Add: [Script] Game script control of industry production level.
This commit is contained in:
@@ -78,6 +78,8 @@
|
||||
* \li GSVehicleList_DefaultGroup
|
||||
* \li GSGoal::IsValidGoalDestination
|
||||
* \li GSGoal::SetDestination
|
||||
* \li GSIndustry::GetProductionLevel
|
||||
* \li GSIndustry::SetProductionLevel
|
||||
*
|
||||
* API removals:
|
||||
* \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore.
|
||||
|
@@ -294,3 +294,19 @@
|
||||
::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company);
|
||||
return ScriptObject::Command<CMD_INDUSTRY_SET_EXCLUSIVITY>::Do(industry_id, owner, true);
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptIndustry::GetProductionLevel(IndustryID industry_id)
|
||||
{
|
||||
Industry *i = Industry::GetIfValid(industry_id);
|
||||
if (i == nullptr) return 0;
|
||||
return i->prod_level;
|
||||
}
|
||||
|
||||
/* static */ bool ScriptIndustry::SetProductionLevel(IndustryID industry_id, SQInteger prod_level, bool show_news)
|
||||
{
|
||||
EnforceDeityMode(false);
|
||||
EnforcePrecondition(false, IsValidIndustry(industry_id));
|
||||
EnforcePrecondition(false, prod_level >= PRODLEVEL_MINIMUM && prod_level <= PRODLEVEL_MAXIMUM);
|
||||
|
||||
return ScriptObject::Command<CMD_INDUSTRY_SET_PRODUCTION>::Do(industry_id, prod_level, show_news);
|
||||
}
|
||||
|
@@ -47,6 +47,10 @@ public:
|
||||
* This does not prevent a closure already announced.
|
||||
*/
|
||||
INDCTL_NO_CLOSURE = ::INDCTL_NO_CLOSURE,
|
||||
/**
|
||||
* Indicates that the production level of the industry is controlled by a game script.
|
||||
*/
|
||||
INDCTL_EXTERNAL_PROD_LEVEL = ::INDCTL_EXTERNAL_PROD_LEVEL,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -323,6 +327,27 @@ public:
|
||||
*/
|
||||
static bool SetExclusiveConsumer(IndustryID industry_id, ScriptCompany::CompanyID company_id);
|
||||
|
||||
/**
|
||||
* Gets the current production level of an industry.
|
||||
* @param industry_id The index of the industry.
|
||||
* @api -ai
|
||||
*/
|
||||
static SQInteger GetProductionLevel(IndustryID industry_id);
|
||||
|
||||
/**
|
||||
* Sets the current production level of an industry.
|
||||
* @note Setting the production level automatically sets the control flag INDCTL_EXTERNAL_PROD_LEVEL if it wasn't already set.
|
||||
* Normal production behaviour can be restored by clearing the control flag.
|
||||
* @param industry_id The index of the industry.
|
||||
* @param prod_level The production level to set.
|
||||
* @param show_news If set to true and the production changed, generate a production change news message. If set to false, no news message is shown.
|
||||
* @pre IsValidIndustry(industry_id).
|
||||
* @pre ScriptCompanyMode::IsDeity().
|
||||
* @pre prod_level >= 4 && prod_level <= 128.
|
||||
* @return True if the action succeeded.
|
||||
* @api -ai
|
||||
*/
|
||||
static bool SetProductionLevel(IndustryID industry_id, SQInteger prod_level, bool show_news);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_INDUSTRY_HPP */
|
||||
|
Reference in New Issue
Block a user