24 m_DefaultTimeToComplete = time_to_complete_action;
29 if (!action_data.m_Player)
32 if (m_TimeElpased < m_TimeToComplete)
34 m_TimeElpased += action_data.m_Player.GetDeltaT();
35 m_TotalTimeElpased += action_data.m_Player.GetDeltaT();
40 m_SpentUnits.param1 = m_TimeElpased;
41 SetACData(m_SpentUnits);
42 m_TimeElpased = m_TimeToComplete - m_TimeElpased;
43 OnCompletePogress(action_data);
64 super.ProgressActionComponent();
66 ActionPushCarData data = ActionPushCarData.Cast(m_ActionData);
76 super.EndActionComponent();
90 if (action.HasAlternativeInterrupt())
105 actionData.m_HorizontalDirectionRandom =
Math.RandomFloat(1.0, 3.5);
106 actionData.m_VerticalDirectionRandom =
Math.RandomFloat(-0.5, 0.5);
109 float invBodyMass = 1.0 / bodyMass;
112 float easedProgress =
Easing.EaseInOutSine(actionData.m_ActionComponent.GetProgress());
114 vector impulse = car.GetDirection() * force * (
float)actionData.m_PushDirection;
115 impulse = impulse * invBodyMass;
116 impulse[0] = impulse[0] * actionData.m_HorizontalDirectionRandom;
117 impulse[1] = impulse[1] * actionData.m_VerticalDirectionRandom;
118 impulse = impulse * easedProgress;
130 m_CallbackClass = ActionPushCarCB;
138 override typename GetInputType()
143 override void CreateConditionComponents()
149 override bool HasAlternativeInterrupt()
156 ActionPushCarData data =
new ActionPushCarData();
165 if (!player.GetSurfaceType())
177 if (car.GetGear() != CarGear.NEUTRAL)
180 if (
Math.AbsFloat(GetDirectionDot(car, player)) < 0.85)
189 override void OnUpdate(
ActionData action_data)
191 super.OnUpdate(action_data);
193 ActionPushCarData data = ActionPushCarData.Cast(action_data);
194 if (data.m_NeedUpdate)
199 data.m_NeedUpdate =
false;
204 if (
vector.Distance(data.m_Car.GetPosition(), data.m_Origin) > 0.5)
208 data.m_NeedUpdate =
false;
215 super.OnStart(action_data);
217 ActionPushCarData data = ActionPushCarData.Cast(action_data);
218 data.m_Car = GetCar(action_data.m_Target);
219 data.m_Origin = data.m_Car.GetPosition();
220 data.m_NeedUpdate =
true;
223 override void OnStartServer(
ActionData action_data)
225 super.OnStartServer(action_data);
227 ActionPushCarData data = ActionPushCarData.Cast(action_data);
231 data.m_Car.SetBrake(0.0);
232 data.m_Car.SetHandbrake(0.0);
233 data.m_Car.SetBrakesActivateWithoutDriver(
false);
236 data.m_PushDirection = -1;
237 if (GetDirectionDot(data.m_Car, data.m_Player) > 0)
238 data.m_PushDirection = 1;
242 override void OnEndServer(
ActionData action_data)
244 super.OnEndServer(action_data);
246 ActionPushCarData data = ActionPushCarData.Cast(action_data);
248 data.m_Car.SetBrakesActivateWithoutDriver(
true);
251 override void OnEndInput(
ActionData action_data)
253 super.OnEndInput(action_data);
255 ActionPushCarData data = ActionPushCarData.Cast(action_data);
258 data.m_NeedUpdate =
false;
263 super.WriteToContext(ctx, action_data);
265 ActionPushCarData data = ActionPushCarData.Cast(action_data);
267 ctx.Write(data.m_Car);
270 override bool ReadFromContext(
ParamsReadContext ctx, out ActionReciveData action_recive_data)
272 if (!action_recive_data)
275 super.ReadFromContext(ctx, action_recive_data);
282 receiveData.m_Car = car;
287 override void HandleReciveData(ActionReciveData action_recive_data,
ActionData action_data)
289 super.HandleReciveData(action_recive_data, action_data);
292 receiveData.m_Car = receiveData.m_Car;
297 return vector.Dot(target.GetDirection(), player.GetDirection());
302 if (target.IsProxy())
303 return CarScript.Cast(target.GetParent());
305 return CarScript.Cast(target.GetObject());