Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EditableEntityCoreBudgetSetting.c
Go to the documentation of this file.
2class SCR_EditableEntityCoreBudgetSetting
3{
4 [Attribute()]
5 protected ref SCR_UIInfo m_Info;
6
7 [Attribute("0", UIWidgets.ComboBox, "", enums: ParamEnumArray.FromEnum(EEditableEntityBudget))]
9
10 [Attribute("1", UIWidgets.Auto, "")]
11 protected int m_iMinBudgetCost;
12
13 protected int m_iCurrentBudget;
14
15 protected SCR_BudgetEditorComponent m_BudgetEditor;
17 protected int m_iReservedBudget;
18
19 EEditableEntityBudget GetBudgetType()
20 {
21 return m_BudgetType;
22 }
23 int GetMinBudgetCost()
24 {
25 return m_iMinBudgetCost;
26 }
27 int GetCurrentBudget()
28 {
29 return m_iCurrentBudget;
30 }
31 SCR_UIInfo GetInfo()
32 {
33 return m_Info;
34 }
35
36 //------------------------------------------------------------------------------------------------
38 int GetReservedBudget()
39 {
40 return m_iReservedBudget;
41 }
42
43 //------------------------------------------------------------------------------------------------
45 void ReserveBudget(int reserveValue)
46 {
47 m_iReservedBudget += reserveValue;
48 }
49
50 //------------------------------------------------------------------------------------------------
52 void UnreserveBudget(int reserveValue)
53 {
54 m_iReservedBudget -= reserveValue;
55 if (m_iReservedBudget < 0)
56 m_iReservedBudget = 0;
57 }
58
59 int SetCurrentBudget(int budgetValue)
60 {
61 int oldBudget = m_iCurrentBudget;
62 m_iCurrentBudget = budgetValue;
63
64 return m_iCurrentBudget - oldBudget;
65 }
66
67 int AddToBudget(SCR_EntityBudgetValue budgetCost = null)
68 {
69 int budgetCostValue = GetMinBudgetCost();
70 if (budgetCost) budgetCostValue = budgetCost.GetBudgetValue();
71
72 int budgetChange = Math.Max(budgetCostValue, GetMinBudgetCost());
73 m_iCurrentBudget += budgetChange;
74
75 return budgetChange;
76 }
77
78 int AddToBudget(int budgetValue)
79 {
80 int budgetChange = Math.Max(budgetValue, GetMinBudgetCost());
81 m_iCurrentBudget += budgetChange;
82
83 return budgetChange;
84 }
85
86 int SubtractFromBudget(SCR_EntityBudgetValue budgetCost = null)
87 {
88 int budgetCostValue = GetMinBudgetCost();
89 if (budgetCost) budgetCostValue = Math.Max(budgetCost.GetBudgetValue(), budgetCostValue);
90
91 const int previousBudget = m_iCurrentBudget;
92 m_iCurrentBudget = Math.Max(m_iCurrentBudget - budgetCostValue, 0);
93
94 return previousBudget - m_iCurrentBudget;
95 }
96
97 int SubtractFromBudget(int budgetValue)
98 {
99 const int prevBudget = m_iCurrentBudget;
100 m_iCurrentBudget = Math.Max(m_iCurrentBudget - budgetValue, 0);
101
102 const int budgetChange = prevBudget - m_iCurrentBudget;
103
104 #ifdef BUDGET_OPTIMIZATION_CHECKS
105 if(budgetChange != budgetValue)
106 {
107 Print("GM Budget got clamped at some point!", LogLevel.WARNING);
108 }
109
110 return -budgetChange;
111 }
112
113 void SetBudgetComponent(notnull SCR_BudgetEditorComponent budgetEditor)
114 {
115 m_BudgetEditor = budgetEditor;
116 }
117
118 void SCR_EditableEntityCoreBudgetSetting(int budgetValue = -1, EEditableEntityBudget budgetType = EEditableEntityBudget.PROPS, int minBudgetCost = 0, SCR_UIInfo info = null)
119 {
120 if (budgetValue == -1)
121 return;
122
123 m_BudgetType = budgetType;
124 m_iMinBudgetCost = minBudgetCost;
125 m_Info = info;
126 }
127}
EEditableEntityBudget
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
ref SCR_HintUIInfo m_Info
EEditableEntityBudget m_BudgetType
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
override SCR_UIInfo GetInfo()
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute