Change: Monitor company new/merge/delete, and industry closure events,
re-organized handling of creating/updating/removal of goals.
This commit is contained in:
28
company.nut
28
company.nut
@@ -123,13 +123,28 @@ class CompanyData {
|
||||
function AddActiveGoal(cargo_id, accept, amount);
|
||||
function HasGoal(cargo_id, accept);
|
||||
function GetNumberOfGoalsForCargo(cargo_id);
|
||||
function IndustryClosed(ind_id);
|
||||
|
||||
function AddMonitorElement(mon);
|
||||
function UpdateDelivered(mon);
|
||||
function UpdateTimeout(step);
|
||||
function CheckAndFinishGoals();
|
||||
|
||||
function FinalizeCompany();
|
||||
};
|
||||
|
||||
// Company is about to be deleted, last chance to clean up.
|
||||
function CompanyData::FinalizeCompany()
|
||||
{
|
||||
foreach (num, goal in this.active_goals) {
|
||||
if (goal != null) {
|
||||
goal.FinalizeGoal();
|
||||
this.active_goals[num] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Find the number of active goals that are missing for this company.
|
||||
// @return Number of additional goals that the company needs.
|
||||
function CompanyData::GetMissingGoalCount()
|
||||
@@ -187,6 +202,19 @@ function CompanyData::GetNumberOfGoalsForCargo(cargo_id)
|
||||
return count;
|
||||
}
|
||||
|
||||
// The given industry closed, delete any goal with it.
|
||||
// @param ind_id Industry that closed.
|
||||
function CompanyData::IndustryClosed(ind_id)
|
||||
{
|
||||
foreach (num, goal in this.active_goals) {
|
||||
if (goal == null) continue;
|
||||
if ("ind" in goal.accept && goal.accept.ind == ind_id) {
|
||||
goal.FinalizeGoal();
|
||||
this.active_goals[num] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add monitor elements of a company, if they exist.
|
||||
// @param [inout] cmon Monitors of all companies, updated in-place.
|
||||
// Result is 'comp_id' number to 'cargo_id' numbers to 'ind' and/or 'town' indices to 'null'
|
||||
|
||||
Reference in New Issue
Block a user