Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ArsenalAmmunitionModeAttribute.c
Go to the documentation of this file.
3 {
4  //------------------------------------------------------------------------------------------------
5  override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
6  {
8  if (!editableEntity)
9  return null;
10 
11  SCR_ArsenalComponent arsenalComponent = SCR_ArsenalComponent.FindArsenalComponent(editableEntity.GetOwner());
12  if (!arsenalComponent)
13  return null;
14 
15  SCR_EArsenalAttributeGroup arsenalGroups = arsenalComponent.GetEditableAttributeGroups();
16  if (!(arsenalGroups & SCR_EArsenalAttributeGroup.AMMUNITION_MODE) || !(arsenalGroups & SCR_EArsenalAttributeGroup.WEAPONS))
17  return null;
18 
19  SCR_EArsenalItemMode itemMode = arsenalComponent.GetSupportedArsenalItemModes();
20 
21  int weaponsAmmunitionIndex;
22 
23  if ((itemMode & SCR_EArsenalItemMode.WEAPON) && (itemMode & SCR_EArsenalItemMode.AMMUNITION))
24  weaponsAmmunitionIndex = 0;
25  else if (itemMode & SCR_EArsenalItemMode.WEAPON)
26  weaponsAmmunitionIndex = 1;
27  else
28  weaponsAmmunitionIndex = 2;
29 
30  return SCR_BaseEditorAttributeVar.CreateInt(weaponsAmmunitionIndex);
31  }
32 
33  //------------------------------------------------------------------------------------------------
34  override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
35  {
36  if (!var)
37  return;
38 
39  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(item);
40  if (!editableEntity)
41  return;
42 
43  SCR_ArsenalComponent arsenalComponent = SCR_ArsenalComponent.FindArsenalComponent(editableEntity.GetOwner());
44  if (!arsenalComponent)
45  return;
46 
47  SCR_EArsenalItemMode itemMode = arsenalComponent.GetSupportedArsenalItemModes();
48 
49  int weaponsAmmunitionIndex = var.GetInt();
50 
51  if (weaponsAmmunitionIndex == 0)
52  {
53  itemMode |= SCR_EArsenalItemMode.WEAPON;
54  itemMode |= SCR_EArsenalItemMode.WEAPON_VARIANTS;
55  itemMode |= SCR_EArsenalItemMode.AMMUNITION;
56  }
57  else if (weaponsAmmunitionIndex == 1)
58  {
59  itemMode |= SCR_EArsenalItemMode.WEAPON;
60  itemMode |= SCR_EArsenalItemMode.WEAPON_VARIANTS;
61  itemMode &= ~SCR_EArsenalItemMode.AMMUNITION;
62  }
63  else
64  {
65  itemMode &= ~SCR_EArsenalItemMode.WEAPON;
66  itemMode &= ~SCR_EArsenalItemMode.WEAPON_VARIANTS;
67  itemMode |= SCR_EArsenalItemMode.AMMUNITION;
68  }
69 
70  arsenalComponent.SetSupportedArsenalItemModes(itemMode);
71  }
72 }
SCR_EArsenalAttributeGroup
SCR_EArsenalAttributeGroup
Definition: SCR_EArsenalAttributeGroup.c:1
SCR_EArsenalItemMode
SCR_EArsenalItemMode
Definition: SCR_EArsenalItemMode.c:1
SCR_ArsenalAmmunitionModeAttribute
Definition: SCR_ArsenalAmmunitionModeAttribute.c:2
SCR_BaseEditorAttributeCustomTitle
Definition: SCR_BaseEditorAttribute.c:868
SCR_BaseEditorAttributeVar
Definition: SCR_BaseEditorAttributeVar.c:1
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseFloatValueHolderEditorAttribute
Attribute base for Name, icon and float value for other attributes to inherent from.
Definition: SCR_BaseFloatValueHolderEditorAttribute.c:3
SCR_ArsenalComponent
Definition: SCR_ArsenalComponent.c:9
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468