New vehicle seat sync and projectile fix
This commit is contained in:
parent
b436abf131
commit
a7d64d241d
@ -125,8 +125,8 @@ namespace RageCoop.Client
|
||||
CoopMenu.MenuPool.Process();
|
||||
#endif
|
||||
|
||||
|
||||
P= Game.Player.Character;
|
||||
// GTA.UI.Screen.ShowHelpTextThisFrame(P.GetPedSpeed().ToString());
|
||||
PlayerPosition=P.ReadPosition();
|
||||
FPS=Game.FPS;
|
||||
|
||||
|
@ -349,6 +349,11 @@ namespace RageCoop.Client
|
||||
c.RightFootPosition=packet.RightFootPosition;
|
||||
c.LeftFootPosition=packet.LeftFootPosition;
|
||||
}
|
||||
else if (c.Speed>=4)
|
||||
{
|
||||
c.VehicleID=packet.VehicleID;
|
||||
c.Seat=packet.Seat;
|
||||
}
|
||||
c.LastSynced = Main.Ticked;
|
||||
if (c.IsAiming)
|
||||
{
|
||||
@ -398,26 +403,20 @@ namespace RageCoop.Client
|
||||
v.Colors=packet.Colors;
|
||||
v.LandingGear=packet.LandingGear;
|
||||
v.RoofState=(VehicleRoofState)packet.RoofState;
|
||||
v.Passengers=new Dictionary<VehicleSeat, SyncedPed>();
|
||||
v.LockStatus=packet.LockStatus;
|
||||
v.RadioStation=packet.RadioStation;
|
||||
v.LicensePlate=packet.LicensePlate;
|
||||
v.Livery=packet.Livery;
|
||||
foreach (KeyValuePair<int, int> pair in packet.Passengers)
|
||||
{
|
||||
if (EntityPool.PedExists(pair.Value))
|
||||
{
|
||||
v.Passengers.Add((VehicleSeat)pair.Key, EntityPool.GetPedByID(pair.Value));
|
||||
}
|
||||
}
|
||||
v.LastFullSynced= Main.Ticked;
|
||||
}
|
||||
}
|
||||
private static void ProjectileSync(Packets.ProjectileSync packet)
|
||||
{
|
||||
|
||||
var p = EntityPool.GetProjectileByID(packet.ID);
|
||||
if (p==null)
|
||||
{
|
||||
|
||||
if (packet.Exploded) { return; }
|
||||
// Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
|
||||
EntityPool.ThreadSafe.Add(p=new SyncedProjectile(packet.ID));
|
||||
|
@ -26,69 +26,88 @@ namespace RageCoop.Client
|
||||
Peer.SendTo(p, Targets, channel, method);
|
||||
}
|
||||
|
||||
public static void SendPed(SyncedPed c, bool full)
|
||||
public static void SendPed(SyncedPed sp, bool full)
|
||||
{
|
||||
if (c.LastSentStopWatch.ElapsedMilliseconds<SyncInterval)
|
||||
if (sp.LastSentStopWatch.ElapsedMilliseconds<SyncInterval)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Ped p = c.MainPed;
|
||||
var packet = SendPackets.PedPacket;
|
||||
packet.ID =c.ID;
|
||||
packet.OwnerID=c.OwnerID;
|
||||
packet.Health = p.Health;
|
||||
packet.Rotation = p.ReadRotation();
|
||||
packet.Velocity = p.ReadVelocity();
|
||||
packet.Speed = p.GetPedSpeed();
|
||||
packet.Flags = p.GetPedFlags();
|
||||
packet.Heading=p.Heading;
|
||||
if (packet.Flags.HasPedFlag(PedDataFlags.IsAiming))
|
||||
Ped ped = sp.MainPed;
|
||||
var p = SendPackets.PedPacket;
|
||||
p.ID =sp.ID;
|
||||
p.OwnerID=sp.OwnerID;
|
||||
p.Health = ped.Health;
|
||||
p.Rotation = ped.ReadRotation();
|
||||
p.Velocity = ped.ReadVelocity();
|
||||
p.Speed = ped.GetPedSpeed();
|
||||
p.Flags = ped.GetPedFlags();
|
||||
p.Heading=ped.Heading;
|
||||
if (p.Flags.HasPedFlag(PedDataFlags.IsAiming))
|
||||
{
|
||||
packet.AimCoords = p.GetAimCoord();
|
||||
p.AimCoords = ped.GetAimCoord();
|
||||
}
|
||||
if (packet.Flags.HasPedFlag(PedDataFlags.IsRagdoll))
|
||||
if (p.Flags.HasPedFlag(PedDataFlags.IsRagdoll))
|
||||
{
|
||||
packet.HeadPosition=p.Bones[Bone.SkelHead].Position;
|
||||
packet.RightFootPosition=p.Bones[Bone.SkelRightFoot].Position;
|
||||
packet.LeftFootPosition=p.Bones[Bone.SkelLeftFoot].Position;
|
||||
p.HeadPosition=ped.Bones[Bone.SkelHead].Position;
|
||||
p.RightFootPosition=ped.Bones[Bone.SkelRightFoot].Position;
|
||||
p.LeftFootPosition=ped.Bones[Bone.SkelLeftFoot].Position;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.Position = p.ReadPosition();
|
||||
// Seat sync
|
||||
if (p.Speed>=4)
|
||||
{
|
||||
var veh = ped.CurrentVehicle?.GetSyncEntity() ?? ped.VehicleTryingToEnter?.GetSyncEntity() ?? ped.LastVehicle?.GetSyncEntity();
|
||||
p.VehicleID = veh?.ID ?? 0;
|
||||
if (p.Speed==5)
|
||||
{
|
||||
p.Seat=ped.GetSeatTryingToEnter();
|
||||
}
|
||||
else
|
||||
{
|
||||
p.Seat=ped.SeatIndex;
|
||||
}
|
||||
if (!veh.IsLocal && p.Speed==4 && p.Seat==VehicleSeat.Driver)
|
||||
{
|
||||
veh.OwnerID=Main.LocalPlayerID;
|
||||
SyncEvents.TriggerChangeOwner(veh.ID,Main.LocalPlayerID);
|
||||
}
|
||||
}
|
||||
p.Position = ped.ReadPosition();
|
||||
}
|
||||
c.LastSentStopWatch.Restart();
|
||||
sp.LastSentStopWatch.Restart();
|
||||
if (full)
|
||||
{
|
||||
packet.CurrentWeaponHash = packet.Flags.HasPedFlag(PedDataFlags.IsInVehicle) ? (uint)p.VehicleWeapon : (uint)p.Weapons.Current.Hash;
|
||||
packet.Flags |= PedDataFlags.IsFullSync;
|
||||
packet.Clothes=p.GetPedClothes();
|
||||
packet.ModelHash=p.Model.Hash;
|
||||
packet.WeaponComponents=p.Weapons.Current.GetWeaponComponents();
|
||||
packet.WeaponTint=(byte)Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, p, p.Weapons.Current.Hash);
|
||||
p.CurrentWeaponHash = p.Speed>=4 ? (uint)ped.VehicleWeapon : (uint)ped.Weapons.Current.Hash;
|
||||
p.Flags |= PedDataFlags.IsFullSync;
|
||||
p.Clothes=ped.GetPedClothes();
|
||||
p.ModelHash=ped.Model.Hash;
|
||||
p.WeaponComponents=ped.Weapons.Current.GetWeaponComponents();
|
||||
p.WeaponTint=(byte)Function.Call<int>(Hash.GET_PED_WEAPON_TINT_INDEX, ped, ped.Weapons.Current.Hash);
|
||||
|
||||
Blip b;
|
||||
if (c.IsPlayer)
|
||||
if (sp.IsPlayer)
|
||||
{
|
||||
packet.BlipColor=Scripting.API.Config.BlipColor;
|
||||
packet.BlipSprite=Scripting.API.Config.BlipSprite;
|
||||
packet.BlipScale=Scripting.API.Config.BlipScale;
|
||||
p.BlipColor=Scripting.API.Config.BlipColor;
|
||||
p.BlipSprite=Scripting.API.Config.BlipSprite;
|
||||
p.BlipScale=Scripting.API.Config.BlipScale;
|
||||
}
|
||||
else if ((b = p.AttachedBlip) !=null)
|
||||
else if ((b = ped.AttachedBlip) !=null)
|
||||
{
|
||||
packet.BlipColor=b.Color;
|
||||
packet.BlipSprite=b.Sprite;
|
||||
p.BlipColor=b.Color;
|
||||
p.BlipSprite=b.Sprite;
|
||||
|
||||
if (packet.BlipSprite==BlipSprite.PoliceOfficer || packet.BlipSprite==BlipSprite.PoliceOfficer2)
|
||||
if (p.BlipSprite==BlipSprite.PoliceOfficer || p.BlipSprite==BlipSprite.PoliceOfficer2)
|
||||
{
|
||||
packet.BlipScale=0.5f;
|
||||
p.BlipScale=0.5f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
packet.BlipColor=(BlipColor)255;
|
||||
p.BlipColor=(BlipColor)255;
|
||||
}
|
||||
}
|
||||
SendSync(packet, ConnectionChannel.PedSync);
|
||||
SendSync(p, ConnectionChannel.PedSync);
|
||||
}
|
||||
public static void SendVehicle(SyncedVehicle v, bool full)
|
||||
{
|
||||
@ -128,7 +147,6 @@ namespace RageCoop.Client
|
||||
packet.Mods = veh.Mods.GetVehicleMods();
|
||||
packet.ModelHash=veh.Model.Hash;
|
||||
packet.EngineHealth=veh.EngineHealth;
|
||||
packet.Passengers=veh.GetPassengers();
|
||||
packet.LockStatus=veh.LockStatus;
|
||||
packet.LicensePlate=Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, veh);
|
||||
packet.Livery=Function.Call<int>(Hash.GET_VEHICLE_LIVERY, veh);
|
||||
|
@ -46,17 +46,22 @@ namespace RageCoop.Client
|
||||
#endregion
|
||||
internal Blip PedBlip = null;
|
||||
internal BlipColor BlipColor = (BlipColor)255;
|
||||
internal BlipSprite BlipSprite = (BlipSprite)0;
|
||||
internal BlipSprite BlipSprite = 0;
|
||||
internal float BlipScale = 1;
|
||||
internal Player Player;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether this ped is a player
|
||||
/// </summary>
|
||||
internal int VehicleID
|
||||
{
|
||||
get => CurrentVehicle?.ID ?? 0;
|
||||
set
|
||||
{
|
||||
if (CurrentVehicle == null || value != CurrentVehicle?.ID)
|
||||
{
|
||||
CurrentVehicle=EntityPool.GetVehicleByID(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal SyncedVehicle CurrentVehicle { get; private set; }
|
||||
internal VehicleSeat Seat;
|
||||
public bool IsPlayer { get => OwnerID == ID && ID != 0; }
|
||||
/// <summary>
|
||||
/// real entity
|
||||
/// </summary>
|
||||
public Ped MainPed { get; internal set; }
|
||||
internal int Health { get; set; }
|
||||
internal bool IsInStealthMode { get; set; }
|
||||
@ -66,8 +71,8 @@ namespace RageCoop.Client
|
||||
internal Vector3 LeftFootPosition { get; set; }
|
||||
|
||||
internal byte WeaponTint { get; set; }
|
||||
internal bool _lastEnteringVehicle = false;
|
||||
internal bool _lastSittingInVehicle = false;
|
||||
internal Vehicle _lastVehicle { get; set; }
|
||||
internal int _lastVehicleID { get; set; }
|
||||
private bool _lastRagdoll = false;
|
||||
private ulong _lastRagdollTime = 0;
|
||||
private bool _lastInCover = false;
|
||||
@ -75,20 +80,36 @@ namespace RageCoop.Client
|
||||
internal byte[] Clothes { get; set; }
|
||||
|
||||
internal float Heading { get; set; }
|
||||
// internal Vector3 RotationVelocity { get; set; }
|
||||
|
||||
|
||||
#region -- VARIABLES --
|
||||
public byte Speed { get; set; }
|
||||
private bool _lastIsJumping = false;
|
||||
internal bool IsJumping { get; set; }
|
||||
internal bool IsOnLadder { get; set; }
|
||||
internal bool IsVaulting { get; set; }
|
||||
internal bool IsInParachuteFreeFall { get; set; }
|
||||
internal bool IsParachuteOpen { get; set; }
|
||||
internal Prop ParachuteProp { get; set; } = null;
|
||||
internal bool IsRagdoll { get; set; }
|
||||
internal bool IsOnFire { get; set; }
|
||||
internal bool IsAiming { get; set; }
|
||||
internal bool IsReloading { get; set; }
|
||||
internal bool IsInCover { get; set; }
|
||||
internal uint CurrentWeaponHash { get; set; }
|
||||
private Dictionary<uint, bool> _lastWeaponComponents = null;
|
||||
internal Dictionary<uint, bool> WeaponComponents { get; set; } = null;
|
||||
private int _lastWeaponObj = 0;
|
||||
#endregion
|
||||
internal Vector3 AimCoords { get; set; }
|
||||
|
||||
private WeaponAsset WeaponAsset { get; set; }
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
if (Owner==null) { return; }
|
||||
if (IsPlayer)
|
||||
{
|
||||
if (Player==null)
|
||||
{
|
||||
Player = PlayerList.GetPlayer(this);
|
||||
return;
|
||||
}
|
||||
RenderNameTag();
|
||||
}
|
||||
|
||||
@ -129,7 +150,7 @@ namespace RageCoop.Client
|
||||
if (IsPlayer)
|
||||
{
|
||||
// Main.Logger.Debug("blip:"+Player.Username);
|
||||
Main.QueueAction(() => { PedBlip.Name=Player.Username; });
|
||||
Main.QueueAction(() => { PedBlip.Name=Owner.Username; });
|
||||
}
|
||||
PedBlip.Color=BlipColor;
|
||||
PedBlip.Sprite=BlipSprite;
|
||||
@ -178,13 +199,13 @@ namespace RageCoop.Client
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MainPed.IsInVehicle()||MainPed.IsGettingIntoVehicle)
|
||||
if (Speed>=4)
|
||||
{
|
||||
DisplayInVehicle();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MainPed.IsInVehicle()) { MainPed.Task.LeaveVehicle(LeaveVehicleFlags.WarpOut); }
|
||||
DisplayOnFoot();
|
||||
}
|
||||
|
||||
@ -193,7 +214,7 @@ namespace RageCoop.Client
|
||||
|
||||
private void RenderNameTag()
|
||||
{
|
||||
if (!Player.DisplayNameTag || (MainPed==null) || !MainPed.IsVisible || !MainPed.IsInRange(Main.PlayerPosition, 40f))
|
||||
if (!Owner.DisplayNameTag || (MainPed==null) || !MainPed.IsVisible || !MainPed.IsInRange(Main.PlayerPosition, 40f))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -203,7 +224,7 @@ namespace RageCoop.Client
|
||||
if (Util.WorldToScreen(targetPos, ref toDraw))
|
||||
{
|
||||
toDraw.Y-=100;
|
||||
new ScaledText(toDraw, Player.Username, 0.4f, GTA.UI.Font.ChaletLondon)
|
||||
new ScaledText(toDraw, Owner.Username, 0.4f, GTA.UI.Font.ChaletLondon)
|
||||
{
|
||||
Outline = true,
|
||||
Alignment = GTA.UI.Alignment.Center,
|
||||
@ -290,30 +311,9 @@ namespace RageCoop.Client
|
||||
}
|
||||
_lastClothes = Clothes;
|
||||
}
|
||||
#region ONFOOT
|
||||
#region -- VARIABLES --
|
||||
/// <summary>
|
||||
/// The latest character rotation (may not have been applied yet)
|
||||
/// </summary>
|
||||
public byte Speed { get; set; }
|
||||
private bool _lastIsJumping = false;
|
||||
internal bool IsJumping { get; set; }
|
||||
internal bool IsOnLadder { get; set; }
|
||||
internal bool IsVaulting { get; set; }
|
||||
internal bool IsInParachuteFreeFall { get; set; }
|
||||
internal bool IsParachuteOpen { get; set; }
|
||||
internal Prop ParachuteProp { get; set; } = null;
|
||||
internal bool IsRagdoll { get; set; }
|
||||
internal bool IsOnFire { get; set; }
|
||||
internal bool IsAiming { get; set; }
|
||||
internal bool IsReloading { get; set; }
|
||||
internal bool IsInCover { get; set; }
|
||||
internal uint CurrentWeaponHash { get; set; }
|
||||
private Dictionary<uint, bool> _lastWeaponComponents = null;
|
||||
internal Dictionary<uint, bool> WeaponComponents { get; set; } = null;
|
||||
private int _lastWeaponObj = 0;
|
||||
#endregion
|
||||
|
||||
|
||||
#region ONFOOT
|
||||
private string[] _currentAnimation = new string[2] { "", "" };
|
||||
|
||||
private void DisplayOnFoot()
|
||||
@ -667,8 +667,6 @@ namespace RageCoop.Client
|
||||
MainPed.PositionNoOffset=Position;
|
||||
return;
|
||||
}
|
||||
// var f = dist*(Position+SyncParameters.PositioinPredictionDefault*Velocity-MainPed.Position)+(Velocity-MainPed.Velocity)*0.2f;
|
||||
// if (!localRagdoll) { f*=5; }
|
||||
if (!(localRagdoll|| MainPed.IsDead))
|
||||
{
|
||||
MainPed.Heading=Heading;
|
||||
@ -709,7 +707,6 @@ namespace RageCoop.Client
|
||||
{
|
||||
MainPed.Velocity=Velocity+5*dist*(Position-MainPed.ReadPosition());
|
||||
}
|
||||
// MainPed.ApplyForce(f);
|
||||
}
|
||||
|
||||
private string LoadAnim(string anim)
|
||||
@ -729,18 +726,42 @@ namespace RageCoop.Client
|
||||
return anim;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void DisplayInVehicle()
|
||||
{
|
||||
if (MainPed.IsOnTurretSeat())
|
||||
if (CurrentVehicle==null || CurrentVehicle.MainVehicle==null) { return; }
|
||||
switch (Speed)
|
||||
{
|
||||
// Function.Call(Hash.SET_VEHICLE_TURRET_SPEED_THIS_FRAME, MainPed.CurrentVehicle, 100);
|
||||
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z);
|
||||
}
|
||||
if (MainPed.VehicleWeapon!=(VehicleWeaponHash)CurrentWeaponHash)
|
||||
{
|
||||
MainPed.VehicleWeapon=(VehicleWeaponHash)CurrentWeaponHash;
|
||||
case 4:
|
||||
if (MainPed.CurrentVehicle!=CurrentVehicle.MainVehicle)
|
||||
{
|
||||
MainPed.SetIntoVehicle(CurrentVehicle.MainVehicle, Seat);
|
||||
}
|
||||
if (MainPed.IsOnTurretSeat())
|
||||
{
|
||||
// Function.Call(Hash.SET_VEHICLE_TURRET_SPEED_THIS_FRAME, MainPed.CurrentVehicle, 100);
|
||||
Function.Call(Hash.TASK_VEHICLE_AIM_AT_COORD, MainPed.Handle, AimCoords.X, AimCoords.Y, AimCoords.Z);
|
||||
}
|
||||
if (MainPed.VehicleWeapon!=(VehicleWeaponHash)CurrentWeaponHash)
|
||||
{
|
||||
MainPed.VehicleWeapon=(VehicleWeaponHash)CurrentWeaponHash;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (MainPed.VehicleTryingToEnter!=CurrentVehicle.MainVehicle || MainPed.GetSeatTryingToEnter()!=Seat)
|
||||
{
|
||||
MainPed.Task.EnterVehicle(CurrentVehicle.MainVehicle,Seat,-1,1,EnterVehicleFlags.AllowJacking);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (!MainPed.IsTaskActive(TaskType.CTaskExitVehicle))
|
||||
{
|
||||
MainPed.Task.LeaveVehicle(CurrentVehicle.Velocity.Length() > 5f ? LeaveVehicleFlags.BailOut:LeaveVehicleFlags.None);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Function.Call(Hash.TASK_SWEEP_AIM_ENTITY,P, "random@paparazzi@pap_anims", "sweep_low", "sweep_med", "sweep_high", -1,V, 1.57f, 0.25f);
|
||||
Function.Call(Hash.SET_PED_STEALTH_MOVEMENT, P,true, 0);
|
||||
|
@ -92,15 +92,10 @@ namespace RageCoop.Client
|
||||
internal Dictionary<int, int> Mods { get; set; }
|
||||
internal float EngineHealth { get; set; }
|
||||
internal VehicleLockStatus LockStatus { get; set; }
|
||||
/// <summary>
|
||||
/// VehicleSeat,PedID
|
||||
/// </summary>
|
||||
internal Dictionary<VehicleSeat, SyncedPed> Passengers { get; set; }
|
||||
internal byte RadioStation = 255;
|
||||
internal string LicensePlate { get; set; }
|
||||
internal int _lastLivery = -1;
|
||||
internal int Livery { get; set; } = -1;
|
||||
internal bool _checkSeat { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
internal override void Update()
|
||||
@ -112,7 +107,7 @@ namespace RageCoop.Client
|
||||
if (!IsReady || Owner==null ) { return; }
|
||||
#endregion
|
||||
#region -- CHECK EXISTENCE --
|
||||
if ((MainVehicle == null) || (!MainVehicle.Exists()) || (MainVehicle.Model.Hash != Model))
|
||||
if ((MainVehicle == null) || (!MainVehicle.Exists()) || (MainVehicle.Model != Model))
|
||||
{
|
||||
if (!CreateVehicle())
|
||||
{
|
||||
@ -260,42 +255,6 @@ namespace RageCoop.Client
|
||||
if (LastFullSynced>=LastUpdated)
|
||||
{
|
||||
#region -- SYNC STATE --
|
||||
#region -- PASSENGER SYNC --
|
||||
|
||||
// check passengers (and driver).
|
||||
if (_checkSeat)
|
||||
{
|
||||
var currentPassengers = MainVehicle.GetPassengers();
|
||||
|
||||
lock (Passengers)
|
||||
{
|
||||
for (int i = -1; i<MainVehicle.PassengerCapacity; i++)
|
||||
{
|
||||
VehicleSeat seat = (VehicleSeat)i;
|
||||
if (Passengers.ContainsKey(seat))
|
||||
{
|
||||
SyncedPed c = Passengers[seat];
|
||||
if (c?.ID==Main.LocalPlayerID && (RadioStation!=Function.Call<int>(Hash.GET_PLAYER_RADIO_STATION_INDEX)))
|
||||
{
|
||||
Util.SetPlayerRadioIndex(RadioStation);
|
||||
}
|
||||
if (c?.MainPed!=null&&(!currentPassengers.ContainsKey(i))&&(!c.MainPed.IsBeingJacked)&&(!c.MainPed.IsTaskActive(TaskType.CTaskExitVehicleSeat)))
|
||||
{
|
||||
Passengers[seat].MainPed.SetIntoVehicle(MainVehicle, seat);
|
||||
}
|
||||
}
|
||||
else if (!MainVehicle.IsSeatFree(seat))
|
||||
{
|
||||
var p = MainVehicle.Occupants.Where(x => x.SeatIndex==seat).FirstOrDefault();
|
||||
if ((p!=null)&& !p.IsTaskActive(TaskType.CTaskLeaveAnyCar))
|
||||
{
|
||||
p.Task.WarpOutOfVehicle(MainVehicle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
if (Flags.HasVehFlag(VehicleDataFlags.Repaired))
|
||||
{
|
||||
MainVehicle.Repair();
|
||||
@ -337,12 +296,8 @@ namespace RageCoop.Client
|
||||
Vector3 _predictedPos;
|
||||
void DisplayVehicle(bool touching)
|
||||
{
|
||||
// predict velocity/position
|
||||
_elapsed = Owner.PacketTravelTime+0.001f*LastSyncedStopWatch.ElapsedMilliseconds;
|
||||
// new LemonUI.Elements.ScaledText(new System.Drawing.PointF(50, 50), Owner.HasDirectConnection+" "+LastSyncedStopWatch.ElapsedMilliseconds).Draw();
|
||||
// _predictedVel = Velocity+Acceleration*_elapsed;
|
||||
_predictedPos = Position+_elapsed*Velocity;
|
||||
// LastVelocity=_predictedVel;
|
||||
var current = MainVehicle.ReadPosition();
|
||||
var dist = current.DistanceTo(Position);
|
||||
var cali = ((Velocity.Length()<0.1 && !touching)?dist*4:dist)*(_predictedPos - current);
|
||||
|
@ -87,8 +87,8 @@ namespace RageCoop.Client
|
||||
}
|
||||
|
||||
#region PEDS
|
||||
public static SyncedPed GetPedByID(int id) => PedsByID.ContainsKey(id) ? PedsByID[id] : null;
|
||||
public static SyncedPed GetPedByHandle(int handle) => PedsByHandle.ContainsKey(handle) ? PedsByHandle[handle] : null;
|
||||
public static SyncedPed GetPedByID(int id) => PedsByID.TryGetValue(id, out var p) ? p : null;
|
||||
public static SyncedPed GetPedByHandle(int handle) => PedsByHandle.TryGetValue(handle, out var p) ? p : null;
|
||||
public static List<int> GetPedIDs() => new List<int>(PedsByID.Keys);
|
||||
public static bool AddPlayer()
|
||||
{
|
||||
@ -182,8 +182,8 @@ namespace RageCoop.Client
|
||||
#endregion
|
||||
|
||||
#region VEHICLES
|
||||
public static SyncedVehicle GetVehicleByID(int id) => VehiclesByID.ContainsKey(id) ? VehiclesByID[id] : null;
|
||||
public static SyncedVehicle GetVehicleByHandle(int handle) => VehiclesByHandle.ContainsKey(handle) ? VehiclesByHandle[handle] : null;
|
||||
public static SyncedVehicle GetVehicleByID(int id) => VehiclesByID.TryGetValue(id,out var v) ? v : null;
|
||||
public static SyncedVehicle GetVehicleByHandle(int handle) => VehiclesByHandle.TryGetValue(handle,out var v) ? v : null;
|
||||
public static List<int> GetVehicleIDs() => new List<int>(VehiclesByID.Keys);
|
||||
public static void Add(SyncedVehicle v)
|
||||
{
|
||||
@ -237,7 +237,7 @@ namespace RageCoop.Client
|
||||
#region PROJECTILES
|
||||
public static SyncedProjectile GetProjectileByID(int id)
|
||||
{
|
||||
return ProjectilesByID.ContainsKey(id) ? ProjectilesByID[id] : null;
|
||||
return ProjectilesByID.TryGetValue(id,out var p) ? p : null;
|
||||
}
|
||||
public static void Add(SyncedProjectile p)
|
||||
{
|
||||
@ -272,7 +272,7 @@ namespace RageCoop.Client
|
||||
{
|
||||
ProjectilesByHandle.Remove(p.Handle);
|
||||
}
|
||||
// Main.Logger.Debug($"Removing projectile {sp.ID}. Reason:{reason}");
|
||||
Main.Logger.Debug($"Removing projectile {sp.ID}. Reason:{reason}");
|
||||
p.Explode();
|
||||
}
|
||||
ProjectilesByID.Remove(id);
|
||||
|
@ -15,39 +15,12 @@ namespace RageCoop.Client
|
||||
Networking.SendSync(new Packets.PedKilled() { VictimID=victim.ID }, ConnectionChannel.SyncEvents);
|
||||
}
|
||||
|
||||
public static void TriggerEnteringVehicle(SyncedPed c, SyncedVehicle veh, VehicleSeat seat)
|
||||
{
|
||||
Networking.
|
||||
SendSync(new Packets.EnteringVehicle()
|
||||
{
|
||||
PedID=c.ID,
|
||||
VehicleID= veh.ID,
|
||||
VehicleSeat=(short)seat,
|
||||
}, ConnectionChannel.SyncEvents);
|
||||
}
|
||||
|
||||
public static void TriggerEnteredVehicle(SyncedPed c, SyncedVehicle veh, VehicleSeat seat)
|
||||
{
|
||||
if (seat==VehicleSeat.Driver)
|
||||
{
|
||||
veh.OwnerID=Main.LocalPlayerID;
|
||||
veh.LastSynced=Main.Ticked;
|
||||
TriggerChangeOwner(veh, c.ID);
|
||||
}
|
||||
Networking.SendSync(new Packets.EnteredVehicle()
|
||||
{
|
||||
VehicleSeat=(short)seat,
|
||||
PedID=c.ID,
|
||||
VehicleID=veh.ID
|
||||
}, ConnectionChannel.SyncEvents);
|
||||
}
|
||||
|
||||
public static void TriggerChangeOwner(SyncedVehicle c, int newOwnerID)
|
||||
public static void TriggerChangeOwner(int vehicleID, int newOwnerID)
|
||||
{
|
||||
|
||||
Networking.SendSync(new Packets.OwnerChanged()
|
||||
{
|
||||
ID= c.ID,
|
||||
ID= vehicleID,
|
||||
NewOwnerID= newOwnerID,
|
||||
}, ConnectionChannel.SyncEvents);
|
||||
|
||||
@ -67,14 +40,6 @@ namespace RageCoop.Client
|
||||
}
|
||||
Networking.SendBulletShot(start, impactPosition, hash, owner.ID);
|
||||
}
|
||||
public static void TriggerLeaveVehicle(int id)
|
||||
{
|
||||
Networking.
|
||||
SendSync(new Packets.LeaveVehicle()
|
||||
{
|
||||
ID=id
|
||||
}, ConnectionChannel.SyncEvents);
|
||||
}
|
||||
|
||||
public static void TriggerVehBulletShot(uint hash, Vehicle veh, SyncedPed owner)
|
||||
{
|
||||
@ -106,50 +71,19 @@ namespace RageCoop.Client
|
||||
static WeaponAsset _weaponAsset = default;
|
||||
static uint _lastWeaponHash;
|
||||
|
||||
private static void HandleLeaveVehicle(Packets.LeaveVehicle p)
|
||||
{
|
||||
var ped = EntityPool.GetPedByID(p.ID);
|
||||
var veh = ped.MainPed.CurrentVehicle.GetSyncEntity();
|
||||
veh._checkSeat=false;
|
||||
var flag = LeaveVehicleFlags.None;
|
||||
if (ped.MainPed?.CurrentVehicle==null) { return; }
|
||||
// Bail out
|
||||
if (ped.MainPed.CurrentVehicle.Speed>5) { flag|=LeaveVehicleFlags.BailOut; }
|
||||
// ped.PauseUpdate((ulong)Game.FPS*2);
|
||||
ped.MainPed.Task.LeaveVehicle(flag);
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
veh._checkSeat=true;
|
||||
});
|
||||
}
|
||||
private static void HandlePedKilled(Packets.PedKilled p)
|
||||
{
|
||||
EntityPool.GetPedByID(p.VictimID)?.MainPed?.Kill();
|
||||
}
|
||||
private static void HandleEnteringVehicle(SyncedPed c, SyncedVehicle veh, VehicleSeat seat)
|
||||
{
|
||||
c.MainPed?.Task.EnterVehicle(veh.MainVehicle, seat, -1, 2, EnterVehicleFlags.WarpToDoor|EnterVehicleFlags.AllowJacking);
|
||||
}
|
||||
private static void HandleEnteredVehicle(int pedId, int vehId, VehicleSeat seat)
|
||||
{
|
||||
var v = EntityPool.GetVehicleByID(vehId);
|
||||
var p = EntityPool.GetPedByID(pedId)?.MainPed;
|
||||
if (v==null||p==null) { return; }
|
||||
if (!v.MainVehicle.IsSeatFree(seat) && v.MainVehicle.GetPedOnSeat(seat) != p)
|
||||
{
|
||||
v.MainVehicle.GetPedOnSeat(seat).Task.WarpOutOfVehicle(v.MainVehicle);
|
||||
}
|
||||
p.SetIntoVehicle(v.MainVehicle, seat);
|
||||
}
|
||||
private static void HandleOwnerChanged(Packets.OwnerChanged p)
|
||||
{
|
||||
var v = EntityPool.GetVehicleByID(p.ID);
|
||||
if (v==null) { return; }
|
||||
v.OwnerID=p.NewOwnerID;
|
||||
|
||||
v.Model=v.MainVehicle.Model;
|
||||
v.LastSynced=Main.Ticked;
|
||||
v.LastFullSynced=Main.Ticked;
|
||||
v.Position=v.MainVehicle.Position;
|
||||
v.Quaternion=v.MainVehicle.Quaternion;
|
||||
// So this vehicle doesn's get re-spawned
|
||||
}
|
||||
private static void HandleNozzleTransform(Packets.NozzleTransform p)
|
||||
@ -229,22 +163,6 @@ namespace RageCoop.Client
|
||||
HandleBulletShot(p.StartPosition, p.EndPosition, p.WeaponHash, p.OwnerID);
|
||||
break;
|
||||
}
|
||||
case PacketType.EnteringVehicle:
|
||||
{
|
||||
Packets.EnteringVehicle p = new Packets.EnteringVehicle();
|
||||
p.Deserialize(data);
|
||||
HandleEnteringVehicle(EntityPool.GetPedByID(p.PedID), EntityPool.GetVehicleByID(p.VehicleID), (VehicleSeat)p.VehicleSeat);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case PacketType.LeaveVehicle:
|
||||
{
|
||||
Packets.LeaveVehicle packet = new Packets.LeaveVehicle();
|
||||
packet.Deserialize(data);
|
||||
HandleLeaveVehicle(packet);
|
||||
}
|
||||
break;
|
||||
case PacketType.OwnerChanged:
|
||||
{
|
||||
Packets.OwnerChanged packet = new Packets.OwnerChanged();
|
||||
@ -259,13 +177,6 @@ namespace RageCoop.Client
|
||||
HandlePedKilled(packet);
|
||||
}
|
||||
break;
|
||||
case PacketType.EnteredVehicle:
|
||||
{
|
||||
var packet = new Packets.EnteredVehicle();
|
||||
packet.Deserialize(data);
|
||||
HandleEnteredVehicle(packet.PedID, packet.VehicleID, (VehicleSeat)packet.VehicleSeat);
|
||||
break;
|
||||
}
|
||||
case PacketType.NozzleTransform:
|
||||
{
|
||||
var packet = new Packets.NozzleTransform();
|
||||
@ -346,34 +257,6 @@ namespace RageCoop.Client
|
||||
TriggerBulletShot((uint)VehicleWeaponHash.Tank, c, subject.LastWeaponImpactPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// Vehicles
|
||||
var g = subject.IsGettingIntoVehicle;
|
||||
if (g && (!c._lastEnteringVehicle))
|
||||
{
|
||||
var v = subject.VehicleTryingToEnter.GetSyncEntity();
|
||||
TriggerEnteringVehicle(c, v, subject.GetSeatTryingToEnter());
|
||||
}
|
||||
|
||||
var currentSitting = subject.IsSittingInVehicle();
|
||||
if (c._lastSittingInVehicle)
|
||||
{
|
||||
if (!currentSitting)
|
||||
{
|
||||
var veh = subject.CurrentVehicle;
|
||||
if (veh!=null)
|
||||
{
|
||||
var v = veh.GetSyncEntity();
|
||||
TriggerLeaveVehicle(c.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (currentSitting)
|
||||
{
|
||||
TriggerEnteredVehicle(c, subject.CurrentVehicle.GetSyncEntity(), subject.SeatIndex);
|
||||
}
|
||||
c._lastSittingInVehicle=currentSitting;
|
||||
c._lastEnteringVehicle=g;
|
||||
}
|
||||
|
||||
public static void Check(SyncedVehicle v)
|
||||
|
@ -43,17 +43,31 @@ namespace RageCoop.Client
|
||||
|
||||
public static byte GetPedSpeed(this Ped ped)
|
||||
{
|
||||
if (ped.IsSprinting)
|
||||
|
||||
if (ped.IsWalking)
|
||||
{
|
||||
return 3;
|
||||
return 1;
|
||||
}
|
||||
if (ped.IsRunning)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if (ped.IsWalking)
|
||||
if (ped.IsSprinting)
|
||||
{
|
||||
return 1;
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (ped.IsTaskActive(TaskType.CTaskExitVehicle))
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
if (ped.IsInVehicle())
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
if (ped.IsTaskActive(TaskType.CTaskEnterVehicle))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -134,6 +148,7 @@ namespace RageCoop.Client
|
||||
flags |= PedDataFlags.IsInStealthMode;
|
||||
}
|
||||
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,6 @@ namespace RageCoop.Core
|
||||
|
||||
PedKilled=30,
|
||||
BulletShot=31,
|
||||
EnteringVehicle=32,
|
||||
LeaveVehicle = 33,
|
||||
EnteredVehicle=34,
|
||||
OwnerChanged=35,
|
||||
VehicleBulletShot = 36,
|
||||
NozzleTransform=37,
|
||||
@ -98,9 +95,6 @@ namespace RageCoop.Core
|
||||
IsOnLadder = 1 << 8,
|
||||
IsVaulting = 1 << 9,
|
||||
IsInCover = 1 << 10,
|
||||
IsInVehicle = 1 << 11,
|
||||
IsEnteringVehicle = 1 << 12,
|
||||
IsLeavingVehicle = 1 << 13,
|
||||
IsFullSync = 1<<15 ,
|
||||
}
|
||||
#region ===== VEHICLE DATA =====
|
||||
|
@ -17,6 +17,9 @@ namespace RageCoop.Core
|
||||
public int ID { get; set; }
|
||||
|
||||
public int OwnerID { get; set; }
|
||||
|
||||
public int VehicleID { get; set; }
|
||||
public VehicleSeat Seat { get; set; }
|
||||
public PedDataFlags Flags { get; set; }
|
||||
|
||||
public int Health { get; set; }
|
||||
@ -62,21 +65,11 @@ namespace RageCoop.Core
|
||||
{
|
||||
|
||||
List<byte> byteArray = new List<byte>();
|
||||
|
||||
// Write ped ID
|
||||
byteArray.AddInt(ID);
|
||||
|
||||
// Write OwnerID
|
||||
byteArray.AddInt(OwnerID);
|
||||
|
||||
|
||||
// Write ped flags
|
||||
byteArray.AddRange(BitConverter.GetBytes((ushort)Flags));
|
||||
|
||||
// Write ped health
|
||||
byteArray.AddRange(BitConverter.GetBytes(Health));
|
||||
|
||||
// ragdoll sync
|
||||
byteArray.Add(Speed);
|
||||
if (Flags.HasPedFlag(PedDataFlags.IsRagdoll))
|
||||
{
|
||||
byteArray.AddVector3(HeadPosition);
|
||||
@ -86,24 +79,19 @@ namespace RageCoop.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write ped position
|
||||
if (Speed>=4)
|
||||
{
|
||||
byteArray.AddInt(VehicleID);
|
||||
byteArray.Add((byte)(Seat+3));
|
||||
}
|
||||
byteArray.AddVector3(Position);
|
||||
}
|
||||
|
||||
// Write ped rotation
|
||||
byteArray.AddVector3(Rotation);
|
||||
|
||||
// Write ped velocity
|
||||
byteArray.AddVector3(Velocity);
|
||||
|
||||
|
||||
// Write ped speed
|
||||
byteArray.Add(Speed);
|
||||
|
||||
|
||||
if (Flags.HasPedFlag(PedDataFlags.IsAiming))
|
||||
{
|
||||
// Write ped aim coords
|
||||
byteArray.AddVector3(AimCoords);
|
||||
}
|
||||
|
||||
@ -111,15 +99,9 @@ namespace RageCoop.Core
|
||||
|
||||
if (Flags.HasPedFlag(PedDataFlags.IsFullSync))
|
||||
{
|
||||
// Write model hash
|
||||
byteArray.AddInt(ModelHash);
|
||||
|
||||
// Write ped weapon hash
|
||||
byteArray.AddUint(CurrentWeaponHash);
|
||||
|
||||
byteArray.AddRange(Clothes);
|
||||
|
||||
// Write player weapon components
|
||||
if (WeaponComponents != null)
|
||||
{
|
||||
byteArray.Add(0x01);
|
||||
@ -154,16 +136,11 @@ namespace RageCoop.Core
|
||||
#region NetIncomingMessageToPacket
|
||||
BitReader reader = new BitReader(array);
|
||||
|
||||
// Read player netHandle
|
||||
ID = reader.ReadInt32();
|
||||
|
||||
OwnerID=reader.ReadInt32();
|
||||
|
||||
// Read player flags
|
||||
Flags = (PedDataFlags)reader.ReadUInt16();
|
||||
|
||||
// Read player health
|
||||
Health = reader.ReadInt32();
|
||||
Speed = reader.ReadByte();
|
||||
|
||||
if (Flags.HasPedFlag(PedDataFlags.IsRagdoll))
|
||||
{
|
||||
@ -174,21 +151,20 @@ namespace RageCoop.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
// Vehicle related
|
||||
if (Speed>=4)
|
||||
{
|
||||
VehicleID=reader.ReadInt32();
|
||||
Seat=(VehicleSeat)(reader.ReadByte()-3);
|
||||
}
|
||||
|
||||
// Read player position
|
||||
Position = reader.ReadVector3();
|
||||
}
|
||||
|
||||
// Read player rotation
|
||||
Rotation = reader.ReadVector3();
|
||||
|
||||
// Read player velocity
|
||||
Velocity = reader.ReadVector3();
|
||||
|
||||
// Read player speed
|
||||
Speed = reader.ReadByte();
|
||||
|
||||
|
||||
// Try to read aim coords
|
||||
if (Flags.HasPedFlag(PedDataFlags.IsAiming))
|
||||
{
|
||||
// Read player aim coords
|
||||
|
@ -48,7 +48,7 @@ namespace RageCoop.Core
|
||||
|
||||
// Write velocity
|
||||
byteArray.AddVector3(Velocity);
|
||||
byteArray.Add(Exploded?(byte)1:(byte)0);
|
||||
byteArray.AddBool(Exploded);
|
||||
|
||||
return byteArray.ToArray();
|
||||
|
||||
@ -76,10 +76,7 @@ namespace RageCoop.Core
|
||||
// Read velocity
|
||||
Velocity =reader.ReadVector3();
|
||||
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
Exploded=true;
|
||||
}
|
||||
Exploded=reader.ReadBoolean();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
internal partial class Packets
|
||||
{
|
||||
internal class EnteredVehicle : Packet
|
||||
{
|
||||
public override PacketType Type => PacketType.EnteredVehicle;
|
||||
public int PedID { get; set; }
|
||||
|
||||
public int VehicleID { get; set; }
|
||||
|
||||
public short VehicleSeat { get; set; }
|
||||
|
||||
public override byte[] Serialize()
|
||||
{
|
||||
|
||||
List<byte> byteArray = new List<byte>();
|
||||
|
||||
byteArray.AddInt(PedID);
|
||||
byteArray.AddInt(VehicleID);
|
||||
byteArray.AddShort(VehicleSeat);
|
||||
|
||||
return byteArray.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public override void Deserialize(byte[] array)
|
||||
{
|
||||
#region NetIncomingMessageToPacket
|
||||
BitReader reader = new BitReader(array);
|
||||
|
||||
PedID=reader.ReadInt32();
|
||||
VehicleID=reader.ReadInt32();
|
||||
VehicleSeat=reader.ReadInt16();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
internal partial class Packets
|
||||
{
|
||||
internal class EnteringVehicle : Packet
|
||||
{
|
||||
public override PacketType Type => PacketType.EnteringVehicle;
|
||||
public int PedID { get; set; }
|
||||
|
||||
public int VehicleID { get; set; }
|
||||
|
||||
public short VehicleSeat { get; set; }
|
||||
|
||||
public override byte[] Serialize()
|
||||
{
|
||||
|
||||
List<byte> byteArray = new List<byte>();
|
||||
|
||||
byteArray.AddInt(PedID);
|
||||
byteArray.AddInt(VehicleID);
|
||||
byteArray.AddShort(VehicleSeat);
|
||||
|
||||
return byteArray.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public override void Deserialize(byte[] array)
|
||||
{
|
||||
#region NetIncomingMessageToPacket
|
||||
BitReader reader = new BitReader(array);
|
||||
|
||||
PedID=reader.ReadInt32();
|
||||
VehicleID=reader.ReadInt32();
|
||||
VehicleSeat=reader.ReadInt16();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using Lidgren.Network;
|
||||
|
||||
namespace RageCoop.Core
|
||||
{
|
||||
internal partial class Packets
|
||||
{
|
||||
|
||||
internal class LeaveVehicle : Packet
|
||||
{
|
||||
public override PacketType Type => PacketType.LeaveVehicle;
|
||||
public int ID { get; set; }
|
||||
|
||||
|
||||
public override byte[] Serialize()
|
||||
{
|
||||
|
||||
List<byte> byteArray = new List<byte>();
|
||||
|
||||
byteArray.AddInt(ID);
|
||||
|
||||
return byteArray.ToArray();
|
||||
|
||||
}
|
||||
|
||||
public override void Deserialize(byte[] array)
|
||||
{
|
||||
#region NetIncomingMessageToPacket
|
||||
BitReader reader = new BitReader(array);
|
||||
|
||||
ID=reader.ReadInt32();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -54,11 +54,6 @@ namespace RageCoop.Core
|
||||
|
||||
public int Livery { get; set; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// VehicleSeat,PedID
|
||||
/// </summary>
|
||||
public Dictionary<int, int> Passengers { get; set; }
|
||||
|
||||
public byte RadioStation { get; set; } = 255;
|
||||
public string LicensePlate { get; set; }
|
||||
#endregion
|
||||
@ -133,15 +128,6 @@ namespace RageCoop.Core
|
||||
byteArray.Add(0x00);
|
||||
}
|
||||
|
||||
// Write passengers
|
||||
byteArray.AddRange(BitConverter.GetBytes(Passengers.Count));
|
||||
|
||||
foreach (KeyValuePair<int, int> p in Passengers)
|
||||
{
|
||||
byteArray.AddRange(BitConverter.GetBytes(p.Key));
|
||||
byteArray.AddRange(BitConverter.GetBytes(p.Value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Write LockStatus
|
||||
@ -257,19 +243,6 @@ namespace RageCoop.Core
|
||||
}
|
||||
|
||||
|
||||
// Read Passengers
|
||||
Passengers=new Dictionary<int, int>();
|
||||
int count = reader.ReadInt32();
|
||||
for (int i = 0; i<count; i++)
|
||||
{
|
||||
int seat, id;
|
||||
seat = reader.ReadInt32();
|
||||
id = reader.ReadInt32();
|
||||
Passengers.Add(seat, id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Read LockStatus
|
||||
LockStatus=(VehicleLockStatus)reader.ReadByte();
|
||||
|
||||
|
@ -79,13 +79,7 @@ namespace RageCoop.Server
|
||||
{
|
||||
|
||||
if (Settings.UseP2P) { return; }
|
||||
foreach (var c in ClientsByNetHandle.Values)
|
||||
{
|
||||
if (c.NetHandle==client.NetHandle) { continue; }
|
||||
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
||||
packet.Pack(outgoingMessage);
|
||||
MainNetServer.SendMessage(outgoingMessage, c.Connection, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PedSync);
|
||||
}
|
||||
Forward(packet, client, ConnectionChannel.ProjectileSync);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -212,6 +212,10 @@ namespace RageCoop.Server.Scripting
|
||||
ped.Health=p.Health;
|
||||
ped._rot=p.Rotation;
|
||||
ped.Owner=sender;
|
||||
if (p.Speed>=4 && Vehicles.TryGetValue(p.VehicleID,out var v))
|
||||
{
|
||||
ped.LastVehicle=v;
|
||||
}
|
||||
}
|
||||
internal void Update(Packets.VehicleSync p, Client sender)
|
||||
{
|
||||
@ -224,16 +228,6 @@ namespace RageCoop.Server.Scripting
|
||||
veh._pos = p.Position;
|
||||
veh.Owner=sender;
|
||||
veh._quat=p.Quaternion;
|
||||
if (p.Flags.HasVehFlag(VehicleDataFlags.IsFullSync))
|
||||
{
|
||||
foreach (var pair in p.Passengers)
|
||||
{
|
||||
if (Peds.TryGetValue(pair.Value, out var ped))
|
||||
{
|
||||
ped.LastVehicle=veh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
internal void CleanUp(Client left)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user