Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_WeaponRackSlotEntity.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Campaign", description: "A weapon rack slot to be filled with a weapon.", color: "0 0 255 255")]
2 class SCR_WeaponRackSlotEntityClass: GenericEntityClass
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
8 {
9  [Attribute("0", UIWidgets.Flags, "", enums: ParamEnumArray.FromEnum(SCR_EArsenalItemType))]
10  protected SCR_EArsenalItemType m_eSupportedItemTypes;
11 
12  [Attribute("0", UIWidgets.Flags, "", enums: ParamEnumArray.FromEnum(SCR_EArsenalItemMode))]
13  protected SCR_EArsenalItemMode m_eSupportedItemModes;
14 
15  protected SCR_EArsenalItemType m_eCurrentItemType;
16  protected SCR_EArsenalItemMode m_eCurrentItemMode;
17 
18  //------------------------------------------------------------------------------------------------
19  SCR_EArsenalItemType GetSlotSupportedItemTypes()
20  {
21  return m_eSupportedItemTypes;
22  }
23 
24  //------------------------------------------------------------------------------------------------
25  SCR_EArsenalItemMode GetSlotSupportedItemModes()
26  {
27  return m_eSupportedItemModes;
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  SCR_EArsenalItemMode GetCurrentOccupiedItemType()
32  {
33  return m_eCurrentItemType;
34  }
35 
36  //------------------------------------------------------------------------------------------------
37  SCR_EArsenalItemMode GetCurrentOccupiedItemMode()
38  {
39  return m_eCurrentItemMode;
40  }
41 
42  //------------------------------------------------------------------------------------------------
44  void RemoveItem()
45  {
46  IEntity child = GetChildren();
47  if (child)
48  {
49  RplComponent.DeleteRplEntity(child, false);
50  }
51  }
52 
53  //------------------------------------------------------------------------------------------------
57  bool CanSpawnItem(bool deleteExisting = false)
58  {
59  if (deleteExisting)
60  return true;
61 
62  return !GetChildren();
63  }
64 
65  //------------------------------------------------------------------------------------------------
73  // TODO: notnull itemResource & arsenalData
74  void SpawnNewItem(Resource itemResource, SCR_ArsenalItem arsenalData, SCR_ArsenalItemDisplayData itemDisplayData = null, bool deleteExisting = false)
75  {
76  IEntity child = GetChildren();
77  if (child)
78  {
79  if (deleteExisting)
80  RplComponent.DeleteRplEntity(child, false);
81  else
82  return;
83  }
84 
85  EntitySpawnParams params = new EntitySpawnParams();
86  params.Parent = this;
87  params.TransformMode = ETransformMode.WORLD;
88 
89  IEntity item = GetGame().SpawnEntityPrefab(itemResource, GetWorld(), params);
90  if (!item)
91  return;
92 
93  // Since item is in hierarchy in which parent (slotEntity) is not traceable (also has no volume), we'll have
94  // to clear its proxy flag so we can trace the item safely. Proxy flag is reset on pickup via item slots
95  item.ClearFlags(EntityFlags.PROXY);
96 
97  vector positionOffset, rotationOffset = vector.Zero;
98  if (itemDisplayData)
99  {
100  positionOffset = itemDisplayData.GetItemOffset();
101  rotationOffset = itemDisplayData.GetItemRotation();
102  }
103 
104  // set weapon rotation
105  item.SetAngles(rotationOffset);
106 
107  // offset the item locally
108  vector mat[4];
109  item.GetLocalTransform(mat);
110  mat[3] = mat[3] + positionOffset;
111  item.SetLocalTransform(mat);
112 
113  if (item.FindComponent(MagazineComponent))
114  item.SetFlags(EntityFlags.PROXY);
115 
116  item.ClearFlags(EntityFlags.ACTIVE);
117 
118  InventoryItemComponent itemComp = InventoryItemComponent.Cast(item.FindComponent(InventoryItemComponent));
119  if (itemComp)
120  {
121  itemComp.DisablePhysics();
122  }
123 
124  item.Update();
125 
126  m_eCurrentItemType = arsenalData.GetItemType();
127  m_eCurrentItemMode = arsenalData.GetItemMode();
128  }
129 
130  //------------------------------------------------------------------------------------------------
131  void SCR_WeaponRackSlotEntity(IEntitySource src, IEntity parent)
132  {
133  }
134 
135  //------------------------------------------------------------------------------------------------
137  {
138  }
139 
140 };
SCR_WeaponRackSlotEntity
Definition: SCR_WeaponRackSlotEntity.c:7
SCR_WeaponRackSlotEntityClass
Definition: SCR_WeaponRackSlotEntity.c:2
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_EArsenalItemMode
SCR_EArsenalItemMode
Definition: SCR_EArsenalItemMode.c:1
SCR_ArsenalItemDisplayData
Definition: SCR_ArsenalItemDisplayData.c:2
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
SCR_EArsenalItemType
SCR_EArsenalItemType
Definition: SCR_EArsenalItemType.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
InventoryItemComponent
Definition: InventoryItemComponent.c:12
GetChildren
void GetChildren(out array< SCR_ScenarioFrameworkLayerBase > children)
Definition: SCR_ScenarioFrameworkLayerBase.c:359
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_ArsenalItem
Definition: SCR_ArsenalItem.c:2
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180