Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AIDecoHasMagazineCount.c
Go to the documentation of this file.
8
10{
11 static const string PORT_MAGAZINE_COUNT = "MagazineCountOut";
12
13 [Attribute("0", UIWidgets.ComboBox, "Test Type", "", ParamEnumArray.FromEnum(EVariableTestType) )]
15 [Attribute("0", UIWidgets.EditBox, "Test Value" )]
16 protected int m_iNumberOfMagazines;
17
18 protected SCR_InventoryStorageManagerComponent m_inventoryManager;
20 protected int prevAmmo;
21
23
24 protected static ref TStringArray s_aVarsOut = {
25 PORT_MAGAZINE_COUNT
26 };
28 {
29 return s_aVarsOut;
30 }
31
32 override void OnInit(AIAgent owner)
33 {
34 m_entity = owner.GetControlledEntity();
35 }
36
37 protected override bool TestFunction(AIAgent owner)
38 {
39 if (m_entity && !m_weapon)
40 {
41 m_inventoryManager = SCR_InventoryStorageManagerComponent.Cast(m_entity.FindComponent(SCR_InventoryStorageManagerComponent));
42 BaseWeaponManagerComponent weaponManager = BaseWeaponManagerComponent.Cast(m_entity.FindComponent(BaseWeaponManagerComponent));
43 if (weaponManager)
44 m_weapon = weaponManager.GetCurrent();
45 }
46
48 return false;
49 int ammo = m_inventoryManager.GetMagazineCountByWeapon(m_weapon);
50 bool result = false;
51 switch (m_TestType)
52 {
53 case EVariableTestType.EqualsValue:
54 {
55 result = ammo == m_iNumberOfMagazines;
56 break;
57 }
58 case EVariableTestType.BiggerThanValue:
59 {
60 result = ammo > m_iNumberOfMagazines;
61 break;
62 }
63 case EVariableTestType.SmallerThanValue:
64 {
65 result = ammo < m_iNumberOfMagazines;
66 break;
67 }
68 case EVariableTestType.WasChanged:
69 {
70 result = ammo != prevAmmo;
71 prevAmmo = ammo;
72 break;
73 }
74 }
75 SetVariableOut(PORT_MAGAZINE_COUNT, ammo);
76 return result;
77 }
78
79 protected static override bool VisibleInPalette()
80 {
81 return true;
82 }
83
84 override protected string GetNodeMiddleText()
85 {
86 return "Checks: " + typename.EnumToString(EVariableTestType,m_TestType) + " with value: " + m_iNumberOfMagazines.ToString();
87 }
88
89 protected static override string GetOnHoverDescription()
90 {
91 return "Decorator that tests if entity has a weapon specified in attribute either as weapon type or as magazine well, in that case it returns the weapon type of the weapon";
92 }
93};
proto void SetVariableOut(string name, void val)
static override bool VisibleInPalette()
SCR_InventoryStorageManagerComponent m_inventoryManager
static override string GetOnHoverDescription()
override TStringArray GetVariablesOut()
override bool TestFunction(AIAgent owner)
override void OnInit(AIAgent owner)
SCR_FieldOfViewSettings Attribute
array< string > TStringArray
Definition Types.c:385