11 protected int m_iMinBudgetCost;
13 protected int m_iCurrentBudget;
17 protected int m_iReservedBudget;
23 int GetMinBudgetCost()
25 return m_iMinBudgetCost;
27 int GetCurrentBudget()
29 return m_iCurrentBudget;
38 int GetReservedBudget()
40 return m_iReservedBudget;
45 void ReserveBudget(
int reserveValue)
47 m_iReservedBudget += reserveValue;
52 void UnreserveBudget(
int reserveValue)
54 m_iReservedBudget -= reserveValue;
55 if (m_iReservedBudget < 0)
56 m_iReservedBudget = 0;
59 int SetCurrentBudget(
int budgetValue)
61 int oldBudget = m_iCurrentBudget;
62 m_iCurrentBudget = budgetValue;
64 return m_iCurrentBudget - oldBudget;
69 int budgetCostValue = GetMinBudgetCost();
70 if (budgetCost) budgetCostValue = budgetCost.GetBudgetValue();
72 int budgetChange = Math.Max(budgetCostValue, GetMinBudgetCost());
73 m_iCurrentBudget += budgetChange;
78 int AddToBudget(
int budgetValue)
80 int budgetChange = Math.Max(budgetValue, GetMinBudgetCost());
81 m_iCurrentBudget += budgetChange;
88 int budgetCostValue = GetMinBudgetCost();
89 if (budgetCost) budgetCostValue = Math.Max(budgetCost.GetBudgetValue(), budgetCostValue);
91 m_iCurrentBudget = Math.Max(m_iCurrentBudget - budgetCostValue, 0);
93 return -budgetCostValue;
96 int SubtractFromBudget(
int budgetValue)
98 int budgetChange = Math.Min(m_iCurrentBudget, Math.Max(GetMinBudgetCost(), budgetValue));
99 m_iCurrentBudget -= budgetChange;
106 m_BudgetEditor = budgetEditor;
111 if (budgetValue == -1)
115 m_iMinBudgetCost = minBudgetCost;