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_ScenarioFrameworkActionOnResourceConsumerChange.c
Go to the documentation of this file.
1
[
BaseContainerProps
(),
SCR_ContainerActionTitle
()]
2
class
SCR_ScenarioFrameworkActionOnResourceConsumerChange
:
SCR_ScenarioFrameworkActionBase
3
{
4
[
Attribute
(
desc
:
"Target entity to manipulate supply (Optional if action is attached on Slot that spawns target entity)"
)]
5
ref
SCR_ScenarioFrameworkGet
m_Getter;
6
7
[
Attribute
(
desc
:
"Actions that will be executed on compartment entered"
,
UIWidgets
.Auto)]
8
ref array<ref SCR_ScenarioFrameworkActionBase> m_aActions;
9
10
[
Attribute
(defvalue:
"0"
,
desc
:
"Activation amount"
,
params
:
"0 inf 0.01"
)]
11
int
m_iActivationAmount;
12
13
[
Attribute
(defvalue:
"0"
,
desc
:
"Operator"
, uiwidget:
UIWidgets
.ComboBox, enumType:
SCR_EScenarioFrameworkComparisonOperator
)]
14
SCR_EScenarioFrameworkComparisonOperator
m_eComparisonOperator;
15
16
IEntity
m_SupplyHolderEntity;
17
ref
SCR_ResourceSystemSubscriptionHandleBase
m_Handle;
18
19
//------------------------------------------------------------------------------------------------
20
override
void
OnActivate
(
IEntity
object
)
21
{
22
if
(!CanActivate())
23
return
;
24
25
if
(!ValidateInputEntity(
object
, m_Getter, m_SupplyHolderEntity))
26
return
;
27
28
SCR_ResourceComponent resourceComponent = SCR_ResourceComponent.Cast(m_SupplyHolderEntity.FindComponent(SCR_ResourceComponent));
29
if
(!resourceComponent)
30
return
;
31
32
SCR_ResourceConsumer consumer = resourceComponent.GetConsumer(
EResourceGeneratorID
.DEFAULT_STORAGE,
EResourceType
.SUPPLIES);
33
if
(!consumer)
34
{
35
if
(
object
)
36
Print
(
string
.Format(
"ScenarioFramework Action: No resource consumer found for Action %1 attached on %2."
,
this
,
object
.
GetName
()),
LogLevel
.ERROR);
37
else
38
Print
(
string
.Format(
"ScenarioFramework Action: No resource consumer Managers found for Action %1."
,
this
),
LogLevel
.ERROR);
39
40
return
;
41
}
42
43
consumer.GetOnResourcesChanged().Insert(OnResourceChanged);
44
m_Handle =
GetGame
().GetResourceSystemSubscriptionManager().RequestSubscriptionListenerHandle(consumer,
Replication
.FindItemId(
GetGame
().
GetPlayerController
().FindComponent(
SCR_ResourcePlayerControllerInventoryComponent
)));
45
}
46
47
//------------------------------------------------------------------------------------------------
48
void
OnResourceChanged(SCR_ResourceInteractor interactor,
float
previousValue)
49
{
50
SCR_ResourceConsumer consumer = SCR_ResourceConsumer.Cast(interactor);
51
if
(!consumer)
52
return
;
53
54
float
current = consumer.GetAggregatedResourceValue();
55
56
if
(((m_eComparisonOperator ==
SCR_EScenarioFrameworkComparisonOperator
.LESS_THAN) && (current < m_iActivationAmount)) || ((m_eComparisonOperator ==
SCR_EScenarioFrameworkComparisonOperator
.LESS_OR_EQUAL) && (current <= m_iActivationAmount)) || ((m_eComparisonOperator ==
SCR_EScenarioFrameworkComparisonOperator
.EQUAL) && (current == m_iActivationAmount)) || ((m_eComparisonOperator ==
SCR_EScenarioFrameworkComparisonOperator
.GREATER_OR_EQUAL) && (current >= m_iActivationAmount)) ||((m_eComparisonOperator ==
SCR_EScenarioFrameworkComparisonOperator
.GREATER_THEN) && (current > m_iActivationAmount)))
57
{
58
foreach
(
SCR_ScenarioFrameworkActionBase
action : m_aActions)
59
{
60
action.Init(m_SupplyHolderEntity);
61
}
62
}
63
}
64
65
//------------------------------------------------------------------------------------------------
70
SCR_ResourceConsumer GetContainer(notnull
IEntity
entity, out SCR_ResourceComponent component)
71
{
72
component = SCR_ResourceComponent.Cast(entity.FindComponent(SCR_ResourceComponent));
73
SCR_ResourceConsumer consumer;
74
75
if
(component)
76
{
77
consumer = component.GetConsumer(
EResourceGeneratorID
.DEFAULT,
EResourceType
.SUPPLIES);
78
if
(consumer)
79
return
consumer;
80
}
81
82
IEntity
iteratedEntity = entity.
GetChildren
();
83
while
(iteratedEntity)
84
{
85
component = SCR_ResourceComponent.Cast(iteratedEntity.
FindComponent
(SCR_ResourceComponent));
86
if
(component)
87
{
88
consumer = component.GetConsumer(
EResourceGeneratorID
.DEFAULT,
EResourceType
.SUPPLIES);
89
if
(consumer)
90
return
consumer;
91
}
92
93
iteratedEntity = iteratedEntity.
GetSibling
();
94
}
95
96
return
null;
97
}
98
99
//------------------------------------------------------------------------------------------------
100
override
array<ref SCR_ScenarioFrameworkActionBase> GetSubActions()
101
{
102
return
m_aActions;
103
}
104
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
BaseContainerProps
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Definition
SCR_AIAnimationWaypoint.c:14
OnActivate
override void OnActivate()
Definition
SCR_CharacterCommandLoiter.c:31
SCR_EScenarioFrameworkComparisonOperator
SCR_EScenarioFrameworkComparisonOperator
Definition
SCR_EScenarioFrameworkComparisonOperator.c:2
GetName
string GetName()
Definition
SCR_NotificationSenderComponent.c:15
EResourceType
EResourceType
Definition
SCR_ResourceContainer.c:2
EResourceGeneratorID
EResourceGeneratorID
Definition
SCR_ResourceGenerator.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetChildren
proto external IEntity GetChildren()
IEntity::GetSibling
proto external IEntity GetSibling()
Replication
Main replication API.
Definition
Replication.c:14
SCR_ContainerActionTitle
Definition
SCR_ContainerActionTitle.c:2
SCR_ResourcePlayerControllerInventoryComponent
Definition
SCR_ResourcePlayerControllerInventoryComponent.c:25
SCR_ResourceSystemSubscriptionHandleBase
Definition
SCR_ResourceSystemSubscriptionHandleBase.c:2
SCR_ScenarioFrameworkActionBase
Definition
SCR_ScenarioFrameworkActionBase.c:3
SCR_ScenarioFrameworkActionOnResourceConsumerChange
Definition
SCR_ScenarioFrameworkActionOnResourceConsumerChange.c:3
SCR_ScenarioFrameworkGet
Definition
SCR_ScenarioFrameworkGet.c:3
UIWidgets
Definition
attributes.c:40
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
GetPlayerController
proto external PlayerController GetPlayerController()
Definition
SCR_PlayerDeployMenuHandlerComponent.c:307
scripts
Game
ScenarioFramework
Actions
ResourceComponentActions
SCR_ScenarioFrameworkActionOnResourceConsumerChange.c
Generated by
1.17.0