Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ExplosiveChargeAction.c
Go to the documentation of this file.
2{
3 [Attribute("CMD_Item_Action", desc: "Name of the command that will be used to bind usage animation")]
4 protected string m_sUseItemCommandName;
5
6 [Attribute("#AR-UserAction_ExplosiveCharge_ArmedWithDifferentFuze", desc: "Localized string of the text that will be shown when charge is armed with different fuze")]
8
11
12 protected const float MAX_ALLOWED_ANIMATION_DISTANCE = 0.3;
13
14 //------------------------------------------------------------------------------------------------
15 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
16 {
18 }
19
20 //------------------------------------------------------------------------------------------------
21 override bool CanBeShownScript(IEntity user)
22 {
23 if (!m_ChargeComp)
24 return false;
25
26 if (!m_ChargeComp.GetTrigger())
27 return false;
28
29 return true;
30 }
31
32 //------------------------------------------------------------------------------------------------
33 override bool CanBePerformedScript(IEntity user)
34 {
35 if (!m_ChargeComp.GetRplId().IsValid())
36 return false;
37
38 return true;
39 }
40
41 //------------------------------------------------------------------------------------------------
42 override bool GetActionNameScript(out string outName)
43 {
44 UIInfo actionInfo = GetUIInfo();
45 if (!actionInfo)
46 return false;
47
48 outName = actionInfo.GetName();
49
50 return true;
51 }
52
53 //------------------------------------------------------------------------------------------------
54 override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
55 {
56 m_ActionUser = ChimeraCharacter.Cast(pUserEntity);
57 if (!m_ActionUser)
58 return;
59
60 if (m_sUseItemCommandName != string.Empty)
61 AnimateUsage(pUserEntity);
62 else
63 ProcesFinished(GetOwner(), true, null);
64 }
65
66 //------------------------------------------------------------------------------------------------
67 protected void AnimateUsage(IEntity pUserEntity)
68 {
69 SCR_CharacterControllerComponent charController = SCR_CharacterControllerComponent.Cast(m_ActionUser.GetCharacterController());
70 if (!charController)
71 return;
72
73 CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent();
74 int itemActionId = pAnimationComponent.BindCommand(m_sUseItemCommandName);
75 vector charWorldMat[4];
76 pUserEntity.GetWorldTransform(charWorldMat);
77 float lerpFactor = vector.DistanceXZ(charWorldMat[3], GetOwner().GetOrigin());
78 lerpFactor = Math.Clamp((lerpFactor - MAX_ALLOWED_ANIMATION_DISTANCE) / lerpFactor, 0.01, 1);
79 charWorldMat[3][0] = Math.Lerp(charWorldMat[3][0], GetOwner().GetOrigin()[0], lerpFactor);
80 charWorldMat[3][2] = Math.Lerp(charWorldMat[3][2], GetOwner().GetOrigin()[2], lerpFactor);
81 PointInfo ptWS = new PointInfo();
82 ptWS.Set(null, "", charWorldMat);
83
85 params.SetEntity(GetOwner());
86 params.SetAllowMovementDuringAction(false);
87 params.SetKeepInHandAfterSuccess(true);
88 params.SetCommandID(itemActionId);
89 params.SetCommandIntArg(3);
90 params.SetCommandFloatArg(0.0);
91 params.SetAlignmentPoint(ptWS);
92
93 charController.TryUseItemOverrideParams(params);
94 charController.m_OnItemUseEndedInvoker.Insert(ProcesFinished);
95 }
96
97 //------------------------------------------------------------------------------------------------
99 void ProcesFinished(IEntity item, bool successful, ItemUseParameters animParams)
100 {
101 if (!m_ActionUser)
102 return;
103
104 SCR_CharacterControllerComponent characterController = SCR_CharacterControllerComponent.Cast(m_ActionUser.GetCharacterController());
105 if (!characterController)
106 return;
107
108 characterController.m_OnItemUseEndedInvoker.Remove(ProcesFinished);
109 }
110}
vector GetOrigin()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external IEntity GetOwner()
Returns the parent entity of this action.
proto external UIInfo GetUIInfo()
Returns the UIInfo set for this user action or null if none.
proto external Managed FindComponent(typename typeName)
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
Definition Math.c:13
PointInfo - allows to define position.
Definition PointInfo.c:9
override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
override bool CanBeShownScript(IEntity user)
override bool GetActionNameScript(out string outName)
void AnimateUsage(IEntity pUserEntity)
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
void ProcesFinished(IEntity item, bool successful, ItemUseParameters animParams)
Called by everyone when process was finished.
SCR_ExplosiveChargeComponent m_ChargeComp
override bool CanBePerformedScript(IEntity user)
A scripted action class having optional logic to check if vehicle is valid.
UIInfo - allows to define UI elements.
Definition UIInfo.c:14
SCR_FieldOfViewSettings Attribute