4 [
Attribute(
"30",
"Arming delay in seconds.")]
5 protected float m_fArmingDelay;
7 [
Attribute(
"10",
"How long the user action will be shown as inactive after starting arming.")]
8 protected float m_fArmingProtectionTime;
12 protected bool m_bCanArm =
true;
15 void OrientToForward(vector forward, vector mat[4])
17 vector origin = mat[3];
20 Math3D.AnglesToMatrix(Vector(forward.VectorToAngles()[0], 0, 0), basis);
21 Math3D.MatrixMultiply3(mat, basis, mat);
32 vector GetGroundNormal(notnull IEntity owner)
34 vector pos = owner.GetOrigin();
36 if (normal != vector.Zero)
43 protected bool CheckAngle(vector up)
45 if (vector.Dot(up, vector.Up) < 0.5)
52 protected void SnapToGround(IEntity user, out vector normal)
56 owner.GetTransform(mat);
58 SCR_PlaceableInventoryItemComponent item = SCR_PlaceableInventoryItemComponent.Cast(owner.FindComponent(SCR_PlaceableInventoryItemComponent));
60 item.SnapToGround(normal, {user}, startOffset: mat[1] * 0.1,
direction: -mat[1]);
64 override event void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
67 GetGame().GetCallqueue().CallLater(AllowArming, 1000 * m_fArmingProtectionTime);
69 vector matUser[4], mat[4];
70 pUserEntity.GetTransform(matUser);
72 vector normal = vector.Zero;
73 SnapToGround(pUserEntity, normal);
75 pOwnerEntity.GetTransform(mat);
77 OrientToForward(matUser[2], mat);
78 pOwnerEntity.SetTransform(mat);
80 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
84 Print(
"Non-ChimeraCharacter user tried using SCR_ActivateMineUserAction!", LogLevel.WARNING);
88 SCR_PressureTriggerComponent pressureTrigger = SCR_PressureTriggerComponent.Cast(pOwnerEntity.FindComponent(SCR_PressureTriggerComponent));
92 pressureTrigger.SetUser(pUserEntity);
94 CharacterControllerComponent charController = character.GetCharacterController();
97 CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent();
98 int itemActionId = pAnimationComponent.BindCommand(
"CMD_Item_Action");
99 vector charWorldMat[4];
100 pUserEntity.GetWorldTransform(charWorldMat);
101 charWorldMat[3] = pOwnerEntity.GetOrigin();
102 PointInfo ptWS =
new PointInfo();
103 ptWS.Set(
null,
"", charWorldMat);
106 params.SetEntity(pOwnerEntity);
107 params.SetAllowMovementDuringAction(
false);
108 params.SetKeepInHandAfterSuccess(
true);
109 params.SetCommandID(itemActionId);
110 params.SetCommandIntArg(3);
111 params.SetCommandFloatArg(0.0);
112 params.SetMaxAnimLength(15.0);
113 params.SetAlignmentPoint(ptWS);
115 charController.TryUseItemOverrideParams(
params);
118 pOwnerEntity.GetTransform(mat);
122 protected bool IsUnderWater()
128 override bool CanBePerformedScript(IEntity user)
133 if (IsUnderWater() || !CheckAngle(mat[1]))
136 if (Math.AbsFloat(mat[3][1] - user.GetOrigin()[1]) > 0.4)
143 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
149 override bool CanBeShownScript(IEntity user)
154 SCR_PressureTriggerComponent mineTriggerComponent = SCR_PressureTriggerComponent.Cast(
GetOwner().FindComponent(SCR_PressureTriggerComponent));
155 if (!mineTriggerComponent)
158 if (mineTriggerComponent.IsActivated())
161 return super.CanBeShownScript(user);