Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_GarbageSystem.c
Go to the documentation of this file.
1
2
class
SCR_GarbageSystem
:
GarbageSystem
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
{
16
if
((container.
GetResourceValue
() / container.
GetMaxResourceValue
()) >
RESOURCE_LIFETIME_PERCENTAGE
)
17
{
18
lifetime *= 2;
19
}
20
else
// Subscribe for changes that might increase the lifetime later
21
{
22
container.
GetOnResourcesChanged
().Insert(
HandleVehicleResourcesChanged
);
23
}
24
}
25
}
26
27
return
lifetime;
28
}
29
30
//------------------------------------------------------------------------------------------------
31
protected
void
HandleVehicleResourcesChanged
(
SCR_ResourceContainer
container)
32
{
33
const
float
max = container.
GetMaxResourceValue
();
34
if
((max > 0) && ((container.
GetResourceValue
() / max) >
RESOURCE_LIFETIME_PERCENTAGE
))
35
{
36
container.
GetOnResourcesChanged
().Remove(
HandleVehicleResourcesChanged
);
37
const
IEntity
vehicle = container.GetOwner().GetRootParent();
38
Bump(vehicle, GetLifetime(vehicle));
39
}
40
}
41
42
//------------------------------------------------------------------------------------------------
43
protected
SCR_ResourceContainer
FindVehicleResourceContainer
(notnull
IEntity
entity,
EResourceType
resourceType)
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
//------------------------------------------------------------------------------------------------
70
static
SCR_GarbageSystem
GetByEntityWorld
(
IEntity
entity)
71
{
72
ChimeraWorld
world =
ChimeraWorld
.CastFrom(entity.
GetWorld
());
73
if
(!world)
74
return
null;
75
76
return
SCR_GarbageSystem
.Cast(world.GetGarbageSystem());
77
}
78
}
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
ChimeraWorld
Definition
ChimeraWorld.c:13
EntitySlotInfo
Adds ability to attach an object to a slot.
Definition
EntitySlotInfo.c:9
GarbageSystem
Definition
GarbageSystem.c:13
IEntity
Definition
IEntity.c:13
IEntity::GetWorld
proto external BaseWorld GetWorld()
SCR_GarbageSystem
Script entry for garbage system modding.
Definition
SCR_GarbageSystem.c:3
SCR_GarbageSystem::FindVehicleResourceContainer
SCR_ResourceContainer FindVehicleResourceContainer(notnull IEntity entity, EResourceType resourceType)
Definition
SCR_GarbageSystem.c:43
SCR_GarbageSystem::GetByEntityWorld
static SCR_GarbageSystem GetByEntityWorld(IEntity entity)
Definition
SCR_GarbageSystem.c:70
SCR_GarbageSystem::OnInsertRequested
float OnInsertRequested(IEntity entity, float lifetime)
Definition
SCR_GarbageSystem.c:7
SCR_GarbageSystem::RESOURCE_LIFETIME_PERCENTAGE
const float RESOURCE_LIFETIME_PERCENTAGE
Definition
SCR_GarbageSystem.c:4
SCR_GarbageSystem::HandleVehicleResourcesChanged
void HandleVehicleResourcesChanged(SCR_ResourceContainer container)
Definition
SCR_GarbageSystem.c:31
SCR_ResourceContainer
Definition
SCR_ResourceContainer.c:35
SCR_ResourceContainer::GetResourceValue
float GetResourceValue()
Definition
SCR_ResourceContainer.c:95
SCR_ResourceContainer::GetMaxResourceValue
float GetMaxResourceValue()
Definition
SCR_ResourceContainer.c:101
SCR_ResourceContainer::GetOnResourcesChanged
ScriptInvoker GetOnResourcesChanged()
Definition
SCR_ResourceContainer.c:322
scripts
Game
Systems
SCR_GarbageSystem.c
Generated by
1.17.0