Skip to content

Commit

Permalink
Remove simulation of vehicle movement
Browse files Browse the repository at this point in the history
  • Loading branch information
DiFFoZ committed Jul 12, 2024
1 parent 00bf0ac commit f4fac3a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 228 deletions.
38 changes: 14 additions & 24 deletions Dummy/Threads/DummyUserSimulationThread.Movement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ private void SimulateAsClient()
{
case EPlayerStance.SITTING:
break;
case EPlayerStance.DRIVING:
SimulateVehicle();
break;
case EPlayerStance.CLIMB:
//s_FallProperty.SetValue(movement, c_Jump);
m_Velocity = new(0, Move.z * speed * 0.5f, 0);
Expand Down Expand Up @@ -138,7 +135,7 @@ private void SimulateAsClient()
m_Velocity.y = Mathf.Max(maxFall, m_Velocity.y);

var moveHorizontalMagnitude = moveVector.GetHorizontalMagnitude();
var horizontal = m_Velocity.GetHorizontal();
var horizontalVelocity = m_Velocity.GetHorizontal();
var horizontalMagnitude2 = m_Velocity.GetHorizontalMagnitude();
float maxMagnitude;
if (horizontalMagnitude2 > moveHorizontalMagnitude)
Expand All @@ -152,7 +149,7 @@ private void SimulateAsClient()
}

var a3 = moveVector * (4f * Provider.modeConfigData.Gameplay.AirStrafing_Acceleration_Multiplier);
var vector2 = horizontal + (a3 * deltaTime);
var vector2 = horizontalVelocity + (a3 * deltaTime);
vector2 = vector2.ClampHorizontalMagnitude(maxMagnitude);
m_Velocity.x = vector2.x;
m_Velocity.z = vector2.z;
Expand Down Expand Up @@ -186,26 +183,19 @@ private void SimulateAsClient()
}

ForceCreatePacket:
if (stance is EPlayerStance.DRIVING)
{
m_Packet = new DrivingPlayerInputPacket();
}
else
var x = (int)Move.x;
var z = (int)Move.z;

var horizontal = (byte)(x + 1);
var vertical = (byte)(z + 1);

m_Packet = new WalkingPlayerInputPacket
{
var x = (int)Move.x;
var z = (int)Move.z;

var horizontal = (byte)(x + 1);
var vertical = (byte)(z + 1);

m_Packet = new WalkingPlayerInputPacket
{
analog = (byte)((horizontal << 4) | vertical),
clientPosition = transform.position,
pitch = m_Pitch,
yaw = m_Yaw
};
}
analog = (byte)((horizontal << 4) | vertical),
clientPosition = transform.position,
pitch = m_Pitch,
yaw = m_Yaw
};

m_Packet.clientSimulationFrameNumber = m_Simulation;
m_Packet.recov = Player.input.recov;
Expand Down
185 changes: 0 additions & 185 deletions Dummy/Threads/DummyUserSimulationThread.Vehicle.cs

This file was deleted.

19 changes: 0 additions & 19 deletions Dummy/Threads/DummyUserSimulationThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,25 +249,6 @@ public async UniTaskVoid Start()
}
m_Packet.keys = compressedKeys;

if (m_Packet is DrivingPlayerInputPacket drivingPlayerInputPacket)
{
var vehicle = Player.movement.getVehicle();

if (vehicle != null)
{
var transform = vehicle.transform;
drivingPlayerInputPacket.position = vehicle.asset.engine is EEngine.TRAIN
? Patch_InteractableVehicle.PackRoadPositionOriginal(vehicle.roadPosition)
: vehicle.transform.position;

drivingPlayerInputPacket.rotation = transform.rotation;

drivingPlayerInputPacket.speed = (byte)(Mathf.Clamp(vehicle.speed, -100f, 100f) + 128f);
drivingPlayerInputPacket.physicsSpeed = (byte)(Mathf.Clamp(vehicle.physicsSpeed, -100f, 100f) + 128f);
drivingPlayerInputPacket.turn = (byte)(Move.x + 1);
}
}

var netWriter = NetMessages.GetInvokableWriter();
netWriter.Reset();
m_Packet.write(netWriter);
Expand Down

0 comments on commit f4fac3a

Please sign in to comment.