mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-27 14:30:17 +00:00
sync offset
This commit is contained in:
parent
eade6fc3d8
commit
75ab5d5d9b
2 changed files with 22 additions and 4 deletions
|
@ -38,6 +38,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
}
|
||||
|
||||
protected void ReadNetworkData(byte[] data)
|
||||
{
|
||||
var reader = new Mirror.NetworkReader(data);
|
||||
this.ReadNetworkData(reader);
|
||||
}
|
||||
|
||||
protected virtual void ReadNetworkData(Mirror.NetworkReader reader)
|
||||
{
|
||||
// first reset params
|
||||
this.CurrentVehicle = null;
|
||||
|
@ -46,8 +52,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
|
||||
// extract vehicle and seat from data
|
||||
|
||||
var reader = new Mirror.NetworkReader(data);
|
||||
|
||||
int magicNumber = reader.ReadInt32();
|
||||
m_currentVehicleNetId = reader.ReadUInt32();
|
||||
this.CurrentVehicleSeatAlignment = (Vehicle.SeatAlignment) reader.ReadSByte();
|
||||
|
@ -57,7 +61,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
this.CurrentVehicle = vehicleGo != null ? vehicleGo.GetComponent<Vehicle>() : null;
|
||||
|
||||
if (magicNumber != 123456789)
|
||||
Debug.LogErrorFormat("magicNumber {0}, m_currentVehicleNetId {1}, data size {2} - this should not happen", magicNumber, m_currentVehicleNetId, data.Length);
|
||||
Debug.LogErrorFormat("magicNumber {0}, m_currentVehicleNetId {1}, data size {2} - this should not happen", magicNumber, m_currentVehicleNetId, reader.Length);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,18 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
base.OnBecameInactive();
|
||||
}
|
||||
|
||||
protected override void GetAdditionalNetworkData(Mirror.NetworkWriter writer)
|
||||
{
|
||||
base.GetAdditionalNetworkData(writer);
|
||||
writer.Write(m_vehicleParentOffset);
|
||||
}
|
||||
|
||||
protected override void ReadNetworkData(Mirror.NetworkReader reader)
|
||||
{
|
||||
base.ReadNetworkData(reader);
|
||||
m_vehicleParentOffset = reader.ReadVector3();
|
||||
}
|
||||
|
||||
protected override void OnVehicleAssigned()
|
||||
{
|
||||
this.EnterVehicleInternal();
|
||||
|
@ -50,7 +62,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
|
|||
{
|
||||
Vehicle vehicle = this.CurrentVehicle;
|
||||
Vehicle.Seat seat = this.CurrentVehicleSeat;
|
||||
m_vehicleParentOffset = m_model.VehicleParentOffset;
|
||||
|
||||
if (m_isServer)
|
||||
m_vehicleParentOffset = m_model.VehicleParentOffset;
|
||||
|
||||
BaseVehicleState.PreparePedForVehicle(m_ped, vehicle, seat);
|
||||
|
||||
|
|
Loading…
Reference in a new issue