Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ArmExplosiveChargeWithRemoteFuzeAction.c
Go to the documentation of this file.
2{
3 protected SCR_DetonatorGadgetComponent m_HeldDetonatorComp;
4 protected bool m_bInProgress;
5
6 //------------------------------------------------------------------------------------------------
7 override bool CanBeShownScript(IEntity user)
8 {
9 if (!super.CanBeShownScript(user))
10 return false;
11
12 if (m_bInProgress)
13 return false;
14
16 if (!character)
17 return false;
18
19 CharacterControllerComponent charController = character.GetCharacterController();
20 if (!charController || charController.IsChangingItem())
21 return false;
22
23 IEntity item = charController.GetAttachedGadgetAtLeftHandSlot();
24 if (!item)
25 return false;
26
27 m_HeldDetonatorComp = SCR_DetonatorGadgetComponent.Cast(item.FindComponent(SCR_DetonatorGadgetComponent));
29 return false;
30
31 return true;
32 }
33
34 //------------------------------------------------------------------------------------------------
35 override bool CanBePerformedScript(IEntity user)
36 {
37 if (!super.CanBePerformedScript(user))
38 return false;
39
41 return false;
42
43 if (m_HeldDetonatorComp.IsAttachedToTheDetonator(m_ChargeComp.GetRplId()))
44 {
45 UIInfo actionInfo = GetUIInfo();
46 if (!actionInfo)
47 return false;
48
49 SetCannotPerformReason(actionInfo.GetDescription());
50 return false;
51 }
52
53 if (m_ChargeComp.GetUsedFuzeType() != SCR_EFuzeType.NONE)
54 {
56 return false;
57 }
58
59 return true;
60 }
61
62 //------------------------------------------------------------------------------------------------
63 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
64 {
65 if (!pUserEntity || !m_ChargeComp)
66 return;
67
68 if (!m_ChargeComp.GetRplId().IsValid())
69 return;
70
72 if (!character)
73 return;
74
75 CharacterControllerComponent charController = character.GetCharacterController();
76 if (!charController || charController.IsChangingItem())
77 return;
78
79 IEntity item = charController.GetAttachedGadgetAtLeftHandSlot();
80 if (!item)
81 return;
82
83 m_HeldDetonatorComp = SCR_DetonatorGadgetComponent.Cast(item.FindComponent(SCR_DetonatorGadgetComponent));
84 if (!m_HeldDetonatorComp)//we need to do this as other clients will also execute this code and they need to have newest detonator
85 return;
86
87 super.PerformAction(pOwnerEntity, pUserEntity);
88 }
89
90 //------------------------------------------------------------------------------------------------
91 override void AnimateUsage(IEntity pUserEntity)
92 {
93 m_bInProgress = true;
94 super.AnimateUsage(pUserEntity);
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override void ProcesFinished(IEntity item, bool successful, ItemUseParameters animParams)
99 {
100 super.ProcesFinished(item, successful, animParams);
101 m_bInProgress = false;
102 if (!successful)
103 return;
104
106 return;
107
108 m_HeldDetonatorComp.ConnectNewCharge(m_ChargeComp.GetRplId());
109
110 if (m_ChargeComp.GetTrigger())
111 m_ChargeComp.GetTrigger().SetUser(m_ActionUser);
112
113 RplId detonatorId = Replication.FindItemId(m_HeldDetonatorComp);
114 if (detonatorId.IsValid())
115 m_ChargeComp.ConnectDetonator(SCR_EFuzeType.REMOTE, detonatorId);
116 }
117
118 //------------------------------------------------------------------------------------------------
119 override bool GetActionNameScript(out string outName)
120 {
121 UIInfo actionInfo = GetUIInfo();
122 if (!actionInfo)
123 return false;
124
126 return false;
127
129 if (!detonatorIIC)
130 return false;
131
132 UIInfo detonatorUiInfo = detonatorIIC.GetUIInfo();
133 if (!detonatorUiInfo)
134 return false;
135
136 outName = WidgetManager.Translate(actionInfo.GetName(), detonatorUiInfo.GetName());
137
138 return true;
139 }
140}
SCR_EFuzeType
Enum with all types of fuzes.
void SetCannotPerformReason(string reason)
proto external Managed FindComponent(typename typeName)
Main replication API.
Definition Replication.c:14
Replication item identifier.
Definition RplId.c:14
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
override void ProcesFinished(IEntity item, bool successful, ItemUseParameters animParams)
SCR_ExplosiveChargeComponent m_ChargeComp
UIInfo - allows to define UI elements.
Definition UIInfo.c:14