4 [
Attribute(
"1",
desc:
"If action is Continuous and duration is less than 0 than the UI process bar goes to 0 again if it reaches the perform action amount")]
5 protected bool m_bLoopAction;
7 [
Attribute(
"0.25",
desc:
"If action is looping this will be used to delay the action after it reaches 100% to prevent the action from instantly looping",
params:
"0 inf")]
8 protected float m_fLoopActionHoldDuration;
10 [
Attribute(
"0",
desc:
"Using this action should automatically lower player weapon")]
11 protected bool m_bLowerWeaponOnUse;
13 [
Attribute(
"0",
desc:
"When can the action be shown regarding the vehicle you are in. Note only checked for vehicle that the action is attached to. IGNORE will never check vehicle state", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EUserActionInVehicleState))]
14 protected EUserActionInVehicleState m_eShownInVehicleState;
16 [
Attribute(
"1",
desc:
"Whether this action can only be performed by occupants of the same vehicle (if in vehicle)", uiwidget: UIWidgets.CheckBox)]
17 protected bool m_bSameVehicleOnly;
22 protected float m_fLoopProgress;
23 protected float m_fLoopProgressSmoothVelocity;
28 if (m_eShownInVehicleState == EUserActionInVehicleState.IGNORE)
32 ChimeraCharacter character = ChimeraCharacter.Cast(
GetOwner());
35 character = ChimeraCharacter.Cast(user);
41 CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
46 if (compAccess.IsGettingIn() || compAccess.IsGettingOut())
50 bool isCharacterInVehicle = character.IsInVehicle();
53 switch (m_eShownInVehicleState)
56 case EUserActionInVehicleState.NOT_IN_VEHICLE :
58 if (isCharacterInVehicle)
64 case EUserActionInVehicleState.IN_VEHICLE_ANY :
66 if (!isCharacterInVehicle)
72 case EUserActionInVehicleState.IN_VEHICLE_PILOT :
74 if (!isCharacterInVehicle || compAccess.GetCompartment().GetType() !=
ECompartmentType.Pilot)
80 case EUserActionInVehicleState.IN_VEHICLE_CARGO :
82 if (!isCharacterInVehicle || compAccess.GetCompartment().GetType() !=
ECompartmentType.Cargo)
88 case EUserActionInVehicleState.IN_VEHICLE_TURRET :
90 if (!isCharacterInVehicle || compAccess.GetCompartment().GetType() !=
ECompartmentType.Turret)
98 if (isCharacterInVehicle && m_bSameVehicleOnly)
99 return IsSameVehicleOrNone(character);
106 protected bool IsSameVehicleOrNone(notnull IEntity user)
110 CompartmentAccessComponent userCompAccess;
113 ChimeraCharacter userCharacter = ChimeraCharacter.Cast(user);
115 userCompAccess = userCharacter.GetCompartmentAccessComponent();
117 userCompAccess = CompartmentAccessComponent.Cast(user.FindComponent(CompartmentAccessComponent));
123 CompartmentAccessComponent ownerAccess = CompartmentAccessComponent.Cast(owner.FindComponent(CompartmentAccessComponent));
127 Vehicle vehicle = Vehicle.Cast(owner);
131 IEntity userVehicle = userCompAccess.GetVehicleIn(user);
132 return userVehicle == vehicle;
136 IEntity userVehicle = userCompAccess.GetVehicleIn(user);
137 IEntity ownerVehicle = ownerAccess.GetVehicleIn(owner);
138 return userVehicle == ownerVehicle;
147 vector GetLocalPositionAction()
149 if (!m_LastUserActionContext)
152 return GetOwner().CoordToLocal(m_LastUserActionContext.GetOrigin());
161 vector GetWorldPositionAction()
163 if (!m_LastUserActionContext)
166 return m_LastUserActionContext.GetOrigin();
172 protected bool LoopActionUpdate(
float timeSlice)
174 float lastLoopProgress = m_fLoopProgress;
176 m_fLoopProgress -= timeSlice;
178 bool bLoopDone =
false;
181 if (lastLoopProgress > 0 && m_fLoopProgress <= 0)
185 if (m_fLoopProgress < -m_fLoopActionHoldDuration)
188 m_fLoopProgress = Math.AbsFloat(GetActionDuration()) + m_fLoopActionHoldDuration + m_fLoopProgress;
198 float GetActionProgress(
float fProgress,
float timeSlice)
200 fProgress = fProgress + timeSlice;
202 if (!IsActionLooping())
205 float actionDuration = Math.AbsFloat(GetActionDuration());
206 float totalDuration = actionDuration + m_fLoopActionHoldDuration;
208 fProgress = Math.Min(Math.Mod(fProgress, totalDuration), actionDuration);
209 float fTargetProgress = Math.Min(totalDuration - (m_fLoopProgress + m_fLoopActionHoldDuration), actionDuration);
211 return Math.SmoothCD(fProgress, fTargetProgress, m_fLoopProgressSmoothVelocity, 0.01, 1000, timeSlice);
218 bool IsActionLooping()
220 return m_bLoopAction && ShouldPerformPerFrame() && GetActionDuration() < 0;
227 float GetLoopActionHoldDuration()
229 return m_fLoopActionHoldDuration;
233 protected override void OnActionSelected()
235 m_LastUserActionContext = GetActiveContext();
239 override void OnActionStart(IEntity pUserEntity)
241 m_LastUserActionContext = GetActiveContext();
244 if (ShouldPerformPerFrame())
245 m_fLoopProgress = Math.AbsFloat(GetActionDuration());
247 if (m_bLowerWeaponOnUse)
251 RplComponent rplComp = RplComponent.Cast(pUserEntity.FindComponent(RplComponent));
252 if (rplComp && !rplComp.IsOwner())
256 ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity);
260 CharacterControllerComponent contr = character.GetCharacterController();
264 if (contr.CanPartialLower() && !contr.IsPartiallyLowered())
265 contr.SetPartialLower(
true);
272 enum EUserActionInVehicleState