diff --git a/Client/COOPAPI.cs b/Client/COOPAPI.cs
index 086979f..c4c63bb 100644
--- a/Client/COOPAPI.cs
+++ b/Client/COOPAPI.cs
@@ -45,10 +45,6 @@ namespace RageCoop.Client
/// ?
///
public static event ChatMessage OnChatMessage;
- ///
- /// ?
- ///
- public static event ModEvent OnModPacketReceived;
public static void Connected()
{
@@ -60,9 +56,9 @@ namespace RageCoop.Client
OnConnection?.Invoke(false, GetPlayerID(), reason);
}
- public static void Connected(long netHandle)
+ public static void Connected(int playerID)
{
- OnConnection?.Invoke(true, netHandle);
+ OnConnection?.Invoke(true, playerID);
}
public static void Disconnected(long netHandle)
@@ -70,11 +66,6 @@ namespace RageCoop.Client
OnConnection?.Invoke(false, netHandle);
}
- public static void ModPacketReceived(long from, string mod, byte customID, byte[] bytes)
- {
- OnModPacketReceived?.Invoke(from, mod, customID, bytes);
- }
-
public static bool ChatMessageReceived(string from, string message)
{
CancelEventArgs args = new CancelEventArgs(false);
@@ -127,20 +118,6 @@ namespace RageCoop.Client
return Main.LocalPlayerID;
}
- /*
-
- ///
- /// Get a player using their Lidgren Network net handle
- ///
- /// Lidgren-Network net handle
- public static CharacterEntity GetPed(int ID)
- {
- lock (Main.Characters)
- {
- return Main.Characters.ContainsKey(ID) ? Main.Characters[ID] : null;
- }
- }
- */
///
/// Check if a RAGECOOP menu is visible
///
@@ -149,7 +126,7 @@ namespace RageCoop.Client
#if NON_INTERACTIVE
return false;
#else
- return Main.MainMenu.MenuPool.AreAnyVisible;
+ return Menus.CoopMenu.MenuPool.AreAnyVisible;
#endif
}
@@ -177,40 +154,6 @@ namespace RageCoop.Client
return Main.CurrentVersion;
}
- ///
- /// Send any data (bytes) to the server
- ///
- /// The name of this modification (script)
- /// The ID to know what the data is
- /// Your class, structure or whatever in bytes
- public static void SendDataToServer(string modName, byte customID, byte[] bytes)
- {
- Networking.SendModData(-1, modName, customID, bytes);
- }
-
- ///
- /// Send any data (bytes) to the all player
- ///
- /// The name of this modification (script)
- /// The ID to know what the data is
- /// Your class, structure or whatever in bytes
- public static void SendDataToAll(string modName, byte customID, byte[] bytes)
- {
- Networking.SendModData(0, modName, customID, bytes);
- }
-
- ///
- /// Send any data (bytes) to a player
- ///
- /// The Lidgren Network net handle that receives the data
- /// The name of this modification (script)
- /// The ID to know what the data is
- /// Your class, structure or whatever in bytes
- public static void SendDataToPlayer(long netHandle, string modName, byte customID, byte[] bytes)
- {
- Networking.SendModData(netHandle, modName, customID, bytes);
- }
-
///
/// Get that player's local username
///
@@ -236,35 +179,13 @@ namespace RageCoop.Client
return true;
}
-
///
- /// Enable or disable the local traffic for this player
+ /// Get or set the client's settings.
///
- /// true to disable traffic
- public static void SetLocalTraffic(bool enable)
+ /// The client's settings, you should NEVER change settings without notifying the player.
+ public static Settings Settings()
{
- Main.Settings.DisableTraffic = !enable;
+ return Main.Settings;
}
-
- ///
- /// Sets the alignment for the player list, if set to true it will align left,
- /// otherwise it will align right
- ///
- /// true to move the player list to the left
- public static void SetPlayerListLeftAlign(bool leftAlign)
- {
- PlayerList.LeftAlign = leftAlign;
- }
-
-#if DEBUG
- ///
- /// ?
- ///
- ///
- public static void SetDebug(bool value)
- {
- Main.UseDebug = value;
- }
-#endif
}
}
diff --git a/Client/Main.cs b/Client/Main.cs
index bcbe8e2..925d8c7 100644
--- a/Client/Main.cs
+++ b/Client/Main.cs
@@ -26,13 +26,12 @@ namespace RageCoop.Client
public static readonly string CurrentVersion = "V0_3";
public static int LocalPlayerID=0;
- public static bool NPCsAllowed = false;
+
internal static RelationshipGroup SyncedPedsGroup;
public static new Settings Settings = null;
#if !NON_INTERACTIVE
- public static RageCoopMenu MainMenu = null;
#endif
public static Chat MainChat = null;
public static Stopwatch Counter = new Stopwatch();
@@ -71,7 +70,6 @@ namespace RageCoop.Client
Settings = Util.ReadSettings();
Networking.Start();
#if !NON_INTERACTIVE
- MainMenu = new RageCoopMenu();
#endif
MainChat = new Chat();
#if DEBUG
@@ -107,7 +105,7 @@ namespace RageCoop.Client
}
#if !NON_INTERACTIVE
- MainMenu.MenuPool.Process();
+ CoopMenu.MenuPool.Process();
#endif
@@ -193,14 +191,20 @@ namespace RageCoop.Client
}
if (e.KeyCode == Settings.MenuKey)
{
- if (MainMenu.MenuPool.AreAnyVisible)
+ if (CoopMenu.MenuPool.AreAnyVisible)
{
- MainMenu.MainMenu.Visible = false;
- MainMenu.SubSettings.Menu.Visible = false;
+ CoopMenu.MenuPool.ForEach(x =>
+ {
+ if (x.Visible)
+ {
+ CoopMenu.LastMenu=x;
+ x.Visible=false;
+ }
+ });
}
else
{
- MainMenu.MainMenu.Visible = true;
+ CoopMenu.LastMenu.Visible = true;
}
}
else if (Game.IsControlJustPressed(GTA.Control.MultiplayerInfo))
@@ -234,7 +238,7 @@ namespace RageCoop.Client
if (V!=null)
{
- var seat = Util.GetNearestSeat(P, V);
+ var seat = P.GetNearestSeat(V);
P.Task.EnterVehicle(V, seat);
}
}
diff --git a/Client/Menus/RageCoopMenu.cs b/Client/Menus/CoopMenu.cs
similarity index 59%
rename from Client/Menus/RageCoopMenu.cs
rename to Client/Menus/CoopMenu.cs
index 4b95987..7b0ea00 100644
--- a/Client/Menus/RageCoopMenu.cs
+++ b/Client/Menus/CoopMenu.cs
@@ -10,24 +10,20 @@ namespace RageCoop.Client.Menus
///
/// Don't use it!
///
- public class RageCoopMenu
+ internal static class CoopMenu
{
- public ObjectPool MenuPool = new ObjectPool();
-
- public NativeMenu MainMenu = new NativeMenu("RAGECOOP", "MAIN")
+ public static ObjectPool MenuPool = new ObjectPool();
+ public static NativeMenu Menu = new NativeMenu("RAGECOOP", "MAIN")
{
UseMouse = false,
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
};
- #region SUB
- public SettingsMenu SubSettings = new SettingsMenu();
- #endregion
-
+ public static NativeMenu LastMenu { get; set; } = Menu;
#region ITEMS
- private readonly NativeItem _usernameItem = new NativeItem("Username") { AltTitle = Main.Settings.Username };
- public readonly NativeItem ServerIpItem = new NativeItem("Server IP") { AltTitle = Main.Settings.LastServerAddress };
- private readonly NativeItem _serverConnectItem = new NativeItem("Connect");
- private readonly NativeItem _aboutItem = new NativeItem("About", "~y~SOURCE~s~~n~" +
+ private static readonly NativeItem _usernameItem = new NativeItem("Username") { AltTitle = Main.Settings.Username };
+ public static readonly NativeItem ServerIpItem = new NativeItem("Server IP") { AltTitle = Main.Settings.LastServerAddress };
+ private static readonly NativeItem _serverConnectItem = new NativeItem("Connect");
+ private static readonly NativeItem _aboutItem = new NativeItem("About", "~y~SOURCE~s~~n~" +
"https://github.com/RAGECOOP~n~" +
"~y~VERSION~s~~n~" +
Main.CurrentVersion.Replace("_", ".")) { LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") };
@@ -38,35 +34,35 @@ namespace RageCoop.Client.Menus
///
/// Don't use it!
///
- public RageCoopMenu()
+ static CoopMenu()
{
- MainMenu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
- MainMenu.Title.Color = Color.FromArgb(255, 165, 0);
+ Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
+ Menu.Title.Color = Color.FromArgb(255, 165, 0);
_usernameItem.Activated += UsernameActivated;
ServerIpItem.Activated += ServerIpActivated;
_serverConnectItem.Activated += (sender, item) => { Networking.DisConnectFromServer(Main.Settings.LastServerAddress); };
- MainMenu.Add(_usernameItem);
- MainMenu.Add(ServerIpItem);
- MainMenu.Add(_serverConnectItem);
+ Menu.Add(_usernameItem);
+ Menu.Add(ServerIpItem);
+ Menu.Add(_serverConnectItem);
- MainMenu.AddSubMenu(SubSettings.Menu);
- MainMenu.AddSubMenu(DevToolMenu.Menu);
- MainMenu.AddSubMenu(DebugMenu.Menu);
+ Menu.AddSubMenu(SettingsMenu.Menu);
+ Menu.AddSubMenu(DevToolMenu.Menu);
+ Menu.AddSubMenu(DebugMenu.Menu);
- MenuPool.Add(MainMenu);
- MenuPool.Add(SubSettings.Menu);
+ MenuPool.Add(Menu);
+ MenuPool.Add(SettingsMenu.Menu);
MenuPool.Add(DevToolMenu.Menu);
MenuPool.Add(DebugMenu.Menu);
MenuPool.Add(DebugMenu.DiagnosticMenu);
- MainMenu.Add(_aboutItem);
+ Menu.Add(_aboutItem);
}
- public void UsernameActivated(object a, System.EventArgs b)
+ public static void UsernameActivated(object a, System.EventArgs b)
{
string newUsername = Game.GetUserInput(WindowTitle.EnterMessage20, _usernameItem.AltTitle, 20);
if (!string.IsNullOrWhiteSpace(newUsername))
@@ -78,7 +74,7 @@ namespace RageCoop.Client.Menus
}
}
- public void ServerIpActivated(object a, System.EventArgs b)
+ public static void ServerIpActivated(object a, System.EventArgs b)
{
string newServerIp = Game.GetUserInput(WindowTitle.EnterMessage60, ServerIpItem.AltTitle, 60);
if (!string.IsNullOrWhiteSpace(newServerIp) && newServerIp.Contains(":"))
@@ -90,21 +86,21 @@ namespace RageCoop.Client.Menus
}
}
- public void InitiateConnectionMenuSetting()
+ public static void InitiateConnectionMenuSetting()
{
_usernameItem.Enabled = false;
ServerIpItem.Enabled = false;
_serverConnectItem.Enabled = false;
}
- public void ConnectedMenuSetting()
+ public static void ConnectedMenuSetting()
{
_serverConnectItem.Enabled = true;
_serverConnectItem.Title = "Disconnect";
- MainMenu.Visible = false;
+ Menu.Visible = false;
}
- public void DisconnectedMenuSetting()
+ public static void DisconnectedMenuSetting()
{
_usernameItem.Enabled = true;
ServerIpItem.Enabled = true;
diff --git a/Client/Menus/Sub/DevToolMenu.cs b/Client/Menus/Sub/DevToolMenu.cs
index 74763fb..3ce7e7d 100644
--- a/Client/Menus/Sub/DevToolMenu.cs
+++ b/Client/Menus/Sub/DevToolMenu.cs
@@ -9,7 +9,7 @@ using System.Drawing;
namespace RageCoop.Client
{
- internal class DevToolMenu
+ internal static class DevToolMenu
{
public static NativeMenu Menu = new NativeMenu("RAGECOOP", "DevTool", "Help with the development")
{
diff --git a/Client/Menus/Sub/SettingsMenu.cs b/Client/Menus/Sub/SettingsMenu.cs
index c9f9827..c3f77e7 100644
--- a/Client/Menus/Sub/SettingsMenu.cs
+++ b/Client/Menus/Sub/SettingsMenu.cs
@@ -9,19 +9,19 @@ namespace RageCoop.Client.Menus
///
/// Don't use it!
///
- public class SettingsMenu
+ internal static class SettingsMenu
{
- public NativeMenu Menu = new NativeMenu("RAGECOOP", "Settings", "Go to the settings")
+ public static NativeMenu Menu = new NativeMenu("RAGECOOP", "Settings", "Go to the settings")
{
UseMouse = false,
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
};
- private readonly NativeCheckboxItem _disableTrafficItem = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.Settings.DisableTraffic);
- private readonly NativeCheckboxItem _flipMenuItem = new NativeCheckboxItem("Flip menu", Main.Settings.FlipMenu);
- private readonly NativeCheckboxItem _disablePauseAlt = new NativeCheckboxItem("Disable Alternate Pause", "Don't freeze game time when Esc pressed", Main.Settings.DisableTraffic);
+ private static readonly NativeCheckboxItem _disableTrafficItem = new NativeCheckboxItem("Disable Traffic (NPCs/Vehicles)", "Local traffic only", Main.Settings.DisableTraffic);
+ private static readonly NativeCheckboxItem _flipMenuItem = new NativeCheckboxItem("Flip menu", Main.Settings.FlipMenu);
+ private static readonly NativeCheckboxItem _disablePauseAlt = new NativeCheckboxItem("Disable Alternate Pause", "Don't freeze game time when Esc pressed", Main.Settings.DisableTraffic);
- private readonly NativeCheckboxItem _showNetworkInfoItem = new NativeCheckboxItem("Show Network Info", Networking.ShowNetworkInfo);
+ private static readonly NativeCheckboxItem _showNetworkInfoItem = new NativeCheckboxItem("Show Network Info", Networking.ShowNetworkInfo);
private static NativeItem _menuKey = new NativeItem("Menu Key","The key to open menu", Main.Settings.MenuKey.ToString());
private static NativeItem _passengerKey = new NativeItem("Passenger Key", "The key to enter a vehicle as passenger", Main.Settings.PassengerKey.ToString());
@@ -30,7 +30,7 @@ namespace RageCoop.Client.Menus
///
/// Don't use it!
///
- public SettingsMenu()
+ static SettingsMenu()
{
Menu.Banner.Color = Color.FromArgb(225, 0, 0, 0);
Menu.Title.Color = Color.FromArgb(255, 165, 0);
@@ -52,14 +52,14 @@ namespace RageCoop.Client.Menus
Menu.Add(_vehicleSoftLimit);
}
-
- private void _disablePauseAlt_CheckboxChanged(object sender, EventArgs e)
+
+ private static void _disablePauseAlt_CheckboxChanged(object sender, EventArgs e)
{
Main.Settings.DisableAlternatePause=_disablePauseAlt.Checked;
Util.SaveSettings();
}
- private void vehicleSoftLimit_Activated(object sender, EventArgs e)
+ private static void vehicleSoftLimit_Activated(object sender, EventArgs e)
{
try
{
@@ -71,7 +71,7 @@ namespace RageCoop.Client.Menus
}
catch { }
}
- private void ChaneMenuKey(object sender, EventArgs e)
+ private static void ChaneMenuKey(object sender, EventArgs e)
{
try
{
@@ -85,7 +85,7 @@ namespace RageCoop.Client.Menus
catch { }
}
- private void ChangePassengerKey(object sender, EventArgs e)
+ private static void ChangePassengerKey(object sender, EventArgs e)
{
try
{
@@ -99,22 +99,22 @@ namespace RageCoop.Client.Menus
catch { }
}
- public void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
+ public static void DisableTrafficCheckboxChanged(object a, System.EventArgs b)
{
Main.Settings.DisableTraffic = _disableTrafficItem.Checked;
Util.SaveSettings() ;
}
- public void FlipMenuCheckboxChanged(object a, System.EventArgs b)
+ public static void FlipMenuCheckboxChanged(object a, System.EventArgs b)
{
- Main.MainMenu.MainMenu.Alignment = _flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
+ CoopMenu.Menu.Alignment = _flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
Menu.Alignment = _flipMenuItem.Checked ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left;
Main.Settings.FlipMenu = _flipMenuItem.Checked;
Util.SaveSettings();
}
- public void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
+ public static void ShowNetworkInfoCheckboxChanged(object a, System.EventArgs b)
{
Networking.ShowNetworkInfo = _showNetworkInfoItem.Checked;
diff --git a/Client/Misc/Util.cs b/Client/Misc/Util.cs
deleted file mode 100644
index 7dfdf6b..0000000
--- a/Client/Misc/Util.cs
+++ /dev/null
@@ -1,982 +0,0 @@
-using System;
-using System.IO;
-using System.Xml.Serialization;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-using RageCoop.Core;
-using GTA;
-using GTA.Native;
-using GTA.Math;
-using System.Linq;
-using System.Diagnostics;
-
-namespace RageCoop.Client
-{
- ///
- ///
- ///
-
- internal static partial class Util
- {
- #region -- POINTER --
- private static int _steeringAngleOffset { get; set; }
-
- public static unsafe void NativeMemory()
- {
- IntPtr address;
-
- address = Game.FindPattern("\x74\x0A\xF3\x0F\x11\xB3\x1C\x09\x00\x00\xEB\x25", "xxxxxx????xx");
- if (address != IntPtr.Zero)
- {
- _steeringAngleOffset = *(int*)(address + 6) + 8;
- }
-
- // breaks some stuff.
- /*
- address = Game.FindPattern("\x32\xc0\xf3\x0f\x11\x09", "xxxxxx"); // Weapon / Radio slowdown
- if (address != IntPtr.Zero)
- {
- for (int i = 0; i < 6; i++)
- {
- *(byte*)(address + i).ToPointer() = 0x90;
- }
- }
- */
- }
-
- public static unsafe void CustomSteeringAngle(this Vehicle veh, float value)
- {
- IntPtr address = new IntPtr((long)veh.MemoryAddress);
- if (address == IntPtr.Zero || _steeringAngleOffset == 0)
- {
- return;
- }
-
- *(float*)(address + _steeringAngleOffset).ToPointer() = value;
- }
- #endregion
-
- public static Settings ReadSettings()
- {
- XmlSerializer ser = new XmlSerializer(typeof(Settings));
-
- string path = Directory.GetCurrentDirectory() + "\\Scripts\\RageCoop\\RageCoop.Client.Settings.xml";
- Settings settings = null;
-
- if (File.Exists(path))
- {
- using (FileStream stream = File.OpenRead(path))
- {
- settings = (RageCoop.Client.Settings)ser.Deserialize(stream);
- }
-
- using (FileStream stream = new FileStream(path, FileMode.Truncate, FileAccess.ReadWrite))
- {
- ser.Serialize(stream, settings);
- }
- }
- else
- {
- using (FileStream stream = File.OpenWrite(path))
- {
- ser.Serialize(stream, settings = new Settings());
- }
- }
-
- return settings;
- }
- public static void SaveSettings()
- {
- try
- {
- string path = Directory.GetCurrentDirectory() + "\\Scripts\\RageCoop\\RageCoop.Client.Settings.xml";
-
- using (FileStream stream = new FileStream(path, File.Exists(path) ? FileMode.Truncate : FileMode.Create, FileAccess.ReadWrite))
- {
- XmlSerializer ser = new XmlSerializer(typeof(Settings));
- ser.Serialize(stream, Main.Settings);
- }
- }
- catch (Exception ex)
- {
- GTA.UI.Notification.Show("Error saving player settings: " + ex.Message);
- }
- }
-
-
-
-
- public static bool IsBetween(this T item, T start, T end)
- {
- return Comparer.Default.Compare(item, start) >= 0 && Comparer.Default.Compare(item, end) <= 0;
- }
-
- public static bool Compare(this Dictionary item, Dictionary item2)
- {
- if (item == null || item2 == null || item.Count != item2.Count)
- {
- return false;
- }
-
- foreach (KeyValuePair pair in item)
- {
- if (item2.TryGetValue(pair.Key, out Y value) && Equals(value, pair.Value))
- {
- continue;
- }
-
- // TryGetValue() or Equals failed
- return false;
- }
-
- // No difference between item and item2
- return true;
- }
-
- #region MATH
- public static Vector3 LinearVectorLerp(Vector3 start, Vector3 end, ulong currentTime, int duration)
- {
- return new Vector3()
- {
- X = LinearFloatLerp(start.X, end.X, currentTime, duration),
- Y = LinearFloatLerp(start.Y, end.Y, currentTime, duration),
- Z = LinearFloatLerp(start.Z, end.Z, currentTime, duration),
- };
- }
-
- public static float LinearFloatLerp(float start, float end, ulong currentTime, int duration)
- {
- return (end - start) * currentTime / duration + start;
- }
-
- public static float Lerp(float from, float to, float fAlpha)
- {
- return (from * (1.0f - fAlpha)) + (to * fAlpha); //from + (to - from) * fAlpha
- }
-
- public static Vector3 RotationToDirection(Vector3 rotation)
- {
- double z = MathExtensions.DegToRad(rotation.Z);
- double x = MathExtensions.DegToRad(rotation.X);
- double num = Math.Abs(Math.Cos(x));
-
- return new Vector3
- {
- X = (float)(-Math.Sin(z) * num),
- Y = (float)(Math.Cos(z) * num),
- Z = (float)Math.Sin(x)
- };
- }
-
-
- #endregion
-
- public static Model ModelRequest(this int hash)
- {
- Model model = new Model(hash);
-
- if (!model.IsValid)
- {
- //GTA.UI.Notification.Show("~y~Not valid!");
- return null;
- }
-
- if (!model.IsLoaded)
- {
- return model.Request(1000) ? model : null;
- }
-
- return model;
- }
-
- #region PED
-
- public static byte GetPedSpeed(this Ped ped)
- {
- if (ped.IsSprinting)
- {
- return 3;
- }
- if (ped.IsRunning)
- {
- return 2;
- }
- if (ped.IsWalking)
- {
- return 1;
- }
-
- return 0;
- }
-
- public static Dictionary GetPedClothes(this Ped ped)
- {
- Dictionary result = new Dictionary();
- for (byte i = 0; i < 11; i++)
- {
- short mod = Function.Call(Hash.GET_PED_DRAWABLE_VARIATION, ped.Handle, i);
- result.Add(i, mod);
- }
- return result;
- }
-
- public static PedDataFlags GetPedFlags(this Ped ped)
- {
- PedDataFlags flags = PedDataFlags.None;
-
- if (ped.IsAiming || ped.IsOnTurretSeat())
- {
- flags |= PedDataFlags.IsAiming;
- }
-
-
- if (ped.IsReloading)
- {
- flags |= PedDataFlags.IsReloading;
- }
-
- if (ped.IsJumping)
- {
- flags |= PedDataFlags.IsJumping;
- }
-
- if (ped.IsRagdoll)
- {
- flags |= PedDataFlags.IsRagdoll;
- }
-
- if (ped.IsOnFire)
- {
- flags |= PedDataFlags.IsOnFire;
- }
-
- if (ped.IsInParachuteFreeFall)
- {
- flags |= PedDataFlags.IsInParachuteFreeFall;
- }
-
- if (ped.ParachuteState == ParachuteState.Gliding)
- {
- flags |= PedDataFlags.IsParachuteOpen;
- }
-
- bool climbingLadder = ped.IsTaskActive(TaskType.CTaskGoToAndClimbLadder);
- if (climbingLadder)
- {
- flags |= PedDataFlags.IsOnLadder;
- }
-
- if (ped.IsVaulting && !climbingLadder)
- {
- flags |= PedDataFlags.IsVaulting;
- }
-
- if (ped.IsInCover || ped.IsGoingIntoCover)
- {
- flags |=PedDataFlags.IsInCover;
- }
- if (ped.IsPlayer)
- {
- flags|=PedDataFlags.IsPlayer;
- }
- return flags;
- }
-
- public static string[] GetReloadingAnimation(this Ped ped)
- {
- switch (ped.Weapons.Current.Hash)
- {
- case WeaponHash.Revolver:
- case WeaponHash.RevolverMk2:
- case WeaponHash.DoubleActionRevolver:
- case WeaponHash.NavyRevolver:
- return new string[2] { "anim@weapons@pistol@revolver_str", "reload_aim" };
- case WeaponHash.APPistol:
- return new string[2] { "weapons@pistol@ap_pistol_str", "reload_aim" };
- case WeaponHash.Pistol50:
- return new string[2] { "weapons@pistol@pistol_50_str", "reload_aim" };
- case WeaponHash.Pistol:
- case WeaponHash.PistolMk2:
- case WeaponHash.PericoPistol:
- case WeaponHash.SNSPistol:
- case WeaponHash.SNSPistolMk2:
- case WeaponHash.HeavyPistol:
- case WeaponHash.VintagePistol:
- case WeaponHash.CeramicPistol:
- case WeaponHash.MachinePistol:
- return new string[2] { "weapons@pistol@pistol_str", "reload_aim" };
- case WeaponHash.AssaultRifle:
- case WeaponHash.AssaultrifleMk2:
- return new string[2] { "weapons@rifle@hi@assault_rifle_str", "reload_aim" };
- case WeaponHash.SniperRifle:
- return new string[2] { "weapons@rifle@hi@sniper_rifle_str", "reload_aim" };
- case WeaponHash.HeavySniper:
- case WeaponHash.HeavySniperMk2:
- return new string[2] { "weapons@rifle@lo@sniper_heavy_str", "reload_aim" };
- case WeaponHash.PumpShotgun:
- case WeaponHash.PumpShotgunMk2:
- return new string[2] { "weapons@rifle@pump_str", "reload_aim" };
- case WeaponHash.Railgun:
- return new string[2] { "weapons@rifle@lo@rail_gun_str", "reload_aim" };
- case WeaponHash.SawnOffShotgun:
- return new string[2] { "weapons@rifle@lo@sawnoff_str", "reload_aim" };
- case WeaponHash.AssaultShotgun:
- return new string[2] { "weapons@rifle@lo@shotgun_assault_str", "reload_aim" };
- case WeaponHash.BullpupShotgun:
- return new string[2] { "weapons@rifle@lo@shotgun_bullpup_str", "reload_aim" };
- case WeaponHash.AdvancedRifle:
- return new string[2] { "weapons@submg@advanced_rifle_str", "reload_aim" };
- case WeaponHash.CarbineRifle:
- case WeaponHash.CarbineRifleMk2:
- case WeaponHash.CompactRifle:
- return new string[2] { "weapons@rifle@lo@carbine_str", "reload_aim" };
- case WeaponHash.Gusenberg:
- return new string[2] { "anim@weapons@machinegun@gusenberg_str", "reload_aim" };
- case WeaponHash.Musket:
- return new string[2] { "anim@weapons@musket@musket_str", "reload_aim" };
- case WeaponHash.FlareGun:
- return new string[2] { "anim@weapons@pistol@flare_str", "reload_aim" };
- case WeaponHash.SpecialCarbine:
- case WeaponHash.SpecialCarbineMk2:
- return new string[2] { "anim@weapons@rifle@lo@spcarbine_str", "reload_aim" };
- case WeaponHash.CombatPDW:
- return new string[2] { "anim@weapons@rifle@lo@pdw_str", "reload_aim" };
- case WeaponHash.BullpupRifle:
- case WeaponHash.BullpupRifleMk2:
- return new string[2] { "anim@weapons@submg@bullpup_rifle_str", "reload_aim" };
- case WeaponHash.AssaultSMG:
- return new string[2] { "weapons@submg@assault_smg_str", "reload_aim" };
- case WeaponHash.MicroSMG:
- case WeaponHash.MiniSMG:
- return new string[2] { "weapons@submg@lo@micro_smg_str", "reload_aim" };
- case WeaponHash.SMG:
- case WeaponHash.SMGMk2:
- return new string[2] { "weapons@rifle@smg_str", "reload_aim" };
- case WeaponHash.GrenadeLauncher:
- case WeaponHash.GrenadeLauncherSmoke:
- case WeaponHash.CompactGrenadeLauncher:
- return new string[2] { "weapons@heavy@grenade_launcher_str", "reload_aim" };
- case WeaponHash.RPG:
- case WeaponHash.Firework:
- return new string[2] { "weapons@heavy@rpg_str", "reload_aim" };
- case WeaponHash.CombatMG:
- case WeaponHash.CombatMGMk2:
- return new string[2] { "weapons@machinegun@combat_mg_str", "reload_aim" };
- case WeaponHash.MG:
- return new string[2] { "weapons@machinegun@mg_str", "reload_aim" };
- default:
- Main.Logger.Warning($"~r~Reloading failed! Weapon ~g~[{ped.Weapons.Current.Hash}]~r~ could not be found!");
- return null;
- }
- }
-
- public static VehicleSeat GetNearestSeat(Ped ped, Vehicle veh, float distanceToignoreDoors = 50f)
- {
- float num = 99f;
- int result = -2;
- Dictionary dictionary = new Dictionary();
- dictionary.Add("door_dside_f", -1);
- dictionary.Add("door_pside_f", 0);
- dictionary.Add("door_dside_r", 1);
- dictionary.Add("door_pside_r", 2);
- foreach (string text in dictionary.Keys)
- {
- bool flag = veh.Bones[text].Position != Vector3.Zero;
- if (flag)
- {
- float num2 = ped.Position.DistanceTo(Function.Call(Hash.GET_WORLD_POSITION_OF_ENTITY_BONE, new InputArgument[]
- {
- veh,
- veh.Bones[text].Index
- }));
- bool flag2 = (num2 < distanceToignoreDoors) && (num2 < num)&& IsSeatUsableByPed(ped, veh, dictionary[text]);
- if (flag2)
- {
- num = num2;
- result = dictionary[text];
- }
- }
- }
- return (VehicleSeat)result;
- }
- public static bool IsSeatUsableByPed(Ped ped, Vehicle veh, int _seat)
- {
- VehicleSeat seat = (VehicleSeat)_seat;
- bool result = false;
- bool flag = veh.IsSeatFree(seat);
- if (flag)
- {
- result = true;
- }
- else
- {
-
- bool isDead = veh.GetPedOnSeat(seat).IsDead;
- if (isDead)
- {
- result = true;
- }
- else
- {
- int num = Function.Call(Hash.GET_RELATIONSHIP_BETWEEN_PEDS, new InputArgument[]
- {
- ped,
- veh.GetPedOnSeat(seat)
- });
- bool flag2 = num > 2;
- if (flag2)
- {
- result = true;
- }
- }
-
- }
- return result;
- }
- public static bool IsTaskActive(this Ped p,TaskType task)
- {
- return Function.Call(Hash.GET_IS_TASK_ACTIVE, p.Handle, task);
- }
- public static Vector3 GetAimCoord(this Ped p)
- {
- var weapon = p.Weapons.CurrentWeaponObject;
-
- var v = p.CurrentVehicle;
- // Rhino
- if (v!=null && v.Model.Hash==782665360)
- {
- return v.Bones[35].Position+v.Bones[35].ForwardVector*100;
- }
- if (p.IsOnTurretSeat()) { return p.GetLookingCoord(); }
- if (weapon!=null)
- {
- // Not very accurate, but doesn't matter
- Vector3 dir = weapon.RightVector;
- return weapon.Position+dir*20;
-
- }
- return GetLookingCoord(p);
- }
- public static Vector3 GetLookingCoord(this Ped p)
- {
- EntityBone b = p.Bones[Bone.FacialForehead];
- Vector3 v = b.UpVector.Normalized;
- return b.Position+200*v;
- }
-
- public static void StayInCover(this Ped p)
- {
- Function.Call(Hash.TASK_STAY_IN_COVER, p);
- }
- public static VehicleSeat GetSeatTryingToEnter(this Ped p)
- {
- return (VehicleSeat)Function.Call(Hash.GET_SEAT_PED_IS_TRYING_TO_ENTER, p);
- }
-
-
-
- #endregion
-
- #region VEHICLE
-
- public static VehicleDataFlags GetVehicleFlags(this Vehicle veh)
- {
- VehicleDataFlags flags = 0;
-
- if (veh.IsEngineRunning)
- {
- flags |= VehicleDataFlags.IsEngineRunning;
- }
-
- if (veh.AreLightsOn)
- {
- flags |= VehicleDataFlags.AreLightsOn;
- }
-
- if (veh.BrakePower >= 0.01f)
- {
- flags |= VehicleDataFlags.AreBrakeLightsOn;
- }
-
- if (veh.AreHighBeamsOn)
- {
- flags |= VehicleDataFlags.AreHighBeamsOn;
- }
-
- if (veh.IsSirenActive)
- {
- flags |= VehicleDataFlags.IsSirenActive;
- }
-
- if (veh.IsDead)
- {
- flags |= VehicleDataFlags.IsDead;
- }
-
- if (Function.Call(Hash.IS_HORN_ACTIVE, veh.Handle))
- {
- flags |= VehicleDataFlags.IsHornActive;
- }
-
- if (veh.IsSubmarineCar && Function.Call(Hash._GET_IS_SUBMARINE_VEHICLE_TRANSFORMED, veh.Handle))
- {
- flags |= VehicleDataFlags.IsTransformed;
- }
-
- if (veh.HasRoof && (veh.RoofState == VehicleRoofState.Opened || veh.RoofState == VehicleRoofState.Opening))
- {
- flags |= VehicleDataFlags.RoofOpened;
- }
-
-
- if (veh.IsAircraft)
- {
- flags |= VehicleDataFlags.IsAircraft;
- }
- if (veh.Model.Hash==1483171323 && veh.IsDeluxoHovering())
- {
- flags|= VehicleDataFlags.IsDeluxoHovering;
- }
-
-
-
- return flags;
- }
- public static bool HasFlag(this PedDataFlags flagToCheck,PedDataFlags flag)
- {
- return (flagToCheck & flag)!=0;
- }
-
- public static bool HasFlag(this VehicleDataFlags flagToCheck, VehicleDataFlags flag)
- {
- return (flagToCheck & flag)!=0;
- }
-
-
- public static Dictionary GetWeaponComponents(this Weapon weapon)
- {
- Dictionary result = null;
-
- if (weapon.Components.Count > 0)
- {
- result = new Dictionary();
-
- foreach (var comp in weapon.Components)
- {
- result.Add((uint)comp.ComponentHash, comp.Active);
- }
- }
-
- return result;
- }
-
- public static Dictionary GetVehicleMods(this VehicleModCollection mods)
- {
- Dictionary result = new Dictionary();
- foreach (VehicleMod mod in mods.ToArray())
- {
- result.Add((int)mod.Type, mod.Index);
- }
- return result;
- }
-
- public static VehicleDamageModel GetVehicleDamageModel(this Vehicle veh)
- {
- // Broken windows
- byte brokenWindows = 0;
- for (int i = 0; i < 8; i++)
- {
- if (!veh.Windows[(VehicleWindowIndex)i].IsIntact)
- {
- brokenWindows |= (byte)(1 << i);
- }
- }
-
- // Broken doors
- byte brokenDoors = 0;
- byte openedDoors = 0;
- foreach (VehicleDoor door in veh.Doors)
- {
- if (door.IsBroken)
- {
- brokenDoors |= (byte)(1 << (byte)door.Index);
- }
- else if (door.IsOpen)
- {
- openedDoors |= (byte)(1 << (byte)door.Index);
- }
- }
-
-
- // Bursted tires
- short burstedTires = 0;
- foreach (VehicleWheel wheel in veh.Wheels.GetAllWheels())
- {
- if (wheel.IsBursted)
- {
- burstedTires |= (short)(1 << (int)wheel.BoneId);
- }
- }
-
- return new VehicleDamageModel()
- {
- BrokenDoors = brokenDoors,
- OpenedDoors = openedDoors,
- BrokenWindows = brokenWindows,
- BurstedTires = burstedTires,
- LeftHeadLightBroken = (byte)(veh.IsLeftHeadLightBroken ? 1 : 0),
- RightHeadLightBroken = (byte)(veh.IsRightHeadLightBroken ? 1 : 0)
- };
- }
-
- public static Dictionary GetPassengers(this Vehicle veh)
- {
- Dictionary ps=new Dictionary();
- var d = veh.Driver;
- if (d!=null&&d.IsSittingInVehicle())
- {
- ps.Add(-1, d.GetSyncEntity().ID);
- }
- foreach(Ped p in veh.Passengers)
- {
- if (p.IsSittingInVehicle())
- {
- ps.Add((int)p.SeatIndex, (int)p.GetSyncEntity().ID);
- }
- }
- return ps;
- }
-
-
- public static void SetDeluxoHoverState(this Vehicle deluxo,bool hover)
- {
- Function.Call(Hash._SET_VEHICLE_HOVER_TRANSFORM_PERCENTAGE, deluxo, hover? 1f: 0f);
- }
- public static bool IsDeluxoHovering(this Vehicle deluxo)
- {
- return Math.Abs(deluxo.Bones[27].ForwardVector.GetCosTheta(deluxo.ForwardVector)-1)>0.05;
- }
-
- public static float GetNozzleAngel(this Vehicle plane)
- {
- return Function.Call(Hash._GET_VEHICLE_FLIGHT_NOZZLE_POSITION, plane);
- }
- public static bool HasNozzle(this Vehicle v)
- {
-
- switch (v.Model.Hash)
- {
- // Hydra
- case 970385471:
- return true;
-
- // Avenger
- case -2118308144:
- return true;
-
- // Avenger
- case 408970549:
- return true;
-
- }
- return false;
- }
- public static void SetNozzleAngel(this Vehicle plane,float ratio)
- {
- Function.Call(Hash.SET_VEHICLE_FLIGHT_NOZZLE_POSITION, plane, ratio);
- }
- public static void SetDamageModel(this Vehicle veh, VehicleDamageModel model, bool leavedoors = true)
- {
- for (int i = 0; i < 8; i++)
- {
- var door = veh.Doors[(VehicleDoorIndex)i];
- if ((model.BrokenDoors & (byte)(1 << i)) != 0)
- {
- door.Break(leavedoors);
- }
- else if (door.IsBroken)
- {
- // The vehicle can only fix a door if the vehicle was completely fixed
- veh.Repair();
- return;
- }
- if ((model.OpenedDoors & (byte)(1 << i)) != 0)
- {
- if ((!door.IsOpen)&&(!door.IsBroken))
- {
- door.Open();
- }
- }
- else if (door.IsOpen)
- {
- if (!door.IsBroken) { door.Close(); }
- }
-
- if ((model.BrokenWindows & (byte)(1 << i)) != 0)
- {
- veh.Windows[(VehicleWindowIndex)i].Smash();
- }
- else if (!veh.Windows[(VehicleWindowIndex)i].IsIntact)
- {
- veh.Windows[(VehicleWindowIndex)i].Repair();
- }
- }
-
- foreach (VehicleWheel wheel in veh.Wheels)
- {
- if ((model.BurstedTires & (short)(1 << (int)wheel.BoneId)) != 0)
- {
- if (!wheel.IsBursted)
- {
- wheel.Puncture();
- wheel.Burst();
- }
- }
- else if (wheel.IsBursted)
- {
- wheel.Fix();
- }
- }
-
- veh.IsLeftHeadLightBroken = model.LeftHeadLightBroken > 0;
- veh.IsRightHeadLightBroken = model.RightHeadLightBroken > 0;
- }
- public static Vector3 PredictPosition(this Entity e,bool applyDefault=true)
- {
- return e.Position+e.Velocity*((applyDefault?SyncParameters.PositioinPredictionDefault:0)+Networking.Latency);
- }
-
- #endregion
-
- public static void SetOnFire(this Entity e,bool toggle)
- {
- if (toggle)
- {
- Function.Call(Hash.START_ENTITY_FIRE, e.Handle);
- }
- else
- {
- Function.Call(Hash.STOP_ENTITY_FIRE, e.Handle);
- }
- }
-
- public static SyncedPed GetSyncEntity(this Ped p)
- {
- if(p == null) { return null; }
- var c = EntityPool.GetPedByHandle(p.Handle);
- if(c==null) { EntityPool.Add(c=new SyncedPed(p)); }
- return c;
- }
-
- public static SyncedVehicle GetSyncEntity(this Vehicle veh)
- {
- if(veh == null) { return null; }
- var v=EntityPool.GetVehicleByHandle(veh.Handle);
- if (v==null) { EntityPool.Add(v=new SyncedVehicle(veh)); }
- return v;
- }
-
-
-
-
-
-
- public static bool IsTurretSeat(this Vehicle veh, int seat)
- {
- if (!Function.Call(Hash.DOES_VEHICLE_HAVE_WEAPONS, veh.Handle))
- {
- return false;
- }
-
- switch (seat)
- {
- case -1:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Rhino
- || (VehicleHash)veh.Model.Hash == VehicleHash.Khanjari
- || (VehicleHash)veh.Model.Hash == VehicleHash.FireTruck
- || (VehicleHash)veh.Model.Hash == VehicleHash.Riot2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Cerberus
- || (VehicleHash)veh.Model.Hash == VehicleHash.Cerberus2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Cerberus3;
- case 0:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Apc;
- case 1:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Valkyrie
- || (VehicleHash)veh.Model.Hash == VehicleHash.Valkyrie2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Technical
- || (VehicleHash)veh.Model.Hash == VehicleHash.Technical2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Technical3
- || (VehicleHash)veh.Model.Hash == VehicleHash.HalfTrack
- || (VehicleHash)veh.Model.Hash == VehicleHash.Barrage;
- case 2:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Valkyrie
- || (VehicleHash)veh.Model.Hash == VehicleHash.Valkyrie2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Barrage;
- case 3:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Limo2
- || (VehicleHash)veh.Model.Hash == VehicleHash.Dinghy5;
- case 7:
- return (VehicleHash)veh.Model.Hash == VehicleHash.Insurgent;
- }
-
- return false;
- }
- public static bool IsOnTurretSeat(this Ped P)
- {
- if (P.CurrentVehicle == null) { return false; }
- return IsTurretSeat(P.CurrentVehicle, (int)P.SeatIndex);
- }
-
-
-
- [DllImport("kernel32.dll")]
- public static extern ulong GetTickCount64();
-
- }
- ///
- ///
- ///
- public static class MathExtensions
- {
- ///
- ///
- ///
- public static Vector3 ToVector(this Quaternion vec)
- {
- return new Vector3()
- {
- X = vec.X,
- Y = vec.Y,
- Z = vec.Z
- };
- }
-
- ///
- ///
- ///
- public static Quaternion ToQuaternion(this Vector3 vec, float vW = 0.0f)
- {
- return new Quaternion()
- {
- X = vec.X,
- Y = vec.Y,
- Z = vec.Z,
- W = vW
- };
- }
-
- public static float Denormalize(this float h)
- {
- return h < 0f ? h + 360f : h;
- }
-
- public static float ToRadians(this float val)
- {
- return (float)(Math.PI / 180) * val;
- }
-
- public static Vector3 ToRadians(this Vector3 i)
- {
- return new Vector3()
- {
- X = ToRadians(i.X),
- Y = ToRadians(i.Y),
- Z = ToRadians(i.Z),
- };
- }
-
- public static Quaternion ToQuaternion(this Vector3 vect)
- {
- vect = new Vector3()
- {
- X = vect.X.Denormalize() * -1,
- Y = vect.Y.Denormalize() - 180f,
- Z = vect.Z.Denormalize() - 180f,
- };
-
- vect = vect.ToRadians();
-
- float rollOver2 = vect.Z * 0.5f;
- float sinRollOver2 = (float)Math.Sin((double)rollOver2);
- float cosRollOver2 = (float)Math.Cos((double)rollOver2);
- float pitchOver2 = vect.Y * 0.5f;
- float sinPitchOver2 = (float)Math.Sin((double)pitchOver2);
- float cosPitchOver2 = (float)Math.Cos((double)pitchOver2);
- float yawOver2 = vect.X * 0.5f; // pitch
- float sinYawOver2 = (float)Math.Sin((double)yawOver2);
- float cosYawOver2 = (float)Math.Cos((double)yawOver2);
- Quaternion result = new Quaternion()
- {
- X = cosYawOver2 * cosPitchOver2 * cosRollOver2 + sinYawOver2 * sinPitchOver2 * sinRollOver2,
- Y = cosYawOver2 * cosPitchOver2 * sinRollOver2 - sinYawOver2 * sinPitchOver2 * cosRollOver2,
- Z = cosYawOver2 * sinPitchOver2 * cosRollOver2 + sinYawOver2 * cosPitchOver2 * sinRollOver2,
- W = sinYawOver2 * cosPitchOver2 * cosRollOver2 - cosYawOver2 * sinPitchOver2 * sinRollOver2
- };
- return result;
- }
- public static double DegToRad(double deg)
- {
- return deg * Math.PI / 180.0;
- }
- public static Vector3 ToEulerRotation(this Vector3 dir,Vector3 up)
- {
- var rot = Quaternion.LookRotation(dir.Normalized,up).ToEulerAngles().ToDegree();
- return rot;
-
- }
- public static Vector3 ToDegree(this Vector3 radian)
- {
- return radian*(float)(180/Math.PI);
- }
- public static Vector3 ToEulerAngles(this Quaternion q)
- {
- Vector3 angles = new Vector3();
-
- // roll / x
- double sinr_cosp = 2 * (q.W * q.X + q.Y * q.Z);
- double cosr_cosp = 1 - 2 * (q.X * q.X + q.Y * q.Y);
- angles.X = (float)Math.Atan2(sinr_cosp, cosr_cosp);
-
- // pitch / y
- double sinp = 2 * (q.W * q.Y - q.Z * q.X);
- if (Math.Abs(sinp) >= 1)
- {
- angles.Y = CopySign(Math.PI / 2, sinp);
- }
- else
- {
- angles.Y = (float)Math.Asin(sinp);
- }
-
- // yaw / z
- double siny_cosp = 2 * (q.W * q.Z + q.X * q.Y);
- double cosy_cosp = 1 - 2 * (q.Y * q.Y + q.Z * q.Z);
- angles.Z = (float)Math.Atan2(siny_cosp, cosy_cosp);
-
- return angles;
- }
- private static float CopySign(double x, double y)
- {
- bool isPositive = y>=0;
- if (isPositive)
- {
- if (x>=0) { return (float)x; } else { return (float)-x; }
- }
- else
- {
- if (x>=0) { return (float)-x; } else { return (float)x; }
-
- }
- }
- public static double AngelTo(this Vector3 v1, Vector3 v2)
- {
- return Math.Acos(v1.GetCosTheta(v2));
- }
- public static float GetCosTheta(this Vector3 v1, Vector3 v2)
- {
-
- return Vector3.Dot(v1, v2)/(v1.Length()*v2.Length());
- }
- }
-
-}
diff --git a/Client/Networking/Chat.cs b/Client/Networking/Chat.cs
index 3950c8d..10d66e6 100644
--- a/Client/Networking/Chat.cs
+++ b/Client/Networking/Chat.cs
@@ -8,7 +8,7 @@ using GTA.Native;
namespace RageCoop.Client
{
- public class Chat
+ internal class Chat
{
private readonly Scaleform MainScaleForm;
diff --git a/Client/Networking/DownloadManager.cs b/Client/Networking/DownloadManager.cs
index 2751a0b..34625ff 100644
--- a/Client/Networking/DownloadManager.cs
+++ b/Client/Networking/DownloadManager.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace RageCoop.Client
{
- public static class DownloadManager
+ internal static class DownloadManager
{
private static readonly List _downloadFiles = new List();
private static readonly Dictionary _streams = new Dictionary();
diff --git a/Client/Networking/Networking.cs b/Client/Networking/Networking.cs
index 57f8b9e..400ce9f 100644
--- a/Client/Networking/Networking.cs
+++ b/Client/Networking/Networking.cs
@@ -31,7 +31,7 @@ namespace RageCoop.Client
// 623c92c287cc392406e7aaaac1c0f3b0 = RAGECOOP
NetPeerConfiguration config = new NetPeerConfiguration("623c92c287cc392406e7aaaac1c0f3b0")
{
- AutoFlushSendQueue = true
+ AutoFlushSendQueue = false
};
config.EnableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated);
@@ -62,7 +62,6 @@ namespace RageCoop.Client
PedID = Main.LocalPlayerID,
Username = Main.Settings.Username,
ModVersion = Main.CurrentVersion,
- NPCsAllowed = false
}.Pack(outgoingMessage);
Client.Connect(ip[0], short.Parse(ip[1]), outgoingMessage);
@@ -80,6 +79,7 @@ namespace RageCoop.Client
{
try
{
+ Client.FlushSendQueue();
ReceiveMessages();
}
catch (Exception ex)
diff --git a/Client/Networking/Receive.cs b/Client/Networking/Receive.cs
index 6ce7f3a..bda3306 100644
--- a/Client/Networking/Receive.cs
+++ b/Client/Networking/Receive.cs
@@ -5,6 +5,7 @@ using System.Diagnostics;
using Lidgren.Network;
using RageCoop.Core;
using GTA;
+using RageCoop.Client.Menus;
using GTA.Math;
using GTA.Native;
@@ -36,7 +37,7 @@ namespace RageCoop.Client
{
case NetConnectionStatus.InitiatedConnect:
#if !NON_INTERACTIVE
- Main.MainMenu.InitiateConnectionMenuSetting();
+ CoopMenu.InitiateConnectionMenuSetting();
#endif
Main.QueueAction(() => { GTA.UI.Notification.Show("~y~Trying to connect..."); return true; });
break;
@@ -53,17 +54,13 @@ namespace RageCoop.Client
Packets.Handshake handshakePacket = new Packets.Handshake();
handshakePacket.Unpack(data);
- // Main.LocalNetHandle = handshakePacket.NetHandle;
- Main.NPCsAllowed = handshakePacket.NPCsAllowed;
-
-
#if !NON_INTERACTIVE
#endif
COOPAPI.Connected();
Main.QueueAction(() => {
- Main.MainMenu.ConnectedMenuSetting();
+ CoopMenu.ConnectedMenuSetting();
Main.MainChat.Init();
PlayerList.Cleanup();
GTA.UI.Notification.Show("~g~Connected!");
@@ -78,9 +75,7 @@ namespace RageCoop.Client
// Reset all values
Latency = 0;
- Main.QueueAction(() => { Main.CleanUpWorld();});
-
- Main.NPCsAllowed = false;
+ Main.QueueAction(() => Main.CleanUpWorld());
if (Main.MainChat.Focused)
{
@@ -90,7 +85,7 @@ namespace RageCoop.Client
Main.QueueAction(() => Main.CleanUp());
#if !NON_INTERACTIVE
- Main.MainMenu.DisconnectedMenuSetting();
+ CoopMenu.DisconnectedMenuSetting();
#endif
COOPAPI.Disconnected(reason);
@@ -227,8 +222,7 @@ namespace RageCoop.Client
{
Packets.Mod packet = new Packets.Mod();
packet.Unpack(data);
- COOPAPI.ModPacketReceived(packet.NetHandle, packet.Name, packet.CustomPacketID, packet.Bytes);
-
+ // Need to do some stuff here
}
break;
case PacketTypes.FileTransferTick:
@@ -370,6 +364,7 @@ namespace RageCoop.Client
v.BrakePower=packet.BrakePower;
v.Velocity=packet.Velocity;
v.RotationVelocity=packet.RotationVelocity;
+ v.DeluxoWingRatio=packet.DeluxoWingRatio;
v.LastSynced=Main.Ticked;
}
private static void VehicleStateSync(Packets.VehicleStateSync packet)
diff --git a/Client/Networking/Send.cs b/Client/Networking/Send.cs
index ec4f26e..5c0771a 100644
--- a/Client/Networking/Send.cs
+++ b/Client/Networking/Send.cs
@@ -83,6 +83,7 @@ namespace RageCoop.Client
ThrottlePower = veh.ThrottlePower,
BrakePower = veh.BrakePower,
};
+ if (v.MainVehicle.Model.Hash==1483171323) { packet.DeluxoWingRatio=v.MainVehicle.GetDeluxoWingRatio(); }
Send(packet,ConnectionChannel.VehicleSync);
}
public static void SendVehicleState(SyncedVehicle v)
@@ -149,27 +150,6 @@ namespace RageCoop.Client
Client.SendMessage(outgoingMessage, NetDeliveryMethod.ReliableOrdered, (byte)ConnectionChannel.Chat);
Client.FlushSendQueue();
-#if DEBUG
- if (ShowNetworkInfo)
- {
- BytesSend += outgoingMessage.LengthBytes;
- }
-#endif
- }
- public static void SendModData(long target, string modName, byte customID, byte[] bytes)
- {
- NetOutgoingMessage outgoingMessage = Client.CreateMessage();
- new Packets.Mod()
- {
- // NetHandle = Main.LocalNetHandle,
- Target = target,
- Name = modName,
- CustomPacketID = customID,
- Bytes = bytes
- }.Pack(outgoingMessage);
- Client.SendMessage(outgoingMessage, NetDeliveryMethod.ReliableOrdered, (byte)ConnectionChannel.Mod);
- Client.FlushSendQueue();
-
#if DEBUG
if (ShowNetworkInfo)
{
@@ -193,19 +173,6 @@ namespace RageCoop.Client
}
#endif
}
- public static void SendTriggerEvent(string eventName, params object[] args)
- {
- NetOutgoingMessage outgoingMessage = Client.CreateMessage();
-
- new Packets.ServerClientEvent()
- {
- EventName = eventName,
- Args = new List