Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AdjustShellChargeRingsAction.c
Go to the documentation of this file.
2{
3 protected SCR_MortarShellGadgetComponent m_ShellGadgetComp;
6 protected int m_iDefaultConfigId;
7
8 //------------------------------------------------------------------------------------------------
9 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
10 {
11 m_ShellGadgetComp = SCR_MortarShellGadgetComponent.Cast(pOwnerEntity.FindComponent(SCR_MortarShellGadgetComponent));
13 {
15 m_iDefaultConfigId = data.FindDefaultChargeRingConfig();
16 }
17
18 super.Init(pOwnerEntity, pManagerComponent);
19 }
20
21 //------------------------------------------------------------------------------------------------
22 override bool CanBeShownScript(IEntity user)
23 {
24 ChimeraCharacter character = ChimeraCharacter.Cast(user);
25 if (!character)
26 return false;
27
28 CharacterControllerComponent characterController = character.GetCharacterController();
29 if (!characterController || characterController.GetInspectEntity() != GetOwner())
30 return false;
31
32 if (!m_ShellGadgetComp || m_ShellGadgetComp.GetNumberOfChargeRingConfigurations() < 2)
33 return false;
34
35 if (!m_ShellConfig)
36 m_ShellConfig = m_ShellGadgetComp.GetSavedConfig(character);
37
38 return super.CanBeShownScript(user);
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override bool GetActionNameScript(out string outName)
43 {
45 return false;
46
47 UIInfo actionInfo = GetUIInfo();
48 if (!actionInfo)
49 return false;
50
51 if (!m_ShellConfig || m_ShellConfig.GetChargeRingConfigId() == -1 || m_ShellConfig.GetChargeRingConfigId() != m_ShellGadgetComp.GetCurentChargeRingConfigId() || m_ShellConfig.GetChargeRingConfigId() == m_iDefaultConfigId)
52 outName = WidgetManager.Translate(actionInfo.GetName(), m_ShellGadgetComp.GetCurentChargeRingConfig()[0].ToString(0, 0));
53 else
54 outName = WidgetManager.Translate(actionInfo.GetDescription(), m_ShellGadgetComp.GetChargeRingConfig(m_ShellConfig.GetChargeRingConfigId())[0].ToString(0, 0));
55
56 return true;
57 }
58
59 //------------------------------------------------------------------------------------------------
60 override void OnActionStart(IEntity pUserEntity)
61 {
62 m_Character = ChimeraCharacter.Cast(pUserEntity);
63
65 m_fTargetValue = m_ShellGadgetComp.GetCurentChargeRingConfigId();
66
67 super.OnActionStart(pUserEntity);
68 }
69
70 //------------------------------------------------------------------------------------------------
71 protected override float SCR_GetCurrentValue()
72 {
74 return m_ShellGadgetComp.GetCurentChargeRingConfigId();
75
76 return GetCurrentValue();
77 }
78
79 //------------------------------------------------------------------------------------------------
80 protected override float SCR_GetMinimumValue()
81 {
82 return 0;
83 }
84
85 //------------------------------------------------------------------------------------------------
86 protected override float SCR_GetMaximumValue()
87 {
89 return m_ShellGadgetComp.GetNumberOfChargeRingConfigurations() - 1;
90
91 return GetMaximumValue();
92 }
93
94 //------------------------------------------------------------------------------------------------
95 protected override bool OnSaveActionData(ScriptBitWriter writer)
96 {
97 if (m_fTargetValue == m_ShellGadgetComp.GetCurentChargeRingConfigId())
98 return false;
99
100 if (!super.OnSaveActionData(writer))
101 return false;
102
104 {
105 SCR_CharacterControllerComponent controller = SCR_CharacterControllerComponent.Cast(m_Character.GetCharacterController());
106 if (!controller)
107 return true;
108
109 EntityPrefabData shellPrefab = GetOwner().GetPrefabData();
110 if (!shellPrefab)
111 return true;
112
113 int savedValue = m_fTargetValue;
114 if (savedValue < 0 || savedValue > SCR_GetMaximumValue() || savedValue == m_iDefaultConfigId)
115 savedValue = -1;
116
117 SCR_ShellConfig savedConfig = controller.GetSavedShellConfig(shellPrefab);
118 if (!savedConfig)
119 savedConfig = new SCR_ShellConfig(shellPrefab, 0, false, savedValue);
120 else
121 savedConfig.SetChargeRingConfigId(savedValue);
122
123 controller.SetShellConfig(savedConfig);
124 }
125
126 return true;
127 }
128
129 //------------------------------------------------------------------------------------------------
130 protected override bool OnLoadActionData(ScriptBitReader reader)
131 {
132 if (!super.OnLoadActionData(reader))
133 return false;
134
136 m_ShellGadgetComp.SetChargeRingConfig(m_fTargetValue, false, false);
137
138 return true;
139 }
140}
Get all prefabs that have the spawner data
proto external Managed FindComponent(typename typeName)
proto external EntityPrefabData GetPrefabData()
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
override bool OnLoadActionData(ScriptBitReader reader)
override bool GetActionNameScript(out string outName)
override bool OnSaveActionData(ScriptBitWriter writer)
override void OnActionStart(IEntity pUserEntity)
SCR_MortarShellGadgetComponent m_ShellGadgetComp
float m_fTargetValue
Normalized current value.
SCR_ShellConfig GetSavedShellConfig(notnull EntityPrefabData shellPrefab)
void SetShellConfig(notnull SCR_ShellConfig config)
void SetChargeRingConfigId(int configId)
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
IEntity GetOwner()
Owner entity of the fuel tank.