From ec4435e181a3c446a331c5d1cc1a016906c0b170 Mon Sep 17 00:00:00 2001 From: in0finite Date: Sun, 26 May 2019 00:08:56 +0200 Subject: [PATCH] Converting vehicle states to new API 3 --- .../Ped/States/VehicleSittingState.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs index 2fa69988..11e862e4 100644 --- a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs @@ -11,6 +11,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States { + public override void OnBecameActive() + { + base.OnBecameActive(); + this.EnterVehicleInternal(); + } + public override void OnBecameInactive() { this.Cleanup(); @@ -25,11 +31,16 @@ namespace SanAndreasUnity.Behaviours.Peds.States public void EnterVehicle(Vehicle vehicle, Vehicle.Seat seat) { - this.CurrentVehicle = vehicle; this.CurrentVehicleSeat = seat; m_ped.SwitchState (); + } + + void EnterVehicleInternal() + { + Vehicle vehicle = this.CurrentVehicle; + Vehicle.Seat seat = this.CurrentVehicleSeat; VehicleEnteringState.PreparePedForVehicle(m_ped, vehicle, seat); @@ -42,13 +53,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States m_model.PlayAnim(AnimGroup.Car, AnimIndex.SitPassenger, PlayMode.StopAll); } - // send message to clients - if (m_isServer) - { - foreach(var pedSync in Net.Player.AllPlayers.Select(p => p.GetComponent())) - pedSync.PedEnteredVehicle(m_ped); - } - }