Skip to content

Commit

Permalink
Vehicle cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sardelka9515 committed Aug 18, 2022
1 parent c4312fa commit c20118a
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 135 deletions.
4 changes: 1 addition & 3 deletions RageCoop.Client/Networking/Send.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,15 @@ public static void SendVehicle(SyncedVehicle v, bool full)
var packet = SendPackets.VehicelPacket;
packet.ID =v.ID;
packet.OwnerID=v.OwnerID;
packet.Flags = veh.GetVehicleFlags();
packet.Flags = v.GetVehicleFlags();
packet.SteeringAngle = veh.SteeringAngle;
packet.Position = veh.ReadPosition();
packet.Velocity=veh.Velocity;
packet.Quaternion=veh.ReadQuaternion();
packet.RotationVelocity=veh.RotationVelocity;
packet.ThrottlePower = veh.ThrottlePower;
packet.BrakePower = veh.BrakePower;
if (v.LastVelocity==default) {v.LastVelocity=packet.Velocity; }
v.LastSentStopWatch.Restart();
v.LastVelocity= packet.Velocity;
if (packet.Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering)) { packet.DeluxoWingRatio=v.MainVehicle.GetDeluxoWingRatio(); }
if (full)
{
Expand Down
1 change: 1 addition & 0 deletions RageCoop.Client/RageCoop.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<Compile Include="Sync\Entities\SyncedProjectile.cs" />
<Compile Include="Sync\Entities\SyncedProp.cs" />
<Compile Include="Sync\Entities\SyncedVehicle.cs" />
<Compile Include="Sync\Entities\SyncedVehicle.Members.cs" />
<Compile Include="Sync\EntityPool.cs" />
<Compile Include="Sync\SyncEvents.cs" />
<Compile Include="Sync\Voice.cs" />
Expand Down
85 changes: 85 additions & 0 deletions RageCoop.Client/Sync/Entities/SyncedVehicle.Members.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using RageCoop.Core;
using GTA;
using System.Diagnostics;
using System.Collections.Generic;
using GTA.Math;
using GTA.Native;

namespace RageCoop.Client{
public partial class SyncedVehicle{
public Vehicle MainVehicle { get; internal set; }
public Stopwatch LastSyncedStopWatch = new Stopwatch();


#region -- SYNC DATA --
internal Vector3 RotationVelocity { get; set; }
internal float SteeringAngle { get; set; }
internal float ThrottlePower { get; set; }
internal float BrakePower { get; set; }
internal float DeluxoWingRatio { get; set; } = -1;


internal byte LandingGear { get; set; }
internal VehicleRoofState RoofState { get; set; }
internal VehicleDamageModel DamageModel { get; set; }
internal byte[] Colors { get; set; }
internal Dictionary<int, int> Mods { get; set; }
internal float EngineHealth { get; set; }
internal VehicleLockStatus LockStatus { get; set; }
internal byte RadioStation = 255;
internal string LicensePlate { get; set; }
internal int Livery { get; set; } = -1;
internal VehicleDataFlags Flags { get; set; }

#endregion

#region FLAGS

internal bool EngineRunning { get => Flags.HasVehFlag(VehicleDataFlags.IsEngineRunning); }
internal bool Transformed { get => Flags.HasVehFlag(VehicleDataFlags.IsTransformed); }
internal bool HornActive { get => Flags.HasVehFlag(VehicleDataFlags.IsHornActive); }
internal bool LightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreLightsOn); }
internal bool BrakeLightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreBrakeLightsOn); }
internal bool HighBeamsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreHighBeamsOn); }
internal bool SireneActive { get => Flags.HasVehFlag(VehicleDataFlags.IsSirenActive); }
internal bool IsDead { get => Flags.HasVehFlag(VehicleDataFlags.IsDead); }
internal bool IsDeluxoHovering { get => Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering); }
#endregion

#region FIXED-DATA

internal bool IsFlipped
{
get => IsMotorcycle || ((Quaternion * Vector3.RelativeTop).Z - (Quaternion * Vector3.RelativeBottom).Z) < 0.5;
}
internal bool IsMotorcycle;
internal bool IsAircraft;
internal bool HasRocketBoost;
internal bool HasParachute;
internal bool HasRoof;
internal bool IsSubmarineCar;
internal bool IsDeluxo;

#endregion

#region PRIVATE
private byte[] _lastVehicleColors = new byte[] { 0, 0 };
private Dictionary<int, int> _lastVehicleMods = new Dictionary<int, int>();
private bool _lastHornActive = false;
private bool _lastTransformed = false;
internal int _lastLivery = -1;
List<Vector3> _predictedTrace = new List<Vector3>();
List<Vector3> _orgTrace = new List<Vector3>();

float _elapsed;
#endregion

#region OUTGOING
internal float LastNozzleAngle { get; set; }

internal float LastEngineHealth { get; set; }
internal Vector3 LastVelocity { get; set; }
#endregion
}
}
Loading

0 comments on commit c20118a

Please sign in to comment.