Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ResourceGeneratorActionDropContainers.c
Go to the documentation of this file.
3{
4 [Attribute(defvalue: "0 0 0", uiwidget: UIWidgets.Coords, params: "inf inf 0 purpose=coords space=entity")]
6
7 [Attribute(defvalue: "10.0", uiwidget: UIWidgets.SpinBox, params: "0.0 inf 1.0")]
8 protected float m_fSpawnRadius;
9
10 [Attribute("", UIWidgets.ResourceNamePicker, "Resource Container Prefab to be used as the dropped container.", "et")]
12
13 //------------------------------------------------------------------------------------------------
16 {
17 return "{A8A4609979D3385D}Prefabs/Props/Military/SupplyBox/SupplyStack/SupplyStack_Small_01/SupplyStack_Small_01_item.et";
18 }
19
20 //------------------------------------------------------------------------------------------------
22 {
23 return false;
24 }
25
26 //------------------------------------------------------------------------------------------------
27 override float ComputeGeneratedResources(notnull SCR_ResourceGenerator generator, float resourceValue)
28 {
29 return resourceValue;
30 }
31
32 //------------------------------------------------------------------------------------------------
39 protected SCR_ResourceContainer SpawnContainer(notnull SCR_ResourceGenerator generator, inout float resourceValue)
40 {
42 {
43 Debug.Error2(ClassName() + " is misconfigured!.", "The generation action for dropping a container must have a Resource Container Prefab to be used as the dropped container.");
44
45 return null;
46 }
47
48 vector position = generator.GetOwnerOrigin();
50
51 const EntitySpawnParams spawnParams = new EntitySpawnParams();
52 spawnParams.TransformMode = ETransformMode.WORLD;
53 spawnParams.Transform[3] = position;
54 IEntity containerEntity;
55
56 if (m_sResourceContainerPrefab.IsEmpty())
57 containerEntity = GetGame().SpawnEntityPrefab(Resource.Load(GetDefaultPrefab()), GetGame().GetWorld(), spawnParams);
58 else
59 containerEntity = GetGame().SpawnEntityPrefab(Resource.Load(m_sResourceContainerPrefab), GetGame().GetWorld(), spawnParams);
60
61 if (!containerEntity)
62 {
63 Debug.Error2(ClassName() + " is misconfigured!.", "The generation action for dropping a container must have a valid prefab to spawn.");
64
65 return null;
66 }
67
68 const SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(containerEntity);
69
70 if (!resourceComponent)
71 {
72 Debug.Error2(ClassName() + " is misconfigured!.", "The generation action for dropping a container must have prefab to spawn that has a Resource Component.");
73
74 return null;
75 }
76
77 const SCR_ResourceContainer container = resourceComponent.GetContainer(generator.GetResourceType());
78
79 if (!container)
80 {
81 Debug.Error2(ClassName() + " is misconfigured!.", "The generation action for dropping a container must have prefab to spawn that has a Resource Container of the same type as the Resource Generator.");
82
83 return null;
84 }
85
86 return container;
87 }
88
89 //------------------------------------------------------------------------------------------------
94 protected void ProcessContainer(notnull SCR_ResourceContainer container, inout float resourceValue)
95 {
96 container.SetResourceValue(resourceValue);
97
98 resourceValue -= container.GetResourceValue();
99 }
100
101 //------------------------------------------------------------------------------------------------
102 override void PerformAction(notnull SCR_ResourceGenerator generator, inout float resourceValue)
103 {
104 SCR_ResourceContainer container;
105
106 while (resourceValue > 0)
107 {
108 container = SpawnContainer(generator, resourceValue);
109
110 if (!container)
111 break;
112
113 ProcessContainer(container, resourceValue);
114 }
115 }
116}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
vector position
proto native owned external string ClassName()
Definition Debug.c:13
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
override float ComputeGeneratedResources(notnull SCR_ResourceGenerator generator, float resourceValue)
void ProcessContainer(notnull SCR_ResourceContainer container, inout float resourceValue)
override void PerformAction(notnull SCR_ResourceGenerator generator, inout float resourceValue)
SCR_ResourceContainer SpawnContainer(notnull SCR_ResourceGenerator generator, inout float resourceValue)
static void FindSuitablePosition(inout vector position, float maxHorizontalOffset, float maxVerticalOffset)
void EntitySpawnParams()
Definition gameLib.c:130
SCR_FieldOfViewSettings Attribute
proto native bool IsEmpty()