Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_GarbageSystem.c
Go to the documentation of this file.
1
3{
4 protected const float RESOURCE_LIFETIME_PERCENTAGE = 0.25;
5
6 //------------------------------------------------------------------------------------------------
7 override protected float OnInsertRequested(IEntity entity, float lifetime)
8 {
9 // If a something has at least 25% of its supply capacity double the lifetime.
10 const SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.FindResourceComponent(entity);
11 if (resourceComponent)
12 {
13 const SCR_ResourceContainer container = resourceComponent.GetContainer(EResourceType.SUPPLIES);
14 if (container && (container.GetMaxResourceValue() > 0))
15 {
17 {
18 lifetime *= 2;
19 }
20 else // Subscribe for changes that might increase the lifetime later
21 {
23 }
24 }
25 }
26
27 return lifetime;
28 }
29
30 //------------------------------------------------------------------------------------------------
32 {
33 const float max = container.GetMaxResourceValue();
34 if ((max > 0) && ((container.GetResourceValue() / max) > RESOURCE_LIFETIME_PERCENTAGE))
35 {
37 const IEntity vehicle = container.GetOwner().GetRootParent();
38 Bump(vehicle, GetLifetime(vehicle));
39 }
40 }
41
42 //------------------------------------------------------------------------------------------------
44 {
45 SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
46 if (!resourceComponent)
47 {
48 SlotManagerComponent slotManager = SlotManagerComponent.Cast(entity.FindComponent(SlotManagerComponent));
49 if (!slotManager)
50 return null;
51
52 EntitySlotInfo slot = slotManager.GetSlotByName("Cargo");
53 if (!slot)
54 return null;
55
56 entity = slot.GetAttachedEntity();
57 if (!entity)
58 return null;
59
60 resourceComponent = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
61 }
62
63 if (!resourceComponent)
64 return null;
65
66 return resourceComponent.GetContainer(resourceType);
67 }
68
69 //------------------------------------------------------------------------------------------------
71 {
72 ChimeraWorld world = ChimeraWorld.CastFrom(entity.GetWorld());
73 if (!world)
74 return null;
75
76 return SCR_GarbageSystem.Cast(world.GetGarbageSystem());
77 }
78}
Adds ability to attach an object to a slot.
proto external BaseWorld GetWorld()
Script entry for garbage system modding.
SCR_ResourceContainer FindVehicleResourceContainer(notnull IEntity entity, EResourceType resourceType)
static SCR_GarbageSystem GetByEntityWorld(IEntity entity)
float OnInsertRequested(IEntity entity, float lifetime)
const float RESOURCE_LIFETIME_PERCENTAGE
void HandleVehicleResourcesChanged(SCR_ResourceContainer container)
ScriptInvoker GetOnResourcesChanged()