#undef DEBUG
using Lidgren.Network;
using Newtonsoft.Json;
using RageCoop.Client.Menus;
using RageCoop.Core;
using RageCoop.Core.Scripting;
using System;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
[assembly: InternalsVisibleTo("CodeGen")] // For generating api bridge
namespace RageCoop.Client.Scripting
{
///
///
public class CustomEventReceivedArgs : EventArgs
{
///
/// The event hash
///
public int Hash { get; set; }
///
/// Supported types: byte, short, ushort, int, uint, long, ulong, float, bool, string, Vector3, Quaternion
///
public object[] Args { get; set; }
}
///
/// Provides vital functionality to interact with RAGECOOP
///
internal static unsafe partial class API
{
#region INTERNAL
internal static Dictionary>> CustomEventHandlers =
new Dictionary>>();
#endregion
///
/// Client configuration, this will conflict with server-side config.
///
public static class Config
{
///
/// Get or set local player's username, set won't be effective if already connected to a server.
///
public static string Username
{
get => Settings.Username;
set
{
if (Networking.IsOnServer || string.IsNullOrEmpty(value)) return;
Settings.Username = value;
}
}
///
/// Enable automatic respawn for this player.
///
public static bool EnableAutoRespawn { get; set; } = true;
///
/// Get or set player's blip color
///
public static BlipColor BlipColor { get; set; } = BlipColor.White;
///
/// Get or set player's blip sprite
///
public static BlipSprite BlipSprite { get; set; } = BlipSprite.Standard;
///
/// Get or set scale of player's blip
///
public static float BlipScale { get; set; } = 1;
public static bool ShowPlayerNameTag
{
get => Settings.ShowPlayerNameTag;
set
{
if (value == ShowPlayerNameTag) return;
Settings.ShowPlayerNameTag = value;
Util.SaveSettings();
}
}
}
///
/// Base events for RageCoop
///
public static class Events
{
///
/// The local player is dead
///
public static event EmptyEvent OnPlayerDied;
///
/// A local vehicle is spawned
///
public static event EventHandler OnVehicleSpawned;
///
/// A local vehicle is deleted
///
public static event EventHandler OnVehicleDeleted;
///
/// A local ped is spawned
///
public static event EventHandler OnPedSpawned;
///
/// A local ped is deleted
///
public static event EventHandler OnPedDeleted;
#region DELEGATES
///
///
public delegate void EmptyEvent();
///
///
///
///
public delegate void CustomEvent(int hash, List