Use struct to serialize vehicle data

This gonna reduce the tedious work needed to add a new sync, also beings a performance boost
Ped, projectile sync will be updated later
This commit is contained in:
Sardelka9515
2023-03-26 15:36:15 +08:00
parent 826e80c5d8
commit 4fbdd86566
24 changed files with 445 additions and 550 deletions

View File

@ -31,8 +31,8 @@ namespace RageCoop.Client
protected override void OnStart()
{
base.OnStart();
while(Game.IsLoading)
Yield();
while (Game.IsLoading)
Yield();
Notification.Show(NotificationIcon.AllPlayersConf, "RAGECOOP", "Welcome!",
$"Press ~g~{Settings.MenuKey}~s~ to open the menu.");
@ -41,6 +41,18 @@ namespace RageCoop.Client
{
base.OnTick();
if (_sleeping)
{
Game.Pause(true);
while (_sleeping)
{
// Don't wait longer than 5 seconds or the game will crash
Thread.Sleep(4500);
Yield();
}
Game.Pause(false);
}
if (Game.IsLoading) return;
try
@ -224,5 +236,21 @@ namespace RageCoop.Client
QueuedActions.Clear();
}
}
private static bool _sleeping;
[ConsoleCommand("Put the game to sleep state by blocking main thread, press any key in the debug console to resume")]
public static void Sleep()
{
if (_sleeping)
throw new InvalidOperationException("Already in sleep state");
_sleeping = true;
Task.Run(() =>
{
System.Console.WriteLine("Press any key to put the game out of sleep state");
System.Console.ReadKey();
System.Console.WriteLine("Game resumed");
_sleeping = false;
});
}
}
}