reformat and cleanup code
This commit is contained in:
parent
164cf6b349
commit
db51bbbc4a
|
@ -1,18 +1,16 @@
|
|||
using System.Numerics;
|
||||
using CommunityServerAPI.BattleBitAPI.Server;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public struct OnPlayerKillArguments<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public struct OnPlayerKillArguments<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public TPlayer Killer;
|
||||
public Vector3 KillerPosition;
|
||||
public TPlayer Killer;
|
||||
public Vector3 KillerPosition;
|
||||
|
||||
public TPlayer Victim;
|
||||
public Vector3 VictimPosition;
|
||||
public TPlayer Victim;
|
||||
public Vector3 VictimPosition;
|
||||
|
||||
public string KillerTool;
|
||||
public PlayerBody BodyPart;
|
||||
public ReasonOfDamage SourceOfDamage;
|
||||
}
|
||||
}
|
||||
public string KillerTool;
|
||||
public PlayerBody BodyPart;
|
||||
public ReasonOfDamage SourceOfDamage;
|
||||
}
|
|
@ -1,50 +1,51 @@
|
|||
using System.Numerics;
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public struct OnPlayerSpawnArguments
|
||||
{
|
||||
public struct OnPlayerSpawnArguments
|
||||
{
|
||||
public PlayerSpawningPosition RequestedPoint;
|
||||
public PlayerLoadout Loadout;
|
||||
public PlayerWearings Wearings;
|
||||
public Vector3 SpawnPosition;
|
||||
public Vector3 LookDirection;
|
||||
public PlayerStand SpawnStand;
|
||||
public float SpawnProtection;
|
||||
public PlayerSpawningPosition RequestedPoint;
|
||||
public PlayerLoadout Loadout;
|
||||
public PlayerWearings Wearings;
|
||||
public Vector3 SpawnPosition;
|
||||
public Vector3 LookDirection;
|
||||
public PlayerStand SpawnStand;
|
||||
public float SpawnProtection;
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.Write((byte)RequestedPoint);
|
||||
Loadout.Write(ser);
|
||||
Wearings.Write(ser);
|
||||
ser.Write(SpawnPosition.X);
|
||||
ser.Write(SpawnPosition.Y);
|
||||
ser.Write(SpawnPosition.Z);
|
||||
ser.Write(LookDirection.X);
|
||||
ser.Write(LookDirection.Y);
|
||||
ser.Write(LookDirection.Z);
|
||||
ser.Write((byte)SpawnStand);
|
||||
ser.Write(SpawnProtection);
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
{
|
||||
RequestedPoint = (PlayerSpawningPosition)ser.ReadInt8();
|
||||
Loadout.Read(ser);
|
||||
Wearings.Read(ser);
|
||||
SpawnPosition = new Vector3()
|
||||
{
|
||||
X = ser.ReadFloat(),
|
||||
Y = ser.ReadFloat(),
|
||||
Z = ser.ReadFloat()
|
||||
};
|
||||
LookDirection = new Vector3()
|
||||
{
|
||||
X = ser.ReadFloat(),
|
||||
Y = ser.ReadFloat(),
|
||||
Z = ser.ReadFloat()
|
||||
};
|
||||
SpawnStand = (PlayerStand)ser.ReadInt8();
|
||||
SpawnProtection = ser.ReadFloat();
|
||||
}
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.Write((byte)RequestedPoint);
|
||||
Loadout.Write(ser);
|
||||
Wearings.Write(ser);
|
||||
ser.Write(SpawnPosition.X);
|
||||
ser.Write(SpawnPosition.Y);
|
||||
ser.Write(SpawnPosition.Z);
|
||||
ser.Write(LookDirection.X);
|
||||
ser.Write(LookDirection.Y);
|
||||
ser.Write(LookDirection.Z);
|
||||
ser.Write((byte)SpawnStand);
|
||||
ser.Write(SpawnProtection);
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
RequestedPoint = (PlayerSpawningPosition)ser.ReadInt8();
|
||||
Loadout.Read(ser);
|
||||
Wearings.Read(ser);
|
||||
SpawnPosition = new Vector3
|
||||
{
|
||||
X = ser.ReadFloat(),
|
||||
Y = ser.ReadFloat(),
|
||||
Z = ser.ReadFloat()
|
||||
};
|
||||
LookDirection = new Vector3
|
||||
{
|
||||
X = ser.ReadFloat(),
|
||||
Y = ser.ReadFloat(),
|
||||
Z = ser.ReadFloat()
|
||||
};
|
||||
SpawnStand = (PlayerStand)ser.ReadInt8();
|
||||
SpawnProtection = ser.ReadFloat();
|
||||
}
|
||||
}
|
|
@ -1,18 +1,17 @@
|
|||
using System;
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public class PlayerJoiningArguments
|
||||
{
|
||||
public class PlayerJoiningArguments
|
||||
{
|
||||
public PlayerStats Stats;
|
||||
public Team Team;
|
||||
public Squads Squad;
|
||||
public Squads Squad;
|
||||
public PlayerStats Stats;
|
||||
public Team Team;
|
||||
|
||||
public void Write(BattleBitAPI.Common.Serialization.Stream ser)
|
||||
{
|
||||
this.Stats.Write(ser);
|
||||
ser.Write((byte)this.Team);
|
||||
ser.Write((byte)this.Squad);
|
||||
}
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
Stats.Write(ser);
|
||||
ser.Write((byte)Team);
|
||||
ser.Write((byte)Squad);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +1,47 @@
|
|||
namespace CommunityServerAPI.BattleBitAPI
|
||||
namespace CommunityServerAPI.BattleBitAPI;
|
||||
|
||||
public static class Const
|
||||
{
|
||||
public static class Const
|
||||
{
|
||||
// ---- Networking ----
|
||||
/// <summary>
|
||||
/// Maximum data size for a single package. 4MB is default.
|
||||
/// </summary>
|
||||
public const int MaxNetworkPackageSize = 1024 * 1024 * 4;//4mb
|
||||
/// <summary>
|
||||
/// How long should server/client wait until connection is determined as timed out when no packages is being sent for long time.
|
||||
/// </summary>
|
||||
public const int NetworkTimeout = 60 * 1000;//60 seconds
|
||||
/// <summary>
|
||||
/// How frequently client/server will send keep alive to each other when no message is being sent to each other for a while.
|
||||
/// </summary>
|
||||
public const int NetworkKeepAlive = 5 * 1000;//15 seconds
|
||||
/// <summary>
|
||||
/// How long server/client will wait other side to send their hail/initial package. In miliseconds.
|
||||
/// </summary>
|
||||
// ---- Networking ----
|
||||
/// <summary>
|
||||
/// Maximum data size for a single package. 4MB is default.
|
||||
/// </summary>
|
||||
public const int MaxNetworkPackageSize = 1024 * 1024 * 4; //4mb
|
||||
|
||||
/// <summary>
|
||||
/// How long should server/client wait until connection is determined as timed out when no packages is being sent for
|
||||
/// long time.
|
||||
/// </summary>
|
||||
public const int NetworkTimeout = 60 * 1000; //60 seconds
|
||||
|
||||
/// <summary>
|
||||
/// How frequently client/server will send keep alive to each other when no message is being sent to each other for a
|
||||
/// while.
|
||||
/// </summary>
|
||||
public const int NetworkKeepAlive = 5 * 1000; //15 seconds
|
||||
|
||||
/// <summary>
|
||||
/// How long server/client will wait other side to send their hail/initial package. In miliseconds.
|
||||
/// </summary>
|
||||
#if DEBUG
|
||||
public const int HailConnectTimeout = 20 * 1000;
|
||||
public const int HailConnectTimeout = 20 * 1000;
|
||||
#else
|
||||
public const int HailConnectTimeout = 2 * 1000;
|
||||
public const int HailConnectTimeout = 2 * 1000;
|
||||
#endif
|
||||
|
||||
// ---- Server Fields ----
|
||||
public const int MinServerNameLength = 5;
|
||||
public const int MaxServerNameLength = 400;
|
||||
// ---- Server Fields ----
|
||||
public const int MinServerNameLength = 5;
|
||||
public const int MaxServerNameLength = 400;
|
||||
|
||||
public const int MinGamemodeNameLength = 2;
|
||||
public const int MaxGamemodeNameLength = 12;
|
||||
public const int MinGamemodeNameLength = 2;
|
||||
public const int MaxGamemodeNameLength = 12;
|
||||
|
||||
public const int MinMapNameLength = 2;
|
||||
public const int MaxMapNameLength = 36;
|
||||
public const int MinMapNameLength = 2;
|
||||
public const int MaxMapNameLength = 36;
|
||||
|
||||
public const int MinLoadingScreenTextLength = 0;
|
||||
public const int MaxLoadingScreenTextLength = 1024 * 8;
|
||||
public const int MinLoadingScreenTextLength = 0;
|
||||
public const int MaxLoadingScreenTextLength = 1024 * 8;
|
||||
|
||||
public const int MinServerRulesTextLength = 0;
|
||||
public const int MaxServerRulesTextLength = 1024 * 8;
|
||||
|
||||
}
|
||||
}
|
||||
public const int MinServerRulesTextLength = 0;
|
||||
public const int MaxServerRulesTextLength = 1024 * 8;
|
||||
}
|
|
@ -1,74 +1,76 @@
|
|||
using BattleBitAPI.Common;
|
||||
using System;
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
public class Attachment : IEquatable<string>, IEquatable<Attachment>
|
||||
{
|
||||
public class Attachment : IEquatable<string>, IEquatable<Attachment>
|
||||
public Attachment(string name, AttachmentType attachmentType)
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public AttachmentType AttachmentType { get; private set; }
|
||||
public Attachment(string name, AttachmentType attachmentType)
|
||||
{
|
||||
Name = name;
|
||||
AttachmentType = attachmentType;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other);
|
||||
}
|
||||
public bool Equals(Attachment other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Attachment right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(string left, Attachment right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator ==(Attachment right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(Attachment right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
Name = name;
|
||||
AttachmentType = attachmentType;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public AttachmentType AttachmentType { get; private set; }
|
||||
|
||||
public bool Equals(Attachment other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Attachment right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(string left, Attachment right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator ==(Attachment right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(Attachment right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
}
|
|
@ -1,69 +1,74 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public class Gadget : IEquatable<string>, IEquatable<Gadget>
|
||||
{
|
||||
public class Gadget : IEquatable<string>, IEquatable<Gadget>
|
||||
public Gadget(string name)
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public Gadget(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other);
|
||||
}
|
||||
public bool Equals(Gadget other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Gadget right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left,null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(string left, Gadget right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator ==(Gadget right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(Gadget right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public bool Equals(Gadget other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Gadget right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(string left, Gadget right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator ==(Gadget right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(Gadget right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
}
|
|
@ -1,76 +1,73 @@
|
|||
using System.Reflection;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public static class Gadgets
|
||||
{
|
||||
public static class Gadgets
|
||||
// ----- Private Variables -----
|
||||
private static readonly Dictionary<string, Gadget> mGadgets;
|
||||
|
||||
// ----- Public Variables -----
|
||||
public static readonly Gadget Bandage = new("Bandage");
|
||||
public static readonly Gadget Binoculars = new("Binoculars");
|
||||
public static readonly Gadget RangeFinder = new("Range Finder");
|
||||
public static readonly Gadget RepairTool = new("Repair Tool");
|
||||
public static readonly Gadget C4 = new("C4");
|
||||
public static readonly Gadget Claymore = new("Claymore");
|
||||
public static readonly Gadget M320SmokeGrenadeLauncher = new("M320 Smoke Grenade Launcher");
|
||||
public static readonly Gadget SmallAmmoKit = new("Small Ammo Kit");
|
||||
public static readonly Gadget AntiPersonnelMine = new("Anti Personnel Mine");
|
||||
public static readonly Gadget AntiVehicleMine = new("Anti Vehicle Mine");
|
||||
public static readonly Gadget MedicKit = new("Medic Kit");
|
||||
public static readonly Gadget Rpg7HeatExplosive = new("Rpg7 Heat Explosive");
|
||||
public static readonly Gadget RiotShield = new("Riot Shield");
|
||||
public static readonly Gadget FragGrenade = new("Frag Grenade");
|
||||
public static readonly Gadget ImpactGrenade = new("Impact Grenade");
|
||||
public static readonly Gadget AntiVehicleGrenade = new("Anti Vehicle Grenade");
|
||||
public static readonly Gadget SmokeGrenadeBlue = new("Smoke Grenade Blue");
|
||||
public static readonly Gadget SmokeGrenadeGreen = new("Smoke Grenade Green");
|
||||
public static readonly Gadget SmokeGrenadeRed = new("Smoke Grenade Red");
|
||||
public static readonly Gadget SmokeGrenadeWhite = new("Smoke Grenade White");
|
||||
public static readonly Gadget Flare = new("Flare");
|
||||
public static readonly Gadget SledgeHammer = new("Sledge Hammer");
|
||||
public static readonly Gadget AdvancedBinoculars = new("Advanced Binoculars");
|
||||
public static readonly Gadget Mdx201 = new("Mdx 201");
|
||||
public static readonly Gadget BinoSoflam = new("Bino Soflam");
|
||||
public static readonly Gadget HeavyAmmoKit = new("Heavy Ammo Kit");
|
||||
public static readonly Gadget Rpg7Pgo7Tandem = new("Rpg7 Pgo7 Tandem");
|
||||
public static readonly Gadget Rpg7Pgo7HeatExplosive = new("Rpg7 Pgo7 Heat Explosive");
|
||||
public static readonly Gadget Rpg7Pgo7Fragmentation = new("Rpg7 Pgo7 Fragmentation");
|
||||
public static readonly Gadget Rpg7Fragmentation = new("Rpg7 Fragmentation");
|
||||
public static readonly Gadget GrapplingHook = new("Grappling Hook");
|
||||
public static readonly Gadget AirDrone = new("Air Drone");
|
||||
public static readonly Gadget Flashbang = new("Flashbang");
|
||||
public static readonly Gadget Pickaxe = new("Pickaxe");
|
||||
public static readonly Gadget SuicideC4 = new("SuicideC4");
|
||||
public static readonly Gadget SledgeHammerSkinA = new("Sledge Hammer SkinA");
|
||||
public static readonly Gadget SledgeHammerSkinB = new("Sledge Hammer SkinB");
|
||||
public static readonly Gadget SledgeHammerSkinC = new("Sledge Hammer SkinC");
|
||||
public static readonly Gadget PickaxeIronPickaxe = new("Pickaxe IronPickaxe");
|
||||
|
||||
// ----- Init -----
|
||||
static Gadgets()
|
||||
{
|
||||
// ----- Private Variables -----
|
||||
private static Dictionary<string, Gadget> mGadgets;
|
||||
|
||||
// ----- Public Variables -----
|
||||
public static readonly Gadget Bandage = new Gadget("Bandage");
|
||||
public static readonly Gadget Binoculars = new Gadget("Binoculars");
|
||||
public static readonly Gadget RangeFinder = new Gadget("Range Finder");
|
||||
public static readonly Gadget RepairTool = new Gadget("Repair Tool");
|
||||
public static readonly Gadget C4 = new Gadget("C4");
|
||||
public static readonly Gadget Claymore = new Gadget("Claymore");
|
||||
public static readonly Gadget M320SmokeGrenadeLauncher = new Gadget("M320 Smoke Grenade Launcher");
|
||||
public static readonly Gadget SmallAmmoKit = new Gadget("Small Ammo Kit");
|
||||
public static readonly Gadget AntiPersonnelMine = new Gadget("Anti Personnel Mine");
|
||||
public static readonly Gadget AntiVehicleMine = new Gadget("Anti Vehicle Mine");
|
||||
public static readonly Gadget MedicKit = new Gadget("Medic Kit");
|
||||
public static readonly Gadget Rpg7HeatExplosive = new Gadget("Rpg7 Heat Explosive");
|
||||
public static readonly Gadget RiotShield = new Gadget("Riot Shield");
|
||||
public static readonly Gadget FragGrenade = new Gadget("Frag Grenade");
|
||||
public static readonly Gadget ImpactGrenade = new Gadget("Impact Grenade");
|
||||
public static readonly Gadget AntiVehicleGrenade = new Gadget("Anti Vehicle Grenade");
|
||||
public static readonly Gadget SmokeGrenadeBlue = new Gadget("Smoke Grenade Blue");
|
||||
public static readonly Gadget SmokeGrenadeGreen = new Gadget("Smoke Grenade Green");
|
||||
public static readonly Gadget SmokeGrenadeRed = new Gadget("Smoke Grenade Red");
|
||||
public static readonly Gadget SmokeGrenadeWhite = new Gadget("Smoke Grenade White");
|
||||
public static readonly Gadget Flare = new Gadget("Flare");
|
||||
public static readonly Gadget SledgeHammer = new Gadget("Sledge Hammer");
|
||||
public static readonly Gadget AdvancedBinoculars = new Gadget("Advanced Binoculars");
|
||||
public static readonly Gadget Mdx201 = new Gadget("Mdx 201");
|
||||
public static readonly Gadget BinoSoflam = new Gadget("Bino Soflam");
|
||||
public static readonly Gadget HeavyAmmoKit = new Gadget("Heavy Ammo Kit");
|
||||
public static readonly Gadget Rpg7Pgo7Tandem = new Gadget("Rpg7 Pgo7 Tandem");
|
||||
public static readonly Gadget Rpg7Pgo7HeatExplosive = new Gadget("Rpg7 Pgo7 Heat Explosive");
|
||||
public static readonly Gadget Rpg7Pgo7Fragmentation = new Gadget("Rpg7 Pgo7 Fragmentation");
|
||||
public static readonly Gadget Rpg7Fragmentation = new Gadget("Rpg7 Fragmentation");
|
||||
public static readonly Gadget GrapplingHook = new Gadget("Grappling Hook");
|
||||
public static readonly Gadget AirDrone = new Gadget("Air Drone");
|
||||
public static readonly Gadget Flashbang = new Gadget("Flashbang");
|
||||
public static readonly Gadget Pickaxe = new Gadget("Pickaxe");
|
||||
public static readonly Gadget SuicideC4 = new Gadget("SuicideC4");
|
||||
public static readonly Gadget SledgeHammerSkinA = new Gadget("Sledge Hammer SkinA");
|
||||
public static readonly Gadget SledgeHammerSkinB = new Gadget("Sledge Hammer SkinB");
|
||||
public static readonly Gadget SledgeHammerSkinC = new Gadget("Sledge Hammer SkinC");
|
||||
public static readonly Gadget PickaxeIronPickaxe = new Gadget("Pickaxe IronPickaxe");
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Gadget item)
|
||||
{
|
||||
return mGadgets.TryGetValue(name, out item);
|
||||
}
|
||||
|
||||
// ----- Init -----
|
||||
static Gadgets()
|
||||
{
|
||||
var members = typeof(Gadgets).GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
||||
mGadgets = new Dictionary<string, Gadget>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
var members = typeof(Gadgets).GetMembers(BindingFlags.Public | BindingFlags.Static);
|
||||
mGadgets = new Dictionary<string, Gadget>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
if (memberInfo.MemberType == MemberTypes.Field)
|
||||
{
|
||||
if (memberInfo.MemberType == System.Reflection.MemberTypes.Field)
|
||||
var field = (FieldInfo)memberInfo;
|
||||
if (field.FieldType == typeof(Gadget))
|
||||
{
|
||||
var field = ((FieldInfo)memberInfo);
|
||||
if (field.FieldType == typeof(Gadget))
|
||||
{
|
||||
var gad = (Gadget)field.GetValue(null);
|
||||
mGadgets.Add(gad.Name, gad);
|
||||
}
|
||||
var gad = (Gadget)field.GetValue(null);
|
||||
mGadgets.Add(gad.Name, gad);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Gadget item)
|
||||
{
|
||||
return mGadgets.TryGetValue(name, out item);
|
||||
}
|
||||
}
|
|
@ -1,69 +1,74 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public class Map : IEquatable<string>, IEquatable<Map>
|
||||
{
|
||||
public class Map : IEquatable<string>, IEquatable<Map>
|
||||
public Map(string name)
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public Map(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other);
|
||||
}
|
||||
public bool Equals(Map other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Map right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(string left, Map right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator ==(Map right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(Map right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public bool Equals(Map other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Map right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(string left, Map right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator ==(Map right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(Map right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
}
|
|
@ -1,348 +1,364 @@
|
|||
namespace BattleBitAPI.Common
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public struct PlayerLoadout
|
||||
{
|
||||
public struct PlayerLoadout
|
||||
public WeaponItem PrimaryWeapon;
|
||||
public WeaponItem SecondaryWeapon;
|
||||
public string FirstAidName;
|
||||
public string LightGadgetName;
|
||||
public string HeavyGadgetName;
|
||||
public string ThrowableName;
|
||||
|
||||
public byte PrimaryExtraMagazines;
|
||||
public byte SecondaryExtraMagazines;
|
||||
public byte FirstAidExtra;
|
||||
public byte LightGadgetExtra;
|
||||
public byte HeavyGadgetExtra;
|
||||
public byte ThrowableExtra;
|
||||
|
||||
public Gadget FirstAid
|
||||
{
|
||||
public WeaponItem PrimaryWeapon;
|
||||
public WeaponItem SecondaryWeapon;
|
||||
public string FirstAidName;
|
||||
public string LightGadgetName;
|
||||
public string HeavyGadgetName;
|
||||
public string ThrowableName;
|
||||
|
||||
public byte PrimaryExtraMagazines;
|
||||
public byte SecondaryExtraMagazines;
|
||||
public byte FirstAidExtra;
|
||||
public byte LightGadgetExtra;
|
||||
public byte HeavyGadgetExtra;
|
||||
public byte ThrowableExtra;
|
||||
|
||||
public Gadget FirstAid
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Gadgets.TryFind(FirstAidName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.FirstAidName = "none";
|
||||
else
|
||||
this.FirstAidName = value.Name;
|
||||
}
|
||||
if (Gadgets.TryFind(FirstAidName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
public Gadget LightGadget
|
||||
set
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Gadgets.TryFind(LightGadgetName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.LightGadgetName = "none";
|
||||
else
|
||||
this.LightGadgetName = value.Name;
|
||||
}
|
||||
}
|
||||
public Gadget HeavyGadget
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Gadgets.TryFind(HeavyGadgetName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.HeavyGadgetName = "none";
|
||||
else
|
||||
this.HeavyGadgetName = value.Name;
|
||||
}
|
||||
}
|
||||
public Gadget Throwable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Gadgets.TryFind(ThrowableName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.ThrowableName = "none";
|
||||
else
|
||||
this.ThrowableName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasGadget(Gadget gadget)
|
||||
{
|
||||
if (this.FirstAid == gadget)
|
||||
return true;
|
||||
if (this.LightGadget == gadget)
|
||||
return true;
|
||||
if (this.HeavyGadget == gadget)
|
||||
return true;
|
||||
if (this.Throwable == gadget)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
{
|
||||
this.PrimaryWeapon.Write(ser);
|
||||
this.SecondaryWeapon.Write(ser);
|
||||
ser.WriteStringItem(this.FirstAidName);
|
||||
ser.WriteStringItem(this.LightGadgetName);
|
||||
ser.WriteStringItem(this.HeavyGadgetName);
|
||||
ser.WriteStringItem(this.ThrowableName);
|
||||
|
||||
ser.Write(this.PrimaryExtraMagazines);
|
||||
ser.Write(this.SecondaryExtraMagazines);
|
||||
ser.Write(this.FirstAidExtra);
|
||||
ser.Write(this.LightGadgetExtra);
|
||||
ser.Write(this.HeavyGadgetExtra);
|
||||
ser.Write(this.ThrowableExtra);
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
{
|
||||
this.PrimaryWeapon.Read(ser);
|
||||
this.SecondaryWeapon.Read(ser);
|
||||
ser.TryReadString(out this.FirstAidName);
|
||||
ser.TryReadString(out this.LightGadgetName);
|
||||
ser.TryReadString(out this.HeavyGadgetName);
|
||||
ser.TryReadString(out this.ThrowableName);
|
||||
|
||||
this.PrimaryExtraMagazines = ser.ReadInt8();
|
||||
this.SecondaryExtraMagazines = ser.ReadInt8();
|
||||
this.FirstAidExtra = ser.ReadInt8();
|
||||
this.LightGadgetExtra = ser.ReadInt8();
|
||||
this.HeavyGadgetExtra = ser.ReadInt8();
|
||||
this.ThrowableExtra = ser.ReadInt8();
|
||||
if (value == null)
|
||||
FirstAidName = "none";
|
||||
else
|
||||
FirstAidName = value.Name;
|
||||
}
|
||||
}
|
||||
public struct WeaponItem
|
||||
|
||||
public Gadget LightGadget
|
||||
{
|
||||
public string ToolName;
|
||||
public string MainSightName;
|
||||
public string TopSightName;
|
||||
public string CantedSightName;
|
||||
public string BarrelName;
|
||||
public string SideRailName;
|
||||
public string UnderRailName;
|
||||
public string BoltActionName;
|
||||
public byte SkinIndex;
|
||||
public byte MagazineIndex;
|
||||
get
|
||||
{
|
||||
if (Gadgets.TryFind(LightGadgetName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
LightGadgetName = "none";
|
||||
else
|
||||
LightGadgetName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Weapon Tool
|
||||
public Gadget HeavyGadget
|
||||
{
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Weapons.TryFind(ToolName, out var weapon))
|
||||
return weapon;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.ToolName = "none";
|
||||
else
|
||||
this.ToolName = value.Name;
|
||||
}
|
||||
if (Gadgets.TryFind(HeavyGadgetName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
public Attachment MainSight
|
||||
set
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(MainSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.MainSightName = "none";
|
||||
else
|
||||
this.MainSightName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment TopSight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(TopSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.TopSightName = "none";
|
||||
else
|
||||
this.TopSightName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment CantedSight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(CantedSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.CantedSightName = "none";
|
||||
else
|
||||
this.CantedSightName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment Barrel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(BarrelName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.BarrelName = "none";
|
||||
else
|
||||
this.BarrelName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment SideRail
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(SideRailName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.SideRailName = "none";
|
||||
else
|
||||
this.SideRailName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment UnderRail
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(UnderRailName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.UnderRailName = "none";
|
||||
else
|
||||
this.UnderRailName = value.Name;
|
||||
}
|
||||
}
|
||||
public Attachment BoltAction
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(BoltActionName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
this.BoltActionName = "none";
|
||||
else
|
||||
this.BoltActionName = value.Name;
|
||||
}
|
||||
if (value == null)
|
||||
HeavyGadgetName = "none";
|
||||
else
|
||||
HeavyGadgetName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAttachment(Attachment attachment)
|
||||
public Gadget Throwable
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (attachment.AttachmentType)
|
||||
{
|
||||
case AttachmentType.MainSight:
|
||||
return this.MainSight == attachment;
|
||||
case AttachmentType.TopSight:
|
||||
return this.TopSight == attachment;
|
||||
case AttachmentType.CantedSight:
|
||||
return this.CantedSight == attachment;
|
||||
case AttachmentType.Barrel:
|
||||
return this.Barrel == attachment;
|
||||
case AttachmentType.UnderRail:
|
||||
return this.Barrel == attachment;
|
||||
case AttachmentType.SideRail:
|
||||
return this.SideRail == attachment;
|
||||
case AttachmentType.Bolt:
|
||||
return this.BoltAction == attachment;
|
||||
}
|
||||
return false;
|
||||
if (Gadgets.TryFind(ThrowableName, out var gadget))
|
||||
return gadget;
|
||||
return null;
|
||||
}
|
||||
public void SetAttachment(Attachment attachment)
|
||||
set
|
||||
{
|
||||
switch (attachment.AttachmentType)
|
||||
{
|
||||
case AttachmentType.MainSight:
|
||||
this.MainSight = attachment;
|
||||
break;
|
||||
case AttachmentType.TopSight:
|
||||
this.TopSight = attachment;
|
||||
break;
|
||||
case AttachmentType.CantedSight:
|
||||
this.CantedSight = attachment;
|
||||
break;
|
||||
case AttachmentType.Barrel:
|
||||
this.Barrel = attachment;
|
||||
break;
|
||||
case AttachmentType.UnderRail:
|
||||
this.Barrel = attachment;
|
||||
break;
|
||||
case AttachmentType.SideRail:
|
||||
this.SideRail = attachment;
|
||||
break;
|
||||
case AttachmentType.Bolt:
|
||||
this.BoltAction = attachment;
|
||||
break;
|
||||
}
|
||||
if (value == null)
|
||||
ThrowableName = "none";
|
||||
else
|
||||
ThrowableName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.WriteStringItem(this.ToolName);
|
||||
ser.WriteStringItem(this.MainSightName);
|
||||
ser.WriteStringItem(this.TopSightName);
|
||||
ser.WriteStringItem(this.CantedSightName);
|
||||
ser.WriteStringItem(this.BarrelName);
|
||||
ser.WriteStringItem(this.SideRailName);
|
||||
ser.WriteStringItem(this.UnderRailName);
|
||||
ser.WriteStringItem(this.BoltActionName);
|
||||
ser.Write(this.SkinIndex);
|
||||
ser.Write(this.MagazineIndex);
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.TryReadString(out this.ToolName);
|
||||
ser.TryReadString(out this.MainSightName);
|
||||
ser.TryReadString(out this.TopSightName);
|
||||
ser.TryReadString(out this.CantedSightName);
|
||||
ser.TryReadString(out this.BarrelName);
|
||||
ser.TryReadString(out this.SideRailName);
|
||||
ser.TryReadString(out this.UnderRailName);
|
||||
ser.TryReadString(out this.BoltActionName);
|
||||
this.SkinIndex = ser.ReadInt8();
|
||||
this.MagazineIndex = ser.ReadInt8();
|
||||
}
|
||||
public bool HasGadget(Gadget gadget)
|
||||
{
|
||||
if (FirstAid == gadget)
|
||||
return true;
|
||||
if (LightGadget == gadget)
|
||||
return true;
|
||||
if (HeavyGadget == gadget)
|
||||
return true;
|
||||
if (Throwable == gadget)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
PrimaryWeapon.Write(ser);
|
||||
SecondaryWeapon.Write(ser);
|
||||
ser.WriteStringItem(FirstAidName);
|
||||
ser.WriteStringItem(LightGadgetName);
|
||||
ser.WriteStringItem(HeavyGadgetName);
|
||||
ser.WriteStringItem(ThrowableName);
|
||||
|
||||
ser.Write(PrimaryExtraMagazines);
|
||||
ser.Write(SecondaryExtraMagazines);
|
||||
ser.Write(FirstAidExtra);
|
||||
ser.Write(LightGadgetExtra);
|
||||
ser.Write(HeavyGadgetExtra);
|
||||
ser.Write(ThrowableExtra);
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
PrimaryWeapon.Read(ser);
|
||||
SecondaryWeapon.Read(ser);
|
||||
ser.TryReadString(out FirstAidName);
|
||||
ser.TryReadString(out LightGadgetName);
|
||||
ser.TryReadString(out HeavyGadgetName);
|
||||
ser.TryReadString(out ThrowableName);
|
||||
|
||||
PrimaryExtraMagazines = ser.ReadInt8();
|
||||
SecondaryExtraMagazines = ser.ReadInt8();
|
||||
FirstAidExtra = ser.ReadInt8();
|
||||
LightGadgetExtra = ser.ReadInt8();
|
||||
HeavyGadgetExtra = ser.ReadInt8();
|
||||
ThrowableExtra = ser.ReadInt8();
|
||||
}
|
||||
}
|
||||
|
||||
public struct WeaponItem
|
||||
{
|
||||
public string ToolName;
|
||||
public string MainSightName;
|
||||
public string TopSightName;
|
||||
public string CantedSightName;
|
||||
public string BarrelName;
|
||||
public string SideRailName;
|
||||
public string UnderRailName;
|
||||
public string BoltActionName;
|
||||
public byte SkinIndex;
|
||||
public byte MagazineIndex;
|
||||
|
||||
public Weapon Tool
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Weapons.TryFind(ToolName, out var weapon))
|
||||
return weapon;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
ToolName = "none";
|
||||
else
|
||||
ToolName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment MainSight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(MainSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
MainSightName = "none";
|
||||
else
|
||||
MainSightName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment TopSight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(TopSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
TopSightName = "none";
|
||||
else
|
||||
TopSightName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment CantedSight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(CantedSightName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
CantedSightName = "none";
|
||||
else
|
||||
CantedSightName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment Barrel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(BarrelName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
BarrelName = "none";
|
||||
else
|
||||
BarrelName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment SideRail
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(SideRailName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
SideRailName = "none";
|
||||
else
|
||||
SideRailName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment UnderRail
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(UnderRailName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
UnderRailName = "none";
|
||||
else
|
||||
UnderRailName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public Attachment BoltAction
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Attachments.TryFind(BoltActionName, out var attachment))
|
||||
return attachment;
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
BoltActionName = "none";
|
||||
else
|
||||
BoltActionName = value.Name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAttachment(Attachment attachment)
|
||||
{
|
||||
switch (attachment.AttachmentType)
|
||||
{
|
||||
case AttachmentType.MainSight:
|
||||
return MainSight == attachment;
|
||||
case AttachmentType.TopSight:
|
||||
return TopSight == attachment;
|
||||
case AttachmentType.CantedSight:
|
||||
return CantedSight == attachment;
|
||||
case AttachmentType.Barrel:
|
||||
return Barrel == attachment;
|
||||
case AttachmentType.UnderRail:
|
||||
return Barrel == attachment;
|
||||
case AttachmentType.SideRail:
|
||||
return SideRail == attachment;
|
||||
case AttachmentType.Bolt:
|
||||
return BoltAction == attachment;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetAttachment(Attachment attachment)
|
||||
{
|
||||
switch (attachment.AttachmentType)
|
||||
{
|
||||
case AttachmentType.MainSight:
|
||||
MainSight = attachment;
|
||||
break;
|
||||
case AttachmentType.TopSight:
|
||||
TopSight = attachment;
|
||||
break;
|
||||
case AttachmentType.CantedSight:
|
||||
CantedSight = attachment;
|
||||
break;
|
||||
case AttachmentType.Barrel:
|
||||
Barrel = attachment;
|
||||
break;
|
||||
case AttachmentType.UnderRail:
|
||||
Barrel = attachment;
|
||||
break;
|
||||
case AttachmentType.SideRail:
|
||||
SideRail = attachment;
|
||||
break;
|
||||
case AttachmentType.Bolt:
|
||||
BoltAction = attachment;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.WriteStringItem(ToolName);
|
||||
ser.WriteStringItem(MainSightName);
|
||||
ser.WriteStringItem(TopSightName);
|
||||
ser.WriteStringItem(CantedSightName);
|
||||
ser.WriteStringItem(BarrelName);
|
||||
ser.WriteStringItem(SideRailName);
|
||||
ser.WriteStringItem(UnderRailName);
|
||||
ser.WriteStringItem(BoltActionName);
|
||||
ser.Write(SkinIndex);
|
||||
ser.Write(MagazineIndex);
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
ser.TryReadString(out ToolName);
|
||||
ser.TryReadString(out MainSightName);
|
||||
ser.TryReadString(out TopSightName);
|
||||
ser.TryReadString(out CantedSightName);
|
||||
ser.TryReadString(out BarrelName);
|
||||
ser.TryReadString(out SideRailName);
|
||||
ser.TryReadString(out UnderRailName);
|
||||
ser.TryReadString(out BoltActionName);
|
||||
SkinIndex = ser.ReadInt8();
|
||||
MagazineIndex = ser.ReadInt8();
|
||||
}
|
||||
}
|
|
@ -1,326 +1,342 @@
|
|||
namespace BattleBitAPI.Common
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public class PlayerStats
|
||||
{
|
||||
public class PlayerStats
|
||||
public byte[] Achievements;
|
||||
|
||||
public bool IsBanned;
|
||||
public PlayerProgess Progress = new();
|
||||
public Roles Roles;
|
||||
public byte[] Selections;
|
||||
public byte[] ToolProgress;
|
||||
|
||||
public PlayerStats()
|
||||
{
|
||||
public PlayerStats() { }
|
||||
public PlayerStats(byte[] data) { Load(data); }
|
||||
}
|
||||
|
||||
public bool IsBanned;
|
||||
public Roles Roles;
|
||||
public PlayerProgess Progress = new PlayerProgess();
|
||||
public byte[] ToolProgress;
|
||||
public byte[] Achievements;
|
||||
public byte[] Selections;
|
||||
public PlayerStats(byte[] data)
|
||||
{
|
||||
Load(data);
|
||||
}
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.Write(IsBanned);
|
||||
ser.Write((ulong)Roles);
|
||||
|
||||
Progress.Write(ser);
|
||||
|
||||
if (ToolProgress != null)
|
||||
{
|
||||
ser.Write(this.IsBanned);
|
||||
ser.Write((ulong)this.Roles);
|
||||
|
||||
Progress.Write(ser);
|
||||
|
||||
if (ToolProgress != null)
|
||||
{
|
||||
ser.Write((ushort)ToolProgress.Length);
|
||||
ser.Write(ToolProgress, 0, ToolProgress.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
|
||||
if (Achievements != null)
|
||||
{
|
||||
ser.Write((ushort)Achievements.Length);
|
||||
ser.Write(Achievements, 0, Achievements.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
|
||||
if (Selections != null)
|
||||
{
|
||||
ser.Write((ushort)Selections.Length);
|
||||
ser.Write(Selections, 0, Selections.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
ser.Write((ushort)ToolProgress.Length);
|
||||
ser.Write(ToolProgress, 0, ToolProgress.Length);
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
else
|
||||
{
|
||||
this.IsBanned = ser.ReadBool();
|
||||
this.Roles = (Roles)ser.ReadUInt64();
|
||||
|
||||
this.Progress.Read(ser);
|
||||
|
||||
int size = ser.ReadInt16();
|
||||
this.ToolProgress = ser.ReadByteArray(size);
|
||||
|
||||
size = ser.ReadInt16();
|
||||
this.Achievements = ser.ReadByteArray(size);
|
||||
|
||||
size = ser.ReadInt16();
|
||||
this.Selections = ser.ReadByteArray(size);
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
|
||||
public byte[] SerializeToByteArray()
|
||||
if (Achievements != null)
|
||||
{
|
||||
using (var ser = Common.Serialization.Stream.Get())
|
||||
{
|
||||
Write(ser);
|
||||
return ser.AsByteArrayData();
|
||||
}
|
||||
ser.Write((ushort)Achievements.Length);
|
||||
ser.Write(Achievements, 0, Achievements.Length);
|
||||
}
|
||||
public void Load(byte[] data)
|
||||
else
|
||||
{
|
||||
var ser = new Common.Serialization.Stream()
|
||||
{
|
||||
Buffer = data,
|
||||
InPool = false,
|
||||
ReadPosition = 0,
|
||||
WritePosition = data.Length,
|
||||
};
|
||||
Read(ser);
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
|
||||
public class PlayerProgess
|
||||
if (Selections != null)
|
||||
{
|
||||
private const uint ParamCount = 42;
|
||||
|
||||
public uint KillCount;
|
||||
public uint LeaderKills;
|
||||
public uint AssaultKills;
|
||||
public uint MedicKills;
|
||||
public uint EngineerKills;
|
||||
public uint SupportKills;
|
||||
public uint ReconKills;
|
||||
public uint DeathCount;
|
||||
public uint WinCount;
|
||||
public uint LoseCount;
|
||||
public uint FriendlyShots;
|
||||
public uint FriendlyKills;
|
||||
public uint Revived;
|
||||
public uint RevivedTeamMates;
|
||||
public uint Assists;
|
||||
public uint Prestige;
|
||||
public uint Rank;
|
||||
public uint EXP;
|
||||
public uint ShotsFired;
|
||||
public uint ShotsHit;
|
||||
public uint Headshots;
|
||||
public uint ObjectivesComplated;
|
||||
public uint HealedHPs;
|
||||
public uint RoadKills;
|
||||
public uint Suicides;
|
||||
public uint VehiclesDestroyed;
|
||||
public uint VehicleHPRepaired;
|
||||
public uint LongestKill;
|
||||
public uint PlayTimeSeconds;
|
||||
public uint LeaderPlayTime;
|
||||
public uint AssaultPlayTime;
|
||||
public uint MedicPlayTime;
|
||||
public uint EngineerPlayTime;
|
||||
public uint SupportPlayTime;
|
||||
public uint ReconPlayTime;
|
||||
public uint LeaderScore;
|
||||
public uint AssaultScore;
|
||||
public uint MedicScore;
|
||||
public uint EngineerScore;
|
||||
public uint SupportScore;
|
||||
public uint ReconScore;
|
||||
public uint TotalScore;
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.Write(ParamCount);
|
||||
{
|
||||
ser.Write(KillCount);
|
||||
ser.Write(LeaderKills);
|
||||
ser.Write(AssaultKills);
|
||||
ser.Write(MedicKills);
|
||||
ser.Write(EngineerKills);
|
||||
ser.Write(SupportKills);
|
||||
ser.Write(ReconKills);
|
||||
ser.Write(DeathCount);
|
||||
ser.Write(WinCount);
|
||||
ser.Write(LoseCount);
|
||||
ser.Write(FriendlyShots);
|
||||
ser.Write(FriendlyKills);
|
||||
ser.Write(Revived);
|
||||
ser.Write(RevivedTeamMates);
|
||||
ser.Write(Assists);
|
||||
ser.Write(Prestige);
|
||||
ser.Write(Rank);
|
||||
ser.Write(EXP);
|
||||
ser.Write(ShotsFired);
|
||||
ser.Write(ShotsHit);
|
||||
ser.Write(Headshots);
|
||||
ser.Write(ObjectivesComplated);
|
||||
ser.Write(HealedHPs);
|
||||
ser.Write(RoadKills);
|
||||
ser.Write(Suicides);
|
||||
ser.Write(VehiclesDestroyed);
|
||||
ser.Write(VehicleHPRepaired);
|
||||
ser.Write(LongestKill);
|
||||
ser.Write(PlayTimeSeconds);
|
||||
ser.Write(LeaderPlayTime);
|
||||
ser.Write(AssaultPlayTime);
|
||||
ser.Write(MedicPlayTime);
|
||||
ser.Write(EngineerPlayTime);
|
||||
ser.Write(SupportPlayTime);
|
||||
ser.Write(ReconPlayTime);
|
||||
ser.Write(LeaderScore);
|
||||
ser.Write(AssaultScore);
|
||||
ser.Write(MedicScore);
|
||||
ser.Write(EngineerScore);
|
||||
ser.Write(SupportScore);
|
||||
ser.Write(ReconScore);
|
||||
ser.Write(TotalScore);
|
||||
}
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
{
|
||||
Reset();
|
||||
|
||||
uint mParamCount = ser.ReadUInt32();
|
||||
int maxReadPosition = ser.ReadPosition + (int)(mParamCount * 4);
|
||||
{
|
||||
bool canRead() => ser.ReadPosition < maxReadPosition;
|
||||
if (canRead())
|
||||
this.KillCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.LeaderKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.AssaultKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.MedicKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.EngineerKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.SupportKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ReconKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.DeathCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.WinCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.LoseCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.FriendlyShots = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.FriendlyKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Revived = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.RevivedTeamMates = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Assists = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Prestige = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Rank = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.EXP = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ShotsFired = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ShotsHit = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Headshots = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ObjectivesComplated = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.HealedHPs = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.RoadKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.Suicides = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.VehiclesDestroyed = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.VehicleHPRepaired = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.LongestKill = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.PlayTimeSeconds = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.LeaderPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.AssaultPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.MedicPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.EngineerPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.SupportPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ReconPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.LeaderScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.AssaultScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.MedicScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.EngineerScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.SupportScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.ReconScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
this.TotalScore = ser.ReadUInt32();
|
||||
}
|
||||
ser.ReadPosition = maxReadPosition;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
KillCount = 0;
|
||||
LeaderKills = 0;
|
||||
AssaultKills = 0;
|
||||
MedicKills = 0;
|
||||
EngineerKills = 0;
|
||||
SupportKills = 0;
|
||||
ReconKills = 0;
|
||||
DeathCount = 0;
|
||||
WinCount = 0;
|
||||
LoseCount = 0;
|
||||
FriendlyShots = 0;
|
||||
FriendlyKills = 0;
|
||||
Revived = 0;
|
||||
RevivedTeamMates = 0;
|
||||
Assists = 0;
|
||||
Prestige = 0;
|
||||
Rank = 0;
|
||||
EXP = 0;
|
||||
ShotsFired = 0;
|
||||
ShotsHit = 0;
|
||||
Headshots = 0;
|
||||
ObjectivesComplated = 0;
|
||||
HealedHPs = 0;
|
||||
RoadKills = 0;
|
||||
Suicides = 0;
|
||||
VehiclesDestroyed = 0;
|
||||
VehicleHPRepaired = 0;
|
||||
LongestKill = 0;
|
||||
PlayTimeSeconds = 0;
|
||||
LeaderPlayTime = 0;
|
||||
AssaultPlayTime = 0;
|
||||
MedicPlayTime = 0;
|
||||
EngineerPlayTime = 0;
|
||||
SupportPlayTime = 0;
|
||||
ReconPlayTime = 0;
|
||||
LeaderScore = 0;
|
||||
AssaultScore = 0;
|
||||
MedicScore = 0;
|
||||
EngineerScore = 0;
|
||||
SupportScore = 0;
|
||||
ReconScore = 0;
|
||||
TotalScore = 0;
|
||||
}
|
||||
ser.Write((ushort)Selections.Length);
|
||||
ser.Write(Selections, 0, Selections.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ser.Write((ushort)0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
IsBanned = ser.ReadBool();
|
||||
Roles = (Roles)ser.ReadUInt64();
|
||||
|
||||
Progress.Read(ser);
|
||||
|
||||
int size = ser.ReadInt16();
|
||||
ToolProgress = ser.ReadByteArray(size);
|
||||
|
||||
size = ser.ReadInt16();
|
||||
Achievements = ser.ReadByteArray(size);
|
||||
|
||||
size = ser.ReadInt16();
|
||||
Selections = ser.ReadByteArray(size);
|
||||
}
|
||||
|
||||
public byte[] SerializeToByteArray()
|
||||
{
|
||||
using (var ser = Stream.Get())
|
||||
{
|
||||
Write(ser);
|
||||
return ser.AsByteArrayData();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(byte[] data)
|
||||
{
|
||||
var ser = new Stream
|
||||
{
|
||||
Buffer = data,
|
||||
InPool = false,
|
||||
ReadPosition = 0,
|
||||
WritePosition = data.Length
|
||||
};
|
||||
Read(ser);
|
||||
}
|
||||
|
||||
public class PlayerProgess
|
||||
{
|
||||
private const uint ParamCount = 42;
|
||||
public uint AssaultKills;
|
||||
public uint AssaultPlayTime;
|
||||
public uint AssaultScore;
|
||||
public uint Assists;
|
||||
public uint DeathCount;
|
||||
public uint EngineerKills;
|
||||
public uint EngineerPlayTime;
|
||||
public uint EngineerScore;
|
||||
public uint EXP;
|
||||
public uint FriendlyKills;
|
||||
public uint FriendlyShots;
|
||||
public uint Headshots;
|
||||
public uint HealedHPs;
|
||||
|
||||
public uint KillCount;
|
||||
public uint LeaderKills;
|
||||
public uint LeaderPlayTime;
|
||||
public uint LeaderScore;
|
||||
public uint LongestKill;
|
||||
public uint LoseCount;
|
||||
public uint MedicKills;
|
||||
public uint MedicPlayTime;
|
||||
public uint MedicScore;
|
||||
public uint ObjectivesComplated;
|
||||
public uint PlayTimeSeconds;
|
||||
public uint Prestige;
|
||||
public uint Rank;
|
||||
public uint ReconKills;
|
||||
public uint ReconPlayTime;
|
||||
public uint ReconScore;
|
||||
public uint Revived;
|
||||
public uint RevivedTeamMates;
|
||||
public uint RoadKills;
|
||||
public uint ShotsFired;
|
||||
public uint ShotsHit;
|
||||
public uint Suicides;
|
||||
public uint SupportKills;
|
||||
public uint SupportPlayTime;
|
||||
public uint SupportScore;
|
||||
public uint TotalScore;
|
||||
public uint VehicleHPRepaired;
|
||||
public uint VehiclesDestroyed;
|
||||
public uint WinCount;
|
||||
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.Write(ParamCount);
|
||||
{
|
||||
ser.Write(KillCount);
|
||||
ser.Write(LeaderKills);
|
||||
ser.Write(AssaultKills);
|
||||
ser.Write(MedicKills);
|
||||
ser.Write(EngineerKills);
|
||||
ser.Write(SupportKills);
|
||||
ser.Write(ReconKills);
|
||||
ser.Write(DeathCount);
|
||||
ser.Write(WinCount);
|
||||
ser.Write(LoseCount);
|
||||
ser.Write(FriendlyShots);
|
||||
ser.Write(FriendlyKills);
|
||||
ser.Write(Revived);
|
||||
ser.Write(RevivedTeamMates);
|
||||
ser.Write(Assists);
|
||||
ser.Write(Prestige);
|
||||
ser.Write(Rank);
|
||||
ser.Write(EXP);
|
||||
ser.Write(ShotsFired);
|
||||
ser.Write(ShotsHit);
|
||||
ser.Write(Headshots);
|
||||
ser.Write(ObjectivesComplated);
|
||||
ser.Write(HealedHPs);
|
||||
ser.Write(RoadKills);
|
||||
ser.Write(Suicides);
|
||||
ser.Write(VehiclesDestroyed);
|
||||
ser.Write(VehicleHPRepaired);
|
||||
ser.Write(LongestKill);
|
||||
ser.Write(PlayTimeSeconds);
|
||||
ser.Write(LeaderPlayTime);
|
||||
ser.Write(AssaultPlayTime);
|
||||
ser.Write(MedicPlayTime);
|
||||
ser.Write(EngineerPlayTime);
|
||||
ser.Write(SupportPlayTime);
|
||||
ser.Write(ReconPlayTime);
|
||||
ser.Write(LeaderScore);
|
||||
ser.Write(AssaultScore);
|
||||
ser.Write(MedicScore);
|
||||
ser.Write(EngineerScore);
|
||||
ser.Write(SupportScore);
|
||||
ser.Write(ReconScore);
|
||||
ser.Write(TotalScore);
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
Reset();
|
||||
|
||||
var mParamCount = ser.ReadUInt32();
|
||||
var maxReadPosition = ser.ReadPosition + (int)(mParamCount * 4);
|
||||
{
|
||||
bool canRead()
|
||||
{
|
||||
return ser.ReadPosition < maxReadPosition;
|
||||
}
|
||||
|
||||
if (canRead())
|
||||
KillCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
LeaderKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
AssaultKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
MedicKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
EngineerKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
SupportKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ReconKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
DeathCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
WinCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
LoseCount = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
FriendlyShots = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
FriendlyKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Revived = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
RevivedTeamMates = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Assists = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Prestige = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Rank = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
EXP = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ShotsFired = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ShotsHit = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Headshots = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ObjectivesComplated = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
HealedHPs = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
RoadKills = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
Suicides = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
VehiclesDestroyed = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
VehicleHPRepaired = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
LongestKill = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
PlayTimeSeconds = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
LeaderPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
AssaultPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
MedicPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
EngineerPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
SupportPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ReconPlayTime = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
LeaderScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
AssaultScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
MedicScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
EngineerScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
SupportScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
ReconScore = ser.ReadUInt32();
|
||||
if (canRead())
|
||||
TotalScore = ser.ReadUInt32();
|
||||
}
|
||||
ser.ReadPosition = maxReadPosition;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
KillCount = 0;
|
||||
LeaderKills = 0;
|
||||
AssaultKills = 0;
|
||||
MedicKills = 0;
|
||||
EngineerKills = 0;
|
||||
SupportKills = 0;
|
||||
ReconKills = 0;
|
||||
DeathCount = 0;
|
||||
WinCount = 0;
|
||||
LoseCount = 0;
|
||||
FriendlyShots = 0;
|
||||
FriendlyKills = 0;
|
||||
Revived = 0;
|
||||
RevivedTeamMates = 0;
|
||||
Assists = 0;
|
||||
Prestige = 0;
|
||||
Rank = 0;
|
||||
EXP = 0;
|
||||
ShotsFired = 0;
|
||||
ShotsHit = 0;
|
||||
Headshots = 0;
|
||||
ObjectivesComplated = 0;
|
||||
HealedHPs = 0;
|
||||
RoadKills = 0;
|
||||
Suicides = 0;
|
||||
VehiclesDestroyed = 0;
|
||||
VehicleHPRepaired = 0;
|
||||
LongestKill = 0;
|
||||
PlayTimeSeconds = 0;
|
||||
LeaderPlayTime = 0;
|
||||
AssaultPlayTime = 0;
|
||||
MedicPlayTime = 0;
|
||||
EngineerPlayTime = 0;
|
||||
SupportPlayTime = 0;
|
||||
ReconPlayTime = 0;
|
||||
LeaderScore = 0;
|
||||
AssaultScore = 0;
|
||||
MedicScore = 0;
|
||||
EngineerScore = 0;
|
||||
SupportScore = 0;
|
||||
ReconScore = 0;
|
||||
TotalScore = 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +1,45 @@
|
|||
namespace BattleBitAPI.Common
|
||||
{
|
||||
public struct PlayerWearings
|
||||
{
|
||||
public string Head;
|
||||
public string Chest;
|
||||
public string Belt;
|
||||
public string Backbag;
|
||||
public string Eye;
|
||||
public string Face;
|
||||
public string Hair;
|
||||
public string Skin;
|
||||
public string Uniform;
|
||||
public string Camo;
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
public void Write(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.WriteStringItem(this.Head);
|
||||
ser.WriteStringItem(this.Chest);
|
||||
ser.WriteStringItem(this.Belt);
|
||||
ser.WriteStringItem(this.Backbag);
|
||||
ser.WriteStringItem(this.Eye);
|
||||
ser.WriteStringItem(this.Face);
|
||||
ser.WriteStringItem(this.Hair);
|
||||
ser.WriteStringItem(this.Skin);
|
||||
ser.WriteStringItem(this.Uniform);
|
||||
ser.WriteStringItem(this.Camo);
|
||||
}
|
||||
public void Read(Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.TryReadString(out this.Head);
|
||||
ser.TryReadString(out this.Chest);
|
||||
ser.TryReadString(out this.Belt);
|
||||
ser.TryReadString(out this.Backbag);
|
||||
ser.TryReadString(out this.Eye);
|
||||
ser.TryReadString(out this.Face);
|
||||
ser.TryReadString(out this.Hair);
|
||||
ser.TryReadString(out this.Skin);
|
||||
ser.TryReadString(out this.Uniform);
|
||||
ser.TryReadString(out this.Camo);
|
||||
}
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public struct PlayerWearings
|
||||
{
|
||||
public string Head;
|
||||
public string Chest;
|
||||
public string Belt;
|
||||
public string Backbag;
|
||||
public string Eye;
|
||||
public string Face;
|
||||
public string Hair;
|
||||
public string Skin;
|
||||
public string Uniform;
|
||||
public string Camo;
|
||||
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.WriteStringItem(Head);
|
||||
ser.WriteStringItem(Chest);
|
||||
ser.WriteStringItem(Belt);
|
||||
ser.WriteStringItem(Backbag);
|
||||
ser.WriteStringItem(Eye);
|
||||
ser.WriteStringItem(Face);
|
||||
ser.WriteStringItem(Hair);
|
||||
ser.WriteStringItem(Skin);
|
||||
ser.WriteStringItem(Uniform);
|
||||
ser.WriteStringItem(Camo);
|
||||
}
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
ser.TryReadString(out Head);
|
||||
ser.TryReadString(out Chest);
|
||||
ser.TryReadString(out Belt);
|
||||
ser.TryReadString(out Backbag);
|
||||
ser.TryReadString(out Eye);
|
||||
ser.TryReadString(out Face);
|
||||
ser.TryReadString(out Hair);
|
||||
ser.TryReadString(out Skin);
|
||||
ser.TryReadString(out Uniform);
|
||||
ser.TryReadString(out Camo);
|
||||
}
|
||||
}
|
|
@ -1,73 +1,76 @@
|
|||
using System;
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
public class Weapon : IEquatable<string>, IEquatable<Weapon>
|
||||
{
|
||||
public class Weapon : IEquatable<string>, IEquatable<Weapon>
|
||||
public Weapon(string name, WeaponType weaponType)
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public WeaponType WeaponType { get; private set; }
|
||||
public Weapon(string name, WeaponType weaponType)
|
||||
{
|
||||
Name = name;
|
||||
WeaponType = weaponType;
|
||||
}
|
||||
Name = name;
|
||||
WeaponType = weaponType;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other);
|
||||
}
|
||||
public bool Equals(Weapon other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return this.Name.Equals(other.Name);
|
||||
}
|
||||
public string Name { get; }
|
||||
public WeaponType WeaponType { get; private set; }
|
||||
|
||||
public static bool operator ==(string left, Weapon right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(string left, Weapon right)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator ==(Weapon right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public static bool operator !=(Weapon right, string left)
|
||||
{
|
||||
bool leftNull = object.ReferenceEquals(left, null);
|
||||
bool rightNull = object.ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
public bool Equals(string other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other);
|
||||
}
|
||||
|
||||
public bool Equals(Weapon other)
|
||||
{
|
||||
if (other == null)
|
||||
return false;
|
||||
return Name.Equals(other.Name);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public static bool operator ==(string left, Weapon right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(string left, Weapon right)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator ==(Weapon right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
|
||||
public static bool operator !=(Weapon right, string left)
|
||||
{
|
||||
var leftNull = ReferenceEquals(left, null);
|
||||
var rightNull = ReferenceEquals(right, null);
|
||||
if (leftNull && rightNull)
|
||||
return true;
|
||||
if (leftNull || rightNull)
|
||||
return false;
|
||||
return right.Name.Equals(left);
|
||||
}
|
||||
}
|
|
@ -1,127 +1,124 @@
|
|||
using System.Reflection;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public static class Attachments
|
||||
{
|
||||
public static class Attachments
|
||||
// ----- Private Variables -----
|
||||
private static readonly Dictionary<string, Attachment> mAttachments;
|
||||
|
||||
// ----- Barrels -----
|
||||
public static readonly Attachment Basic = new("Basic", AttachmentType.Barrel);
|
||||
public static readonly Attachment Compensator = new("Compensator", AttachmentType.Barrel);
|
||||
public static readonly Attachment Heavy = new("Heavy", AttachmentType.Barrel);
|
||||
public static readonly Attachment LongBarrel = new("Long_Barrel", AttachmentType.Barrel);
|
||||
public static readonly Attachment MuzzleBreak = new("Muzzle_Break", AttachmentType.Barrel);
|
||||
public static readonly Attachment Ranger = new("Ranger", AttachmentType.Barrel);
|
||||
public static readonly Attachment SuppressorLong = new("Suppressor_Long", AttachmentType.Barrel);
|
||||
public static readonly Attachment SuppressorShort = new("Suppressor_Short", AttachmentType.Barrel);
|
||||
public static readonly Attachment Tactical = new("Tactical", AttachmentType.Barrel);
|
||||
public static readonly Attachment FlashHider = new("Flash_Hider", AttachmentType.Barrel);
|
||||
public static readonly Attachment Osprey9 = new("Osprey_9", AttachmentType.Barrel);
|
||||
public static readonly Attachment DGN308 = new("DGN-308", AttachmentType.Barrel);
|
||||
public static readonly Attachment VAMB762 = new("VAMB-762", AttachmentType.Barrel);
|
||||
public static readonly Attachment SDN6762 = new("SDN-6_762", AttachmentType.Barrel);
|
||||
public static readonly Attachment NT4556 = new("NT-4_556", AttachmentType.Barrel);
|
||||
|
||||
// ----- Canted Sights -----
|
||||
public static readonly Attachment Ironsight = new("Ironsight", AttachmentType.CantedSight);
|
||||
public static readonly Attachment CantedRedDot = new("Canted_Red_Dot", AttachmentType.CantedSight);
|
||||
public static readonly Attachment FYouCanted = new("FYou_Canted", AttachmentType.CantedSight);
|
||||
public static readonly Attachment HoloDot = new("Holo_Dot", AttachmentType.CantedSight);
|
||||
|
||||
// ----- Scope -----
|
||||
public static readonly Attachment _6xScope = new("6x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _8xScope = new("8x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _15xScope = new("15x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _20xScope = new("20x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment PTR40Hunter = new("PTR-40_Hunter", AttachmentType.MainSight);
|
||||
public static readonly Attachment _1P78 = new("1P78", AttachmentType.MainSight);
|
||||
public static readonly Attachment Acog = new("Acog", AttachmentType.MainSight);
|
||||
public static readonly Attachment M125 = new("M_125", AttachmentType.MainSight);
|
||||
public static readonly Attachment Prisma = new("Prisma", AttachmentType.MainSight);
|
||||
public static readonly Attachment Slip = new("Slip", AttachmentType.MainSight);
|
||||
public static readonly Attachment PistolDeltaSight = new("Pistol_Delta_Sight", AttachmentType.MainSight);
|
||||
public static readonly Attachment PistolRedDot = new("Pistol_Red_Dot", AttachmentType.MainSight);
|
||||
public static readonly Attachment AimComp = new("Aim_Comp", AttachmentType.MainSight);
|
||||
public static readonly Attachment Holographic = new("Holographic", AttachmentType.MainSight);
|
||||
public static readonly Attachment Kobra = new("Kobra", AttachmentType.MainSight);
|
||||
public static readonly Attachment OKP7 = new("OKP7", AttachmentType.MainSight);
|
||||
public static readonly Attachment PKAS = new("PK-AS", AttachmentType.MainSight);
|
||||
public static readonly Attachment RedDot = new("Red_Dot", AttachmentType.MainSight);
|
||||
public static readonly Attachment Reflex = new("Reflex", AttachmentType.MainSight);
|
||||
public static readonly Attachment Strikefire = new("Strikefire", AttachmentType.MainSight);
|
||||
public static readonly Attachment Razor = new("Razor", AttachmentType.MainSight);
|
||||
public static readonly Attachment Flir = new("Flir", AttachmentType.MainSight);
|
||||
public static readonly Attachment Echo = new("Echo", AttachmentType.MainSight);
|
||||
public static readonly Attachment TRI4X32 = new("TRI4X32", AttachmentType.MainSight);
|
||||
public static readonly Attachment FYouSight = new("FYou_Sight", AttachmentType.MainSight);
|
||||
public static readonly Attachment HoloPK120 = new("Holo_PK-120", AttachmentType.MainSight);
|
||||
public static readonly Attachment Pistol8xScope = new("Pistol_8x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment BurrisAR332 = new("BurrisAR332", AttachmentType.MainSight);
|
||||
public static readonly Attachment HS401G5 = new("HS401G5", AttachmentType.MainSight);
|
||||
|
||||
// ----- Top Scope -----
|
||||
public static readonly Attachment DeltaSightTop = new("Delta_Sight_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment RedDotTop = new("Red_Dot_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment CRedDotTop = new("C_Red_Dot_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment FYouTop = new("FYou_Top", AttachmentType.TopSight);
|
||||
|
||||
// ----- Under Rails -----
|
||||
public static readonly Attachment AngledGrip = new("Angled_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment Bipod = new("Bipod", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VerticalGrip = new("Vertical_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment StubbyGrip = new("Stubby_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment StabilGrip = new("Stabil_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VerticalSkeletonGrip = new("Vertical_Skeleton_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment FABDTFG = new("FAB-DTFG", AttachmentType.UnderRail);
|
||||
public static readonly Attachment MagpulAngled = new("Magpul_Angled", AttachmentType.UnderRail);
|
||||
public static readonly Attachment BCMGunFighter = new("BCM-Gun_Fighter", AttachmentType.UnderRail);
|
||||
public static readonly Attachment ShiftShortAngledGrip = new("Shift_Short_Angled_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment SE5Grip = new("SE-5_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment RK6Foregrip = new("RK-6_Foregrip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment HeraCQRFront = new("HeraCQR_Front", AttachmentType.UnderRail);
|
||||
public static readonly Attachment B25URK = new("B-25URK", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VTACUVGTacticalGrip = new("VTAC_UVG_TacticalGrip", AttachmentType.UnderRail);
|
||||
|
||||
// ----- Side Rails -----
|
||||
public static readonly Attachment Flashlight = new("Flashlight", AttachmentType.SideRail);
|
||||
public static readonly Attachment Rangefinder = new("Rangefinder", AttachmentType.SideRail);
|
||||
public static readonly Attachment Redlaser = new("Redlaser", AttachmentType.SideRail);
|
||||
public static readonly Attachment TacticalFlashlight = new("Tactical_Flashlight", AttachmentType.SideRail);
|
||||
public static readonly Attachment Greenlaser = new("Greenlaser", AttachmentType.SideRail);
|
||||
public static readonly Attachment Searchlight = new("Searchlight", AttachmentType.SideRail);
|
||||
|
||||
// ----- Bolts -----
|
||||
public static readonly Attachment BoltActionA = new("Bolt_Action_A", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionB = new("Bolt_Action_B", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionC = new("Bolt_Action_C", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionD = new("Bolt_Action_D", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionE = new("Bolt_Action_E", AttachmentType.Bolt);
|
||||
|
||||
// ----- Init -----
|
||||
static Attachments()
|
||||
{
|
||||
// ----- Private Variables -----
|
||||
private static Dictionary<string, Attachment> mAttachments;
|
||||
|
||||
// ----- Barrels -----
|
||||
public static readonly Attachment Basic = new Attachment("Basic", AttachmentType.Barrel);
|
||||
public static readonly Attachment Compensator = new Attachment("Compensator", AttachmentType.Barrel);
|
||||
public static readonly Attachment Heavy = new Attachment("Heavy", AttachmentType.Barrel);
|
||||
public static readonly Attachment LongBarrel = new Attachment("Long_Barrel", AttachmentType.Barrel);
|
||||
public static readonly Attachment MuzzleBreak = new Attachment("Muzzle_Break", AttachmentType.Barrel);
|
||||
public static readonly Attachment Ranger = new Attachment("Ranger", AttachmentType.Barrel);
|
||||
public static readonly Attachment SuppressorLong = new Attachment("Suppressor_Long", AttachmentType.Barrel);
|
||||
public static readonly Attachment SuppressorShort = new Attachment("Suppressor_Short", AttachmentType.Barrel);
|
||||
public static readonly Attachment Tactical = new Attachment("Tactical", AttachmentType.Barrel);
|
||||
public static readonly Attachment FlashHider = new Attachment("Flash_Hider", AttachmentType.Barrel);
|
||||
public static readonly Attachment Osprey9 = new Attachment("Osprey_9", AttachmentType.Barrel);
|
||||
public static readonly Attachment DGN308 = new Attachment("DGN-308", AttachmentType.Barrel);
|
||||
public static readonly Attachment VAMB762 = new Attachment("VAMB-762", AttachmentType.Barrel);
|
||||
public static readonly Attachment SDN6762 = new Attachment("SDN-6_762", AttachmentType.Barrel);
|
||||
public static readonly Attachment NT4556 = new Attachment("NT-4_556", AttachmentType.Barrel);
|
||||
|
||||
// ----- Canted Sights -----
|
||||
public static readonly Attachment Ironsight = new Attachment("Ironsight", AttachmentType.CantedSight);
|
||||
public static readonly Attachment CantedRedDot = new Attachment("Canted_Red_Dot", AttachmentType.CantedSight);
|
||||
public static readonly Attachment FYouCanted = new Attachment("FYou_Canted", AttachmentType.CantedSight);
|
||||
public static readonly Attachment HoloDot = new Attachment("Holo_Dot", AttachmentType.CantedSight);
|
||||
|
||||
// ----- Scope -----
|
||||
public static readonly Attachment _6xScope = new Attachment("6x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _8xScope = new Attachment("8x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _15xScope = new Attachment("15x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment _20xScope = new Attachment("20x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment PTR40Hunter = new Attachment("PTR-40_Hunter", AttachmentType.MainSight);
|
||||
public static readonly Attachment _1P78 = new Attachment("1P78", AttachmentType.MainSight);
|
||||
public static readonly Attachment Acog = new Attachment("Acog", AttachmentType.MainSight);
|
||||
public static readonly Attachment M125 = new Attachment("M_125", AttachmentType.MainSight);
|
||||
public static readonly Attachment Prisma = new Attachment("Prisma", AttachmentType.MainSight);
|
||||
public static readonly Attachment Slip = new Attachment("Slip", AttachmentType.MainSight);
|
||||
public static readonly Attachment PistolDeltaSight = new Attachment("Pistol_Delta_Sight", AttachmentType.MainSight);
|
||||
public static readonly Attachment PistolRedDot = new Attachment("Pistol_Red_Dot", AttachmentType.MainSight);
|
||||
public static readonly Attachment AimComp = new Attachment("Aim_Comp", AttachmentType.MainSight);
|
||||
public static readonly Attachment Holographic = new Attachment("Holographic", AttachmentType.MainSight);
|
||||
public static readonly Attachment Kobra = new Attachment("Kobra", AttachmentType.MainSight);
|
||||
public static readonly Attachment OKP7 = new Attachment("OKP7", AttachmentType.MainSight);
|
||||
public static readonly Attachment PKAS = new Attachment("PK-AS", AttachmentType.MainSight);
|
||||
public static readonly Attachment RedDot = new Attachment("Red_Dot", AttachmentType.MainSight);
|
||||
public static readonly Attachment Reflex = new Attachment("Reflex", AttachmentType.MainSight);
|
||||
public static readonly Attachment Strikefire = new Attachment("Strikefire", AttachmentType.MainSight);
|
||||
public static readonly Attachment Razor = new Attachment("Razor", AttachmentType.MainSight);
|
||||
public static readonly Attachment Flir = new Attachment("Flir", AttachmentType.MainSight);
|
||||
public static readonly Attachment Echo = new Attachment("Echo", AttachmentType.MainSight);
|
||||
public static readonly Attachment TRI4X32 = new Attachment("TRI4X32", AttachmentType.MainSight);
|
||||
public static readonly Attachment FYouSight = new Attachment("FYou_Sight", AttachmentType.MainSight);
|
||||
public static readonly Attachment HoloPK120 = new Attachment("Holo_PK-120", AttachmentType.MainSight);
|
||||
public static readonly Attachment Pistol8xScope = new Attachment("Pistol_8x_Scope", AttachmentType.MainSight);
|
||||
public static readonly Attachment BurrisAR332 = new Attachment("BurrisAR332", AttachmentType.MainSight);
|
||||
public static readonly Attachment HS401G5 = new Attachment("HS401G5", AttachmentType.MainSight);
|
||||
|
||||
// ----- Top Scope -----
|
||||
public static readonly Attachment DeltaSightTop = new Attachment("Delta_Sight_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment RedDotTop = new Attachment("Red_Dot_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment CRedDotTop = new Attachment("C_Red_Dot_Top", AttachmentType.TopSight);
|
||||
public static readonly Attachment FYouTop = new Attachment("FYou_Top", AttachmentType.TopSight);
|
||||
|
||||
// ----- Under Rails -----
|
||||
public static readonly Attachment AngledGrip = new Attachment("Angled_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment Bipod = new Attachment("Bipod", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VerticalGrip = new Attachment("Vertical_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment StubbyGrip = new Attachment("Stubby_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment StabilGrip = new Attachment("Stabil_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VerticalSkeletonGrip = new Attachment("Vertical_Skeleton_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment FABDTFG = new Attachment("FAB-DTFG", AttachmentType.UnderRail);
|
||||
public static readonly Attachment MagpulAngled = new Attachment("Magpul_Angled", AttachmentType.UnderRail);
|
||||
public static readonly Attachment BCMGunFighter = new Attachment("BCM-Gun_Fighter", AttachmentType.UnderRail);
|
||||
public static readonly Attachment ShiftShortAngledGrip = new Attachment("Shift_Short_Angled_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment SE5Grip = new Attachment("SE-5_Grip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment RK6Foregrip = new Attachment("RK-6_Foregrip", AttachmentType.UnderRail);
|
||||
public static readonly Attachment HeraCQRFront = new Attachment("HeraCQR_Front", AttachmentType.UnderRail);
|
||||
public static readonly Attachment B25URK = new Attachment("B-25URK", AttachmentType.UnderRail);
|
||||
public static readonly Attachment VTACUVGTacticalGrip = new Attachment("VTAC_UVG_TacticalGrip", AttachmentType.UnderRail);
|
||||
|
||||
// ----- Side Rails -----
|
||||
public static readonly Attachment Flashlight = new Attachment("Flashlight", AttachmentType.SideRail);
|
||||
public static readonly Attachment Rangefinder = new Attachment("Rangefinder", AttachmentType.SideRail);
|
||||
public static readonly Attachment Redlaser = new Attachment("Redlaser", AttachmentType.SideRail);
|
||||
public static readonly Attachment TacticalFlashlight = new Attachment("Tactical_Flashlight", AttachmentType.SideRail);
|
||||
public static readonly Attachment Greenlaser = new Attachment("Greenlaser", AttachmentType.SideRail);
|
||||
public static readonly Attachment Searchlight = new Attachment("Searchlight", AttachmentType.SideRail);
|
||||
|
||||
// ----- Bolts -----
|
||||
public static readonly Attachment BoltActionA = new Attachment("Bolt_Action_A", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionB = new Attachment("Bolt_Action_B", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionC = new Attachment("Bolt_Action_C", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionD = new Attachment("Bolt_Action_D", AttachmentType.Bolt);
|
||||
public static readonly Attachment BoltActionE = new Attachment("Bolt_Action_E", AttachmentType.Bolt);
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Attachment item)
|
||||
{
|
||||
return mAttachments.TryGetValue(name, out item);
|
||||
}
|
||||
|
||||
// ----- Init -----
|
||||
static Attachments()
|
||||
{
|
||||
var members = typeof(Attachments).GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
||||
mAttachments = new Dictionary<string, Attachment>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
var members = typeof(Attachments).GetMembers(BindingFlags.Public | BindingFlags.Static);
|
||||
mAttachments = new Dictionary<string, Attachment>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
if (memberInfo.MemberType == MemberTypes.Field)
|
||||
{
|
||||
if (memberInfo.MemberType == System.Reflection.MemberTypes.Field)
|
||||
var field = (FieldInfo)memberInfo;
|
||||
if (field.FieldType == typeof(Attachment))
|
||||
{
|
||||
var field = ((FieldInfo)memberInfo);
|
||||
if (field.FieldType == typeof(Attachment))
|
||||
{
|
||||
var att = (Attachment)field.GetValue(null);
|
||||
mAttachments.Add(att.Name, att);
|
||||
}
|
||||
var att = (Attachment)field.GetValue(null);
|
||||
mAttachments.Add(att.Name, att);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Attachment item)
|
||||
{
|
||||
return mAttachments.TryGetValue(name, out item);
|
||||
}
|
||||
}
|
|
@ -1,82 +1,78 @@
|
|||
using Microsoft.VisualBasic;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public static class Weapons
|
||||
{
|
||||
public static class Weapons
|
||||
// ----- Private Variables -----
|
||||
private static readonly Dictionary<string, Weapon> mWeapons;
|
||||
|
||||
// ----- Public Variables -----
|
||||
public static readonly Weapon ACR = new("ACR", WeaponType.Rifle);
|
||||
public static readonly Weapon AK15 = new("AK15", WeaponType.Rifle);
|
||||
public static readonly Weapon AK74 = new("AK74", WeaponType.Rifle);
|
||||
public static readonly Weapon G36C = new("G36C", WeaponType.Rifle);
|
||||
public static readonly Weapon HoneyBadger = new("Honey Badger", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public static readonly Weapon KrissVector = new("Kriss Vector", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon L86A1 = new("L86A1", WeaponType.LightSupportGun_LSG);
|
||||
public static readonly Weapon L96 = new("L96", WeaponType.SniperRifle);
|
||||
public static readonly Weapon M4A1 = new("M4A1", WeaponType.Rifle);
|
||||
public static readonly Weapon M9 = new("M9", WeaponType.Pistol);
|
||||
public static readonly Weapon M110 = new("M110", WeaponType.DMR);
|
||||
public static readonly Weapon M249 = new("M249", WeaponType.LightMachineGun_LMG);
|
||||
public static readonly Weapon MK14EBR = new("MK14 EBR", WeaponType.DMR);
|
||||
public static readonly Weapon MK20 = new("MK20", WeaponType.DMR);
|
||||
public static readonly Weapon MP7 = new("MP7", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon PP2000 = new("PP2000", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon SCARH = new("SCAR-H", WeaponType.Rifle);
|
||||
public static readonly Weapon SSG69 = new("SSG 69", WeaponType.SniperRifle);
|
||||
public static readonly Weapon SV98 = new("SV-98", WeaponType.SniperRifle);
|
||||
public static readonly Weapon UMP45 = new("UMP-45", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon Unica = new("Unica", WeaponType.HeavyPistol);
|
||||
public static readonly Weapon USP = new("USP", WeaponType.Pistol);
|
||||
public static readonly Weapon AsVal = new("As Val", WeaponType.Carbine);
|
||||
public static readonly Weapon AUGA3 = new("AUG A3", WeaponType.Rifle);
|
||||
public static readonly Weapon DesertEagle = new("Desert Eagle", WeaponType.HeavyPistol);
|
||||
public static readonly Weapon FAL = new("FAL", WeaponType.Rifle);
|
||||
public static readonly Weapon Glock18 = new("Glock 18", WeaponType.AutoPistol);
|
||||
public static readonly Weapon M200 = new("M200", WeaponType.SniperRifle);
|
||||
public static readonly Weapon MP443 = new("MP 443", WeaponType.Pistol);
|
||||
public static readonly Weapon FAMAS = new("FAMAS", WeaponType.Rifle);
|
||||
public static readonly Weapon MP5 = new("MP5", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon P90 = new("P90", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public static readonly Weapon MSR = new("MSR", WeaponType.SniperRifle);
|
||||
public static readonly Weapon PP19 = new("PP19", WeaponType.SubmachineGun_SMG);
|
||||
public static readonly Weapon SVD = new("SVD", WeaponType.DMR);
|
||||
public static readonly Weapon Rem700 = new("Rem700", WeaponType.SniperRifle);
|
||||
public static readonly Weapon SG550 = new("SG550", WeaponType.Rifle);
|
||||
public static readonly Weapon Groza = new("Groza", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public static readonly Weapon HK419 = new("HK419", WeaponType.Rifle);
|
||||
public static readonly Weapon ScorpionEVO = new("ScorpionEVO", WeaponType.Carbine);
|
||||
public static readonly Weapon Rsh12 = new("Rsh12", WeaponType.HeavyPistol);
|
||||
public static readonly Weapon MG36 = new("MG36", WeaponType.LightSupportGun_LSG);
|
||||
public static readonly Weapon AK5C = new("AK5C", WeaponType.Rifle);
|
||||
public static readonly Weapon Ultimax100 = new("Ultimax100", WeaponType.LightMachineGun_LMG);
|
||||
|
||||
// ----- Init -----
|
||||
static Weapons()
|
||||
{
|
||||
// ----- Private Variables -----
|
||||
private static Dictionary<string, Weapon> mWeapons;
|
||||
|
||||
// ----- Public Variables -----
|
||||
public readonly static Weapon ACR = new Weapon("ACR", WeaponType.Rifle);
|
||||
public readonly static Weapon AK15 = new Weapon("AK15", WeaponType.Rifle);
|
||||
public readonly static Weapon AK74 = new Weapon("AK74", WeaponType.Rifle);
|
||||
public readonly static Weapon G36C = new Weapon("G36C", WeaponType.Rifle);
|
||||
public readonly static Weapon HoneyBadger = new Weapon("Honey Badger", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public readonly static Weapon KrissVector = new Weapon("Kriss Vector", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon L86A1 = new Weapon("L86A1", WeaponType.LightSupportGun_LSG);
|
||||
public readonly static Weapon L96 = new Weapon("L96", WeaponType.SniperRifle);
|
||||
public readonly static Weapon M4A1 = new Weapon("M4A1", WeaponType.Rifle);
|
||||
public readonly static Weapon M9 = new Weapon("M9", WeaponType.Pistol);
|
||||
public readonly static Weapon M110 = new Weapon("M110", WeaponType.DMR);
|
||||
public readonly static Weapon M249 = new Weapon("M249", WeaponType.LightMachineGun_LMG);
|
||||
public readonly static Weapon MK14EBR = new Weapon("MK14 EBR", WeaponType.DMR);
|
||||
public readonly static Weapon MK20 = new Weapon("MK20", WeaponType.DMR);
|
||||
public readonly static Weapon MP7 = new Weapon("MP7", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon PP2000 = new Weapon("PP2000", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon SCARH = new Weapon("SCAR-H", WeaponType.Rifle);
|
||||
public readonly static Weapon SSG69 = new Weapon("SSG 69", WeaponType.SniperRifle);
|
||||
public readonly static Weapon SV98 = new Weapon("SV-98", WeaponType.SniperRifle);
|
||||
public readonly static Weapon UMP45 = new Weapon("UMP-45", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon Unica = new Weapon("Unica", WeaponType.HeavyPistol);
|
||||
public readonly static Weapon USP = new Weapon("USP", WeaponType.Pistol);
|
||||
public readonly static Weapon AsVal = new Weapon("As Val", WeaponType.Carbine);
|
||||
public readonly static Weapon AUGA3 = new Weapon("AUG A3", WeaponType.Rifle);
|
||||
public readonly static Weapon DesertEagle = new Weapon("Desert Eagle", WeaponType.HeavyPistol);
|
||||
public readonly static Weapon FAL = new Weapon("FAL", WeaponType.Rifle);
|
||||
public readonly static Weapon Glock18 = new Weapon("Glock 18", WeaponType.AutoPistol);
|
||||
public readonly static Weapon M200 = new Weapon("M200", WeaponType.SniperRifle);
|
||||
public readonly static Weapon MP443 = new Weapon("MP 443", WeaponType.Pistol);
|
||||
public readonly static Weapon FAMAS = new Weapon("FAMAS", WeaponType.Rifle);
|
||||
public readonly static Weapon MP5 = new Weapon("MP5", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon P90 = new Weapon("P90", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public readonly static Weapon MSR = new Weapon("MSR", WeaponType.SniperRifle);
|
||||
public readonly static Weapon PP19 = new Weapon("PP19", WeaponType.SubmachineGun_SMG);
|
||||
public readonly static Weapon SVD = new Weapon("SVD", WeaponType.DMR);
|
||||
public readonly static Weapon Rem700 = new Weapon("Rem700", WeaponType.SniperRifle);
|
||||
public readonly static Weapon SG550 = new Weapon("SG550", WeaponType.Rifle);
|
||||
public readonly static Weapon Groza = new Weapon("Groza", WeaponType.PersonalDefenseWeapon_PDW);
|
||||
public readonly static Weapon HK419 = new Weapon("HK419", WeaponType.Rifle);
|
||||
public readonly static Weapon ScorpionEVO = new Weapon("ScorpionEVO", WeaponType.Carbine);
|
||||
public readonly static Weapon Rsh12 = new Weapon("Rsh12", WeaponType.HeavyPistol);
|
||||
public readonly static Weapon MG36 = new Weapon("MG36", WeaponType.LightSupportGun_LSG);
|
||||
public readonly static Weapon AK5C = new Weapon("AK5C", WeaponType.Rifle);
|
||||
public readonly static Weapon Ultimax100 = new Weapon("Ultimax100", WeaponType.LightMachineGun_LMG);
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Weapon item)
|
||||
{
|
||||
return mWeapons.TryGetValue(name, out item);
|
||||
}
|
||||
|
||||
// ----- Init -----
|
||||
static Weapons()
|
||||
{
|
||||
var members = typeof(Weapons).GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
||||
mWeapons = new Dictionary<string, Weapon>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
var members = typeof(Weapons).GetMembers(BindingFlags.Public | BindingFlags.Static);
|
||||
mWeapons = new Dictionary<string, Weapon>(members.Length);
|
||||
foreach (var memberInfo in members)
|
||||
if (memberInfo.MemberType == MemberTypes.Field)
|
||||
{
|
||||
if (memberInfo.MemberType == System.Reflection.MemberTypes.Field)
|
||||
var field = (FieldInfo)memberInfo;
|
||||
if (field.FieldType == typeof(Weapon))
|
||||
{
|
||||
var field = ((FieldInfo)memberInfo);
|
||||
if (field.FieldType == typeof(Weapon))
|
||||
{
|
||||
var wep = (Weapon)field.GetValue(null);
|
||||
mWeapons.Add(wep.Name, wep);
|
||||
}
|
||||
var wep = (Weapon)field.GetValue(null);
|
||||
mWeapons.Add(wep.Name, wep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Public Calls -----
|
||||
public static bool TryFind(string name, out Weapon item)
|
||||
{
|
||||
return mWeapons.TryGetValue(name, out item);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum AttachmentType
|
||||
{
|
||||
public enum AttachmentType
|
||||
{
|
||||
MainSight,
|
||||
TopSight,
|
||||
CantedSight,
|
||||
Barrel,
|
||||
UnderRail,
|
||||
SideRail,
|
||||
Bolt,
|
||||
}
|
||||
}
|
||||
MainSight,
|
||||
TopSight,
|
||||
CantedSight,
|
||||
Barrel,
|
||||
UnderRail,
|
||||
SideRail,
|
||||
Bolt
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum ChatChannel
|
||||
{
|
||||
public enum ChatChannel
|
||||
{
|
||||
AllChat,
|
||||
TeamChat,
|
||||
SquadChat
|
||||
}
|
||||
}
|
||||
AllChat,
|
||||
TeamChat,
|
||||
SquadChat
|
||||
}
|
|
@ -1,27 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
namespace BattleBitAPI.Common
|
||||
public enum ReasonOfDamage : byte
|
||||
{
|
||||
public enum ReasonOfDamage : byte
|
||||
{
|
||||
Server = 0,
|
||||
Weapon = 1,
|
||||
Bleeding = 2,
|
||||
Fall = 3,
|
||||
HelicopterBlade = 4,
|
||||
VehicleExplosion = 5,
|
||||
Explosion = 6,
|
||||
vehicleRunOver = 7,
|
||||
BuildingCollapsing = 8,
|
||||
SledgeHammer = 9,
|
||||
TreeFall = 10,
|
||||
CountAsKill = 11,
|
||||
Suicide = 12,
|
||||
HelicopterCrash = 13,
|
||||
BarbedWire = 14,
|
||||
}
|
||||
}
|
||||
Server = 0,
|
||||
Weapon = 1,
|
||||
Bleeding = 2,
|
||||
Fall = 3,
|
||||
HelicopterBlade = 4,
|
||||
VehicleExplosion = 5,
|
||||
Explosion = 6,
|
||||
vehicleRunOver = 7,
|
||||
BuildingCollapsing = 8,
|
||||
SledgeHammer = 9,
|
||||
TreeFall = 10,
|
||||
CountAsKill = 11,
|
||||
Suicide = 12,
|
||||
HelicopterCrash = 13,
|
||||
BarbedWire = 14
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum GameRole
|
||||
{
|
||||
public enum GameRole
|
||||
{
|
||||
Assault = 0, Medic = 1, Support = 2, Engineer = 3, Recon = 4, Leader = 5
|
||||
}
|
||||
}
|
||||
Assault = 0,
|
||||
Medic = 1,
|
||||
Support = 2,
|
||||
Engineer = 3,
|
||||
Recon = 4,
|
||||
Leader = 5
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum GameState : byte
|
||||
{
|
||||
public enum GameState : byte
|
||||
{
|
||||
WaitingForPlayers = 0,
|
||||
CountingDown = 1,
|
||||
Playing = 2,
|
||||
EndingGame = 3
|
||||
}
|
||||
}
|
||||
WaitingForPlayers = 0,
|
||||
CountingDown = 1,
|
||||
Playing = 2,
|
||||
EndingGame = 3
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum LeaningSide
|
||||
{
|
||||
public enum LeaningSide
|
||||
{
|
||||
Left, None, Right
|
||||
}
|
||||
}
|
||||
Left,
|
||||
None,
|
||||
Right
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum LoadoutIndex : byte
|
||||
{
|
||||
public enum LoadoutIndex : byte
|
||||
{
|
||||
Primary = 0,
|
||||
Secondary = 1,
|
||||
FirstAid = 2,
|
||||
LightGadget = 3,
|
||||
HeavyGadget = 4,
|
||||
Throwable = 5,
|
||||
}
|
||||
}
|
||||
Primary = 0,
|
||||
Secondary = 1,
|
||||
FirstAid = 2,
|
||||
LightGadget = 3,
|
||||
HeavyGadget = 4,
|
||||
Throwable = 5
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum MapDayNight : byte
|
||||
{
|
||||
public enum MapDayNight : byte
|
||||
{
|
||||
Day = 0,
|
||||
Night = 1,
|
||||
}
|
||||
}
|
||||
Day = 0,
|
||||
Night = 1
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum MapSize : byte
|
||||
{
|
||||
public enum MapSize : byte
|
||||
{
|
||||
None = 0,
|
||||
_8v8=8,
|
||||
_16vs16 = 16,
|
||||
_32vs32 = 32,
|
||||
_64vs64 = 64,
|
||||
_127vs127 = 90,
|
||||
}
|
||||
}
|
||||
None = 0,
|
||||
_8v8 = 8,
|
||||
_16vs16 = 16,
|
||||
_32vs32 = 32,
|
||||
_64vs64 = 64,
|
||||
_127vs127 = 90
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
namespace BattleBitAPI.Common
|
||||
{
|
||||
public enum PlayerBody : byte
|
||||
{
|
||||
None = 0,
|
||||
Head = 2,
|
||||
Neck = 3,
|
||||
Shoulder = 4,
|
||||
Arm = 5,
|
||||
Leg = 6,
|
||||
Foot = 7,
|
||||
Chest = 10,
|
||||
}
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
}
|
||||
public enum PlayerBody : byte
|
||||
{
|
||||
None = 0,
|
||||
Head = 2,
|
||||
Neck = 3,
|
||||
Shoulder = 4,
|
||||
Arm = 5,
|
||||
Leg = 6,
|
||||
Foot = 7,
|
||||
Chest = 10
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum PlayerSpawningPosition : byte
|
||||
{
|
||||
public enum PlayerSpawningPosition : byte
|
||||
{
|
||||
SpawnAtPoint, SpawnAtRally, SpawnAtFriend, SpawnAtVehicle, Null
|
||||
}
|
||||
}
|
||||
SpawnAtPoint,
|
||||
SpawnAtRally,
|
||||
SpawnAtFriend,
|
||||
SpawnAtVehicle,
|
||||
Null
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum PlayerStand : byte
|
||||
{
|
||||
public enum PlayerStand : byte
|
||||
{
|
||||
Standing = 0, Crouching = 1, Proning = 2
|
||||
}
|
||||
}
|
||||
Standing = 0,
|
||||
Crouching = 1,
|
||||
Proning = 2
|
||||
}
|
|
@ -1,23 +1,22 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum ReportReason
|
||||
{
|
||||
public enum ReportReason
|
||||
{
|
||||
Cheating_WallHack = 0,
|
||||
Cheating_Aimbot = 1,
|
||||
Cheating_Speedhack = 2,
|
||||
Cheating_WallHack = 0,
|
||||
Cheating_Aimbot = 1,
|
||||
Cheating_Speedhack = 2,
|
||||
|
||||
Racism_Discrimination_Text = 3,
|
||||
Racism_Discrimination_Voice = 4,
|
||||
Racism_Discrimination_Text = 3,
|
||||
Racism_Discrimination_Voice = 4,
|
||||
|
||||
Spamming_Text = 5,
|
||||
Spamming_Voice = 6,
|
||||
Spamming_Text = 5,
|
||||
Spamming_Voice = 6,
|
||||
|
||||
Bad_Language_Text = 7,
|
||||
Bad_Language_Voice = 8,
|
||||
Bad_Language_Text = 7,
|
||||
Bad_Language_Voice = 8,
|
||||
|
||||
Griefing = 9,
|
||||
Exploiting = 10,
|
||||
OtherToxicBehaviour = 11,
|
||||
UserProfileNamePicture = 12,
|
||||
}
|
||||
}
|
||||
Griefing = 9,
|
||||
Exploiting = 10,
|
||||
OtherToxicBehaviour = 11,
|
||||
UserProfileNamePicture = 12
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
namespace BattleBitAPI.Common
|
||||
{
|
||||
public enum Roles : ulong
|
||||
{
|
||||
None = 0,
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
Admin = 1 << 0,
|
||||
Moderator = 1 << 1,
|
||||
Special = 1 << 2,
|
||||
Vip = 1 << 3,
|
||||
}
|
||||
}
|
||||
public enum Roles : ulong
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Admin = 1 << 0,
|
||||
Moderator = 1 << 1,
|
||||
Special = 1 << 2,
|
||||
Vip = 1 << 3
|
||||
}
|
|
@ -1,72 +1,71 @@
|
|||
namespace BattleBitAPI.Common
|
||||
{
|
||||
public enum Squads
|
||||
{
|
||||
NoSquad = 0,
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
Alpha = 1,
|
||||
Bravo = 2,
|
||||
Charlie = 3,
|
||||
Delta = 4,
|
||||
Echo = 5,
|
||||
Foxtrot = 6,
|
||||
Golf = 7,
|
||||
Hotel = 8,
|
||||
India = 9,
|
||||
Juliett = 10,
|
||||
Kilo = 11,
|
||||
Lima = 12,
|
||||
Mike = 13,
|
||||
November = 14,
|
||||
Oscar = 15,
|
||||
Papa = 16,
|
||||
Quebec = 17,
|
||||
Romeo = 18,
|
||||
Sierra = 19,
|
||||
Tango = 20,
|
||||
Uniform = 21,
|
||||
Whiskey = 22,
|
||||
Xray = 23,
|
||||
Yankee = 24,
|
||||
Zulu = 25,
|
||||
Ash = 26,
|
||||
Baker = 27,
|
||||
Cast = 28,
|
||||
Diver = 29,
|
||||
Eagle = 30,
|
||||
Fisher = 31,
|
||||
George = 32,
|
||||
Hanover = 33,
|
||||
Ice = 34,
|
||||
Jake = 35,
|
||||
King = 36,
|
||||
Lash = 37,
|
||||
Mule = 38,
|
||||
Neptune = 39,
|
||||
Ostend = 40,
|
||||
Page = 41,
|
||||
Quail = 42,
|
||||
Raft = 43,
|
||||
Scout = 44,
|
||||
Tare = 45,
|
||||
Unit = 46,
|
||||
William = 47,
|
||||
Xaintrie = 48,
|
||||
Yoke = 49,
|
||||
Zebra = 50,
|
||||
Ace = 51,
|
||||
Beer = 52,
|
||||
Cast2 = 53,
|
||||
Duff = 54,
|
||||
Edward = 55,
|
||||
Freddy = 56,
|
||||
Gustav = 57,
|
||||
Henry = 58,
|
||||
Ivar = 59,
|
||||
Jazz = 60,
|
||||
Key = 61,
|
||||
Lincoln = 62,
|
||||
Mary = 63,
|
||||
Nora = 64
|
||||
}
|
||||
}
|
||||
public enum Squads
|
||||
{
|
||||
NoSquad = 0,
|
||||
|
||||
Alpha = 1,
|
||||
Bravo = 2,
|
||||
Charlie = 3,
|
||||
Delta = 4,
|
||||
Echo = 5,
|
||||
Foxtrot = 6,
|
||||
Golf = 7,
|
||||
Hotel = 8,
|
||||
India = 9,
|
||||
Juliett = 10,
|
||||
Kilo = 11,
|
||||
Lima = 12,
|
||||
Mike = 13,
|
||||
November = 14,
|
||||
Oscar = 15,
|
||||
Papa = 16,
|
||||
Quebec = 17,
|
||||
Romeo = 18,
|
||||
Sierra = 19,
|
||||
Tango = 20,
|
||||
Uniform = 21,
|
||||
Whiskey = 22,
|
||||
Xray = 23,
|
||||
Yankee = 24,
|
||||
Zulu = 25,
|
||||
Ash = 26,
|
||||
Baker = 27,
|
||||
Cast = 28,
|
||||
Diver = 29,
|
||||
Eagle = 30,
|
||||
Fisher = 31,
|
||||
George = 32,
|
||||
Hanover = 33,
|
||||
Ice = 34,
|
||||
Jake = 35,
|
||||
King = 36,
|
||||
Lash = 37,
|
||||
Mule = 38,
|
||||
Neptune = 39,
|
||||
Ostend = 40,
|
||||
Page = 41,
|
||||
Quail = 42,
|
||||
Raft = 43,
|
||||
Scout = 44,
|
||||
Tare = 45,
|
||||
Unit = 46,
|
||||
William = 47,
|
||||
Xaintrie = 48,
|
||||
Yoke = 49,
|
||||
Zebra = 50,
|
||||
Ace = 51,
|
||||
Beer = 52,
|
||||
Cast2 = 53,
|
||||
Duff = 54,
|
||||
Edward = 55,
|
||||
Freddy = 56,
|
||||
Gustav = 57,
|
||||
Henry = 58,
|
||||
Ivar = 59,
|
||||
Jazz = 60,
|
||||
Key = 61,
|
||||
Lincoln = 62,
|
||||
Mary = 63,
|
||||
Nora = 64
|
||||
}
|
|
@ -1,9 +1,8 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum Team : byte
|
||||
{
|
||||
public enum Team : byte
|
||||
{
|
||||
TeamA = 0,
|
||||
TeamB = 1,
|
||||
None = 2
|
||||
}
|
||||
}
|
||||
TeamA = 0,
|
||||
TeamB = 1,
|
||||
None = 2
|
||||
}
|
|
@ -1,17 +1,16 @@
|
|||
namespace BattleBitAPI.Common
|
||||
namespace BattleBitAPI.Common;
|
||||
|
||||
public enum WeaponType
|
||||
{
|
||||
public enum WeaponType : int
|
||||
{
|
||||
Rifle,
|
||||
DMR,
|
||||
SniperRifle,
|
||||
LightSupportGun_LSG,
|
||||
LightMachineGun_LMG,
|
||||
SubmachineGun_SMG,
|
||||
Pistol,
|
||||
AutoPistol,
|
||||
HeavyPistol,
|
||||
Carbine,
|
||||
PersonalDefenseWeapon_PDW,
|
||||
}
|
||||
}
|
||||
Rifle,
|
||||
DMR,
|
||||
SniperRifle,
|
||||
LightSupportGun_LSG,
|
||||
LightMachineGun_LMG,
|
||||
SubmachineGun_SMG,
|
||||
Pistol,
|
||||
AutoPistol,
|
||||
HeavyPistol,
|
||||
Carbine,
|
||||
PersonalDefenseWeapon_PDW
|
||||
}
|
|
@ -1,39 +1,79 @@
|
|||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI.Common.Extentions
|
||||
namespace BattleBitAPI.Common.Extentions;
|
||||
|
||||
public static class Extentions
|
||||
{
|
||||
public static class Extentions
|
||||
public static long TickCount
|
||||
{
|
||||
public static long TickCount
|
||||
get
|
||||
{
|
||||
get
|
||||
{
|
||||
#if NETCOREAPP
|
||||
return System.Environment.TickCount64;
|
||||
return Environment.TickCount64;
|
||||
#else
|
||||
return (long)Environment.TickCount;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public unsafe static uint ToUInt(this IPAddress address)
|
||||
{
|
||||
}
|
||||
|
||||
public static uint ToUInt(this IPAddress address)
|
||||
{
|
||||
#if NETCOREAPP
|
||||
return BitConverter.ToUInt32(address.GetAddressBytes());
|
||||
return BitConverter.ToUInt32(address.GetAddressBytes());
|
||||
#else
|
||||
return BitConverter.ToUInt32(address.GetAddressBytes(), 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void SafeClose(this TcpClient client)
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
public static void SafeClose(this TcpClient client)
|
||||
try
|
||||
{
|
||||
try { client.Close(); } catch { }
|
||||
try { client.Dispose(); } catch { }
|
||||
client.Dispose();
|
||||
}
|
||||
public static async Task<int> Read(this NetworkStream networkStream, Serialization.Stream outputStream, int size, CancellationToken token = default)
|
||||
catch
|
||||
{
|
||||
int read = 0;
|
||||
int readUntil = outputStream.WritePosition + size;
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<int> Read(this NetworkStream networkStream, Stream outputStream, int size, CancellationToken token = default)
|
||||
{
|
||||
var read = 0;
|
||||
var readUntil = outputStream.WritePosition + size;
|
||||
|
||||
//Ensure we have space.
|
||||
outputStream.EnsureWriteBufferSize(size);
|
||||
|
||||
//Continue reading until we have the package.
|
||||
while (outputStream.WritePosition < readUntil)
|
||||
{
|
||||
var sizeToRead = readUntil - outputStream.WritePosition;
|
||||
var received = await networkStream.ReadAsync(outputStream.Buffer, outputStream.WritePosition, sizeToRead, token);
|
||||
if (received <= 0)
|
||||
throw new Exception("NetworkStream was closed.");
|
||||
|
||||
read += received;
|
||||
outputStream.WritePosition += received;
|
||||
}
|
||||
|
||||
return read;
|
||||
}
|
||||
|
||||
public static async Task<bool> TryRead(this NetworkStream networkStream, Stream outputStream, int size, CancellationToken token = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var readUntil = outputStream.WritePosition + size;
|
||||
|
||||
//Ensure we have space.
|
||||
outputStream.EnsureWriteBufferSize(size);
|
||||
|
@ -41,42 +81,18 @@ namespace BattleBitAPI.Common.Extentions
|
|||
//Continue reading until we have the package.
|
||||
while (outputStream.WritePosition < readUntil)
|
||||
{
|
||||
int sizeToRead = readUntil - outputStream.WritePosition;
|
||||
int received = await networkStream.ReadAsync(outputStream.Buffer, outputStream.WritePosition, sizeToRead, token);
|
||||
var sizeToRead = readUntil - outputStream.WritePosition;
|
||||
var received = await networkStream.ReadAsync(outputStream.Buffer, outputStream.WritePosition, sizeToRead, token);
|
||||
if (received <= 0)
|
||||
throw new Exception("NetworkStream was closed.");
|
||||
|
||||
read += received;
|
||||
outputStream.WritePosition += received;
|
||||
}
|
||||
|
||||
return read;
|
||||
return true;
|
||||
}
|
||||
public static async Task<bool> TryRead(this NetworkStream networkStream, Serialization.Stream outputStream, int size, CancellationToken token = default)
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
int readUntil = outputStream.WritePosition + size;
|
||||
|
||||
//Ensure we have space.
|
||||
outputStream.EnsureWriteBufferSize(size);
|
||||
|
||||
//Continue reading until we have the package.
|
||||
while (outputStream.WritePosition < readUntil)
|
||||
{
|
||||
int sizeToRead = readUntil - outputStream.WritePosition;
|
||||
int received = await networkStream.ReadAsync(outputStream.Buffer, outputStream.WritePosition, sizeToRead, token);
|
||||
if (received <= 0)
|
||||
throw new Exception("NetworkStream was closed.");
|
||||
outputStream.WritePosition += received;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
namespace BattleBitAPI.Common.Serialization
|
||||
namespace BattleBitAPI.Common.Serialization;
|
||||
|
||||
public interface IStreamSerializable
|
||||
{
|
||||
public interface IStreamSerializable
|
||||
{
|
||||
void Read(Stream ser);
|
||||
void Write(Stream ser);
|
||||
}
|
||||
}
|
||||
void Read(Stream ser);
|
||||
void Write(Stream ser);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,70 +1,79 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
namespace BattleBitAPI.Common.Threading;
|
||||
|
||||
namespace BattleBitAPI.Common.Threading
|
||||
public class ThreadSafe<T>
|
||||
{
|
||||
public class ThreadSafe<T>
|
||||
private readonly ReaderWriterLockSlim mLock;
|
||||
public T Value;
|
||||
|
||||
public ThreadSafe(T value)
|
||||
{
|
||||
private System.Threading.ReaderWriterLockSlim mLock;
|
||||
public T Value;
|
||||
Value = value;
|
||||
mLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
|
||||
}
|
||||
|
||||
public ThreadSafe(T value)
|
||||
public SafeWriteHandle GetWriteHandle()
|
||||
{
|
||||
return new SafeWriteHandle(mLock);
|
||||
}
|
||||
|
||||
public SafeReadHandle GetReadHandle()
|
||||
{
|
||||
return new SafeReadHandle(mLock);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swaps current value with new value and returns old one.
|
||||
/// </summary>
|
||||
/// <param name="newValue"></param>
|
||||
/// <returns>Old value</returns>
|
||||
public T SwapValue(T newValue)
|
||||
{
|
||||
using (new SafeWriteHandle(mLock))
|
||||
{
|
||||
this.Value = value;
|
||||
this.mLock = new System.Threading.ReaderWriterLockSlim(System.Threading.LockRecursionPolicy.SupportsRecursion);
|
||||
}
|
||||
|
||||
public SafeWriteHandle GetWriteHandle() => new SafeWriteHandle(this.mLock);
|
||||
public SafeReadHandle GetReadHandle() => new SafeReadHandle(this.mLock);
|
||||
|
||||
/// <summary>
|
||||
/// Swaps current value with new value and returns old one.
|
||||
/// </summary>
|
||||
/// <param name="newValue"></param>
|
||||
/// <returns>Old value</returns>
|
||||
public T SwapValue(T newValue)
|
||||
{
|
||||
using (new SafeWriteHandle(this.mLock))
|
||||
{
|
||||
var oldValue = this.Value;
|
||||
this.Value = newValue;
|
||||
return oldValue;
|
||||
}
|
||||
var oldValue = Value;
|
||||
Value = newValue;
|
||||
return oldValue;
|
||||
}
|
||||
}
|
||||
public class SafeWriteHandle : System.IDisposable
|
||||
{
|
||||
private System.Threading.ReaderWriterLockSlim mLock;
|
||||
private bool mDisposed;
|
||||
public SafeWriteHandle(System.Threading.ReaderWriterLockSlim mLock)
|
||||
{
|
||||
this.mLock = mLock;
|
||||
mLock.EnterWriteLock();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (mDisposed)
|
||||
return;
|
||||
mDisposed = true;
|
||||
mLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
public class SafeReadHandle : System.IDisposable
|
||||
{
|
||||
private System.Threading.ReaderWriterLockSlim mLock;
|
||||
private bool mDisposed;
|
||||
public SafeReadHandle(System.Threading.ReaderWriterLockSlim mLock)
|
||||
{
|
||||
this.mLock = mLock;
|
||||
mLock.EnterReadLock();
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (mDisposed)
|
||||
return;
|
||||
mDisposed = true;
|
||||
}
|
||||
|
||||
mLock.ExitReadLock();
|
||||
}
|
||||
public class SafeWriteHandle : IDisposable
|
||||
{
|
||||
private bool mDisposed;
|
||||
private readonly ReaderWriterLockSlim mLock;
|
||||
|
||||
public SafeWriteHandle(ReaderWriterLockSlim mLock)
|
||||
{
|
||||
this.mLock = mLock;
|
||||
mLock.EnterWriteLock();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (mDisposed)
|
||||
return;
|
||||
mDisposed = true;
|
||||
mLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
public class SafeReadHandle : IDisposable
|
||||
{
|
||||
private bool mDisposed;
|
||||
private readonly ReaderWriterLockSlim mLock;
|
||||
|
||||
public SafeReadHandle(ReaderWriterLockSlim mLock)
|
||||
{
|
||||
this.mLock = mLock;
|
||||
mLock.EnterReadLock();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (mDisposed)
|
||||
return;
|
||||
mDisposed = true;
|
||||
|
||||
mLock.ExitReadLock();
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
namespace BattleBitAPI.Networking
|
||||
{
|
||||
public enum NetworkCommuncation : byte
|
||||
{
|
||||
None = 0,
|
||||
Hail = 1,
|
||||
Accepted = 2,
|
||||
Denied = 3,
|
||||
|
||||
ExecuteCommand = 10,
|
||||
SendPlayerStats = 11,
|
||||
SpawnPlayer = 12,
|
||||
SetNewRoomSettings = 13,
|
||||
RespondPlayerMessage = 14,
|
||||
SetNewRoundState = 15,
|
||||
SetPlayerWeapon = 16,
|
||||
SetPlayerGadget = 17,
|
||||
|
||||
PlayerConnected = 50,
|
||||
PlayerDisconnected = 51,
|
||||
OnPlayerTypedMessage = 52,
|
||||
OnAPlayerDownedAnotherPlayer = 53,
|
||||
OnPlayerJoining = 54,
|
||||
SavePlayerStats = 55,
|
||||
OnPlayerAskingToChangeRole = 56,
|
||||
OnPlayerChangedRole = 57,
|
||||
OnPlayerJoinedASquad = 58,
|
||||
OnPlayerLeftSquad = 59,
|
||||
OnPlayerChangedTeam = 60,
|
||||
OnPlayerRequestingToSpawn = 61,
|
||||
OnPlayerReport = 62,
|
||||
OnPlayerSpawn = 63,
|
||||
OnPlayerDie = 64,
|
||||
NotifyNewMapRotation = 65,
|
||||
NotifyNewGamemodeRotation = 66,
|
||||
NotifyNewRoundState = 67,
|
||||
OnPlayerAskingToChangeTeam = 68,
|
||||
GameTick = 69,
|
||||
OnPlayerGivenUp = 70,
|
||||
OnPlayerRevivedAnother = 71,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
namespace BattleBitAPI.Networking;
|
||||
|
||||
public enum NetworkCommunication : byte
|
||||
{
|
||||
None = 0,
|
||||
Hail = 1,
|
||||
Accepted = 2,
|
||||
Denied = 3,
|
||||
|
||||
ExecuteCommand = 10,
|
||||
SendPlayerStats = 11,
|
||||
SpawnPlayer = 12,
|
||||
SetNewRoomSettings = 13,
|
||||
RespondPlayerMessage = 14,
|
||||
SetNewRoundState = 15,
|
||||
SetPlayerWeapon = 16,
|
||||
SetPlayerGadget = 17,
|
||||
|
||||
PlayerConnected = 50,
|
||||
PlayerDisconnected = 51,
|
||||
OnPlayerTypedMessage = 52,
|
||||
OnAPlayerDownedAnotherPlayer = 53,
|
||||
OnPlayerJoining = 54,
|
||||
SavePlayerStats = 55,
|
||||
OnPlayerAskingToChangeRole = 56,
|
||||
OnPlayerChangedRole = 57,
|
||||
OnPlayerJoinedASquad = 58,
|
||||
OnPlayerLeftSquad = 59,
|
||||
OnPlayerChangedTeam = 60,
|
||||
OnPlayerRequestingToSpawn = 61,
|
||||
OnPlayerReport = 62,
|
||||
OnPlayerSpawn = 63,
|
||||
OnPlayerDie = 64,
|
||||
NotifyNewMapRotation = 65,
|
||||
NotifyNewGamemodeRotation = 66,
|
||||
NotifyNewRoundState = 67,
|
||||
OnPlayerAskingToChangeTeam = 68,
|
||||
GameTick = 69,
|
||||
OnPlayerGivenUp = 70,
|
||||
OnPlayerRevivedAnother = 71
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,66 +1,80 @@
|
|||
using BattleBitAPI.Common;
|
||||
using CommunityServerAPI.BattleBitAPI.Server;
|
||||
namespace BattleBitAPI.Server;
|
||||
|
||||
namespace BattleBitAPI.Server
|
||||
public class GamemodeRotation<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public class GamemodeRotation<TPlayer> where TPlayer : Player<TPlayer>
|
||||
private readonly GameServer<TPlayer>.Internal mResources;
|
||||
|
||||
public GamemodeRotation(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
private GameServer<TPlayer>.Internal mResources;
|
||||
public GamemodeRotation(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
mResources = resources;
|
||||
}
|
||||
mResources = resources;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetGamemodeRotation()
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
return new List<string>(mResources._GamemodeRotation);
|
||||
}
|
||||
public bool InRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
return mResources._GamemodeRotation.Contains(gamemode);
|
||||
}
|
||||
public bool RemoveFromRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
if (!mResources._GamemodeRotation.Remove(gamemode))
|
||||
return false;
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
return true;
|
||||
}
|
||||
public bool AddToRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
if (!mResources._GamemodeRotation.Add(gamemode))
|
||||
return false;
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
return true;
|
||||
}
|
||||
public void SetRotation(params string[] gamemodes)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
mResources._GamemodeRotation.Clear();
|
||||
foreach (var item in gamemodes)
|
||||
mResources._GamemodeRotation.Add(item);
|
||||
}
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
}
|
||||
public void ClearRotation()
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
if (mResources._GamemodeRotation.Count == 0)
|
||||
return;
|
||||
|
||||
mResources._GamemodeRotation.Clear();
|
||||
}
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
public IEnumerable<string> GetGamemodeRotation()
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
return new List<string>(mResources._GamemodeRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool InRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
return mResources._GamemodeRotation.Contains(gamemode);
|
||||
}
|
||||
}
|
||||
|
||||
public bool RemoveFromRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
if (!mResources._GamemodeRotation.Remove(gamemode))
|
||||
return false;
|
||||
}
|
||||
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddToRotation(string gamemode)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
if (!mResources._GamemodeRotation.Add(gamemode))
|
||||
return false;
|
||||
}
|
||||
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetRotation(params string[] gamemodes)
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
mResources._GamemodeRotation.Clear();
|
||||
foreach (var item in gamemodes)
|
||||
mResources._GamemodeRotation.Add(item);
|
||||
}
|
||||
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
}
|
||||
|
||||
public void ClearRotation()
|
||||
{
|
||||
lock (mResources._GamemodeRotation)
|
||||
{
|
||||
if (mResources._GamemodeRotation.Count == 0)
|
||||
return;
|
||||
|
||||
mResources._GamemodeRotation.Clear();
|
||||
}
|
||||
|
||||
mResources.IsDirtyGamemodeRotation = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,71 +1,86 @@
|
|||
using CommunityServerAPI.BattleBitAPI.Server;
|
||||
namespace BattleBitAPI.Server;
|
||||
|
||||
namespace BattleBitAPI.Server
|
||||
public class MapRotation<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public class MapRotation<TPlayer> where TPlayer : Player<TPlayer>
|
||||
private readonly GameServer<TPlayer>.Internal mResources;
|
||||
|
||||
public MapRotation(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
private GameServer<TPlayer>.Internal mResources;
|
||||
public MapRotation(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
mResources = resources;
|
||||
}
|
||||
mResources = resources;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetMapRotation()
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
return new List<string>(mResources._MapRotation);
|
||||
}
|
||||
public bool InRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
return mResources._MapRotation.Contains(map);
|
||||
}
|
||||
public bool RemoveFromRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
if (!mResources._MapRotation.Remove(map))
|
||||
return false;
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
return true;
|
||||
}
|
||||
public bool AddToRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
if (!mResources._MapRotation.Add(map))
|
||||
return false;
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
return true;
|
||||
}
|
||||
public void SetRotation(params string[] maps)
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
mResources._MapRotation.Clear();
|
||||
foreach (var item in maps)
|
||||
mResources._MapRotation.Add(item);
|
||||
}
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
}
|
||||
public void ClearRotation()
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
if (mResources._MapRotation.Count == 0)
|
||||
return;
|
||||
|
||||
mResources._MapRotation.Clear();
|
||||
}
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
public IEnumerable<string> GetMapRotation()
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
return new List<string>(mResources._MapRotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool InRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
return mResources._MapRotation.Contains(map);
|
||||
}
|
||||
}
|
||||
|
||||
public bool RemoveFromRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
if (!mResources._MapRotation.Remove(map))
|
||||
return false;
|
||||
}
|
||||
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AddToRotation(string map)
|
||||
{
|
||||
map = map.ToUpperInvariant();
|
||||
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
if (!mResources._MapRotation.Add(map))
|
||||
return false;
|
||||
}
|
||||
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetRotation(params string[] maps)
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
mResources._MapRotation.Clear();
|
||||
foreach (var item in maps)
|
||||
mResources._MapRotation.Add(item);
|
||||
}
|
||||
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
}
|
||||
|
||||
public void ClearRotation()
|
||||
{
|
||||
lock (mResources._MapRotation)
|
||||
{
|
||||
if (mResources._MapRotation.Count == 0)
|
||||
return;
|
||||
|
||||
mResources._MapRotation.Clear();
|
||||
}
|
||||
|
||||
mResources.IsDirtyMapRotation = true;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
namespace BattleBitAPI.Server
|
||||
{
|
||||
public class PlayerModifications<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
private Player<TPlayer>.Internal @internal;
|
||||
public PlayerModifications(Player<TPlayer>.Internal @internal)
|
||||
{
|
||||
this.@internal = @internal;
|
||||
}
|
||||
namespace BattleBitAPI.Server;
|
||||
|
||||
public float RunningSpeedMultiplier { get; set; }
|
||||
public float ReceiveDamageMultiplier { get; set; }
|
||||
public float GiveDamageMultiplier { get; set; }
|
||||
public float JumpHeightMultiplier { get; set; }
|
||||
public float FallDamageMultiplier { get; set; }
|
||||
public float ReloadSpeedMultiplier { get; set; }
|
||||
public bool CanUseNightVision { get; set; }
|
||||
public bool HasCollision { get; set; }
|
||||
public float DownTimeGiveUpTime { get; set; }
|
||||
public bool AirStrafe { get; set; }
|
||||
public bool CanSpawn { get; set; }
|
||||
public bool CanSpectate { get; set; }
|
||||
public bool IsTextChatMuted { get; set; }
|
||||
public bool IsVoiceChatMuted { get; set; }
|
||||
public float RespawnTime { get; set; }
|
||||
public bool CanRespawn { get; set; }
|
||||
public class PlayerModifications<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
private Player<TPlayer>.Internal @internal;
|
||||
|
||||
public PlayerModifications(Player<TPlayer>.Internal @internal)
|
||||
{
|
||||
this.@internal = @internal;
|
||||
}
|
||||
}
|
||||
|
||||
public float RunningSpeedMultiplier { get; set; }
|
||||
public float ReceiveDamageMultiplier { get; set; }
|
||||
public float GiveDamageMultiplier { get; set; }
|
||||
public float JumpHeightMultiplier { get; set; }
|
||||
public float FallDamageMultiplier { get; set; }
|
||||
public float ReloadSpeedMultiplier { get; set; }
|
||||
public bool CanUseNightVision { get; set; }
|
||||
public bool HasCollision { get; set; }
|
||||
public float DownTimeGiveUpTime { get; set; }
|
||||
public bool AirStrafe { get; set; }
|
||||
public bool CanSpawn { get; set; }
|
||||
public bool CanSpectate { get; set; }
|
||||
public bool IsTextChatMuted { get; set; }
|
||||
public bool IsVoiceChatMuted { get; set; }
|
||||
public float RespawnTime { get; set; }
|
||||
public bool CanRespawn { get; set; }
|
||||
}
|
|
@ -1,69 +1,69 @@
|
|||
using BattleBitAPI.Common;
|
||||
using CommunityServerAPI.BattleBitAPI.Server;
|
||||
|
||||
namespace BattleBitAPI.Server
|
||||
namespace BattleBitAPI.Server;
|
||||
|
||||
public class RoundSettings<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public class RoundSettings<TPlayer> where TPlayer : Player<TPlayer>
|
||||
private readonly GameServer<TPlayer>.Internal mResources;
|
||||
|
||||
public RoundSettings(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
private GameServer<TPlayer>.Internal mResources;
|
||||
public RoundSettings(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
mResources = resources;
|
||||
}
|
||||
mResources = resources;
|
||||
}
|
||||
|
||||
public GameState State
|
||||
{
|
||||
get => this.mResources._RoundSettings.State;
|
||||
}
|
||||
public double TeamATickets
|
||||
{
|
||||
get => this.mResources._RoundSettings.TeamATickets;
|
||||
set
|
||||
{
|
||||
this.mResources._RoundSettings.TeamATickets = value;
|
||||
this.mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
public double TeamBTickets
|
||||
{
|
||||
get => this.mResources._RoundSettings.TeamBTickets;
|
||||
set
|
||||
{
|
||||
this.mResources._RoundSettings.TeamBTickets = value;
|
||||
this.mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
public double MaxTickets
|
||||
{
|
||||
get => this.mResources._RoundSettings.MaxTickets;
|
||||
set
|
||||
{
|
||||
this.mResources._RoundSettings.MaxTickets = value;
|
||||
this.mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
public int PlayersToStart
|
||||
{
|
||||
get => this.mResources._RoundSettings.PlayersToStart;
|
||||
set
|
||||
{
|
||||
this.mResources._RoundSettings.PlayersToStart = value;
|
||||
this.mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
public int SecondsLeft
|
||||
{
|
||||
get => this.mResources._RoundSettings.SecondsLeft;
|
||||
set
|
||||
{
|
||||
this.mResources._RoundSettings.SecondsLeft = value;
|
||||
this.mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
public GameState State => mResources._RoundSettings.State;
|
||||
|
||||
public void Reset()
|
||||
public double TeamATickets
|
||||
{
|
||||
get => mResources._RoundSettings.TeamATickets;
|
||||
set
|
||||
{
|
||||
|
||||
mResources._RoundSettings.TeamATickets = value;
|
||||
mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double TeamBTickets
|
||||
{
|
||||
get => mResources._RoundSettings.TeamBTickets;
|
||||
set
|
||||
{
|
||||
mResources._RoundSettings.TeamBTickets = value;
|
||||
mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public double MaxTickets
|
||||
{
|
||||
get => mResources._RoundSettings.MaxTickets;
|
||||
set
|
||||
{
|
||||
mResources._RoundSettings.MaxTickets = value;
|
||||
mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int PlayersToStart
|
||||
{
|
||||
get => mResources._RoundSettings.PlayersToStart;
|
||||
set
|
||||
{
|
||||
mResources._RoundSettings.PlayersToStart = value;
|
||||
mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int SecondsLeft
|
||||
{
|
||||
get => mResources._RoundSettings.SecondsLeft;
|
||||
set
|
||||
{
|
||||
mResources._RoundSettings.SecondsLeft = value;
|
||||
mResources.IsDirtyRoundSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,91 +1,95 @@
|
|||
using CommunityServerAPI.BattleBitAPI.Server;
|
||||
namespace BattleBitAPI.Server;
|
||||
|
||||
namespace BattleBitAPI.Server
|
||||
public class ServerSettings<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public class ServerSettings<TPlayer> where TPlayer : Player<TPlayer>
|
||||
private readonly GameServer<TPlayer>.Internal mResources;
|
||||
|
||||
public ServerSettings(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
private GameServer<TPlayer>.Internal mResources;
|
||||
public ServerSettings(GameServer<TPlayer>.Internal resources)
|
||||
{
|
||||
mResources = resources;
|
||||
}
|
||||
mResources = resources;
|
||||
}
|
||||
|
||||
public float DamageMultiplier
|
||||
public float DamageMultiplier
|
||||
{
|
||||
get => mResources._RoomSettings.DamageMultiplier;
|
||||
set
|
||||
{
|
||||
get => mResources._RoomSettings.DamageMultiplier;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.DamageMultiplier = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool BleedingEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.BleedingEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.BleedingEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool StamineEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.StaminaEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.StaminaEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool FriendlyFireEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.FriendlyFireEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.FriendlyFireEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool OnlyWinnerTeamCanVote
|
||||
{
|
||||
get => mResources._RoomSettings.OnlyWinnerTeamCanVote;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.OnlyWinnerTeamCanVote = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool HitMarkersEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.HitMarkersEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.HitMarkersEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool PointLogEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.PointLogEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.PointLogEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
public bool SpectatorEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.SpectatorEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.SpectatorEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
mResources._RoomSettings.DamageMultiplier = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool BleedingEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.BleedingEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.BleedingEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool StamineEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.StaminaEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.StaminaEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FriendlyFireEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.FriendlyFireEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.FriendlyFireEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool OnlyWinnerTeamCanVote
|
||||
{
|
||||
get => mResources._RoomSettings.OnlyWinnerTeamCanVote;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.OnlyWinnerTeamCanVote = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HitMarkersEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.HitMarkersEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.HitMarkersEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool PointLogEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.PointLogEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.PointLogEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SpectatorEnabled
|
||||
{
|
||||
get => mResources._RoomSettings.SpectatorEnabled;
|
||||
set
|
||||
{
|
||||
mResources._RoomSettings.SpectatorEnabled = value;
|
||||
mResources.IsDirtyRoomSettings = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,364 +1,395 @@
|
|||
using BattleBitAPI.Common;
|
||||
using BattleBitAPI.Server;
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Numerics;
|
||||
using BattleBitAPI.Common;
|
||||
using BattleBitAPI.Server;
|
||||
using Stream = BattleBitAPI.Common.Serialization.Stream;
|
||||
|
||||
namespace BattleBitAPI
|
||||
namespace BattleBitAPI;
|
||||
|
||||
public class Player<TPlayer> where TPlayer : Player<TPlayer>
|
||||
{
|
||||
public class Player<TPlayer> where TPlayer : Player<TPlayer>
|
||||
private Internal mInternal;
|
||||
|
||||
// ---- Variables ----
|
||||
public ulong SteamID => mInternal.SteamID;
|
||||
public string Name => mInternal.Name;
|
||||
public IPAddress IP => mInternal.IP;
|
||||
public GameServer<TPlayer> GameServer => mInternal.GameServer;
|
||||
|
||||
public GameRole Role
|
||||
{
|
||||
private Internal mInternal;
|
||||
|
||||
// ---- Variables ----
|
||||
public ulong SteamID => mInternal.SteamID;
|
||||
public string Name => mInternal.Name;
|
||||
public IPAddress IP => mInternal.IP;
|
||||
public GameServer<TPlayer> GameServer => mInternal.GameServer;
|
||||
public GameRole Role
|
||||
get => mInternal.Role;
|
||||
set
|
||||
{
|
||||
get => mInternal.Role;
|
||||
set
|
||||
{
|
||||
if (value == mInternal.Role)
|
||||
return;
|
||||
SetNewRole(value);
|
||||
}
|
||||
}
|
||||
public Team Team
|
||||
{
|
||||
get => mInternal.Team;
|
||||
set
|
||||
{
|
||||
if (mInternal.Team != value)
|
||||
ChangeTeam(value);
|
||||
}
|
||||
}
|
||||
public Squads Squad
|
||||
{
|
||||
get => mInternal.Squad;
|
||||
set
|
||||
{
|
||||
if (value == mInternal.Squad)
|
||||
return;
|
||||
if (value == Squads.NoSquad)
|
||||
KickFromSquad();
|
||||
else
|
||||
JoinSquad(value);
|
||||
}
|
||||
}
|
||||
public bool InSquad => mInternal.Squad != Squads.NoSquad;
|
||||
public int PingMs => mInternal.PingMs;
|
||||
|
||||
public float HP => mInternal.HP;
|
||||
public bool IsAlive => mInternal.HP >= 0f;
|
||||
public bool IsUp => mInternal.HP > 0f;
|
||||
public bool IsDown => mInternal.HP == 0f;
|
||||
public bool IsDead => mInternal.HP == -1f;
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get => mInternal.Position;
|
||||
set => Teleport(value);
|
||||
}
|
||||
public PlayerStand StandingState => mInternal.Standing;
|
||||
public LeaningSide LeaningState => mInternal.Leaning;
|
||||
public LoadoutIndex CurrentLoadoutIndex => mInternal.CurrentLoadoutIndex;
|
||||
public bool InVehicle => mInternal.InVehicle;
|
||||
public bool IsBleeding => mInternal.IsBleeding;
|
||||
public PlayerLoadout CurrentLoadout => mInternal.CurrentLoadout;
|
||||
public PlayerWearings CurrentWearings => mInternal.CurrentWearings;
|
||||
public PlayerModifications<TPlayer> Modifications => mInternal.Modifications;
|
||||
|
||||
// ---- Events ----
|
||||
public virtual void OnCreated()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual async Task OnConnected()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnSpawned()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnDowned()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnGivenUp()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnRevivedByAnotherPlayer()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnRevivedAnotherPlayer()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnDied()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnChangedTeam()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnChangedRole(GameRole newRole)
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnJoinedSquad(Squads newSquad)
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnLeftSquad(Squads oldSquad)
|
||||
{
|
||||
|
||||
}
|
||||
public virtual async Task OnDisconnected()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// ---- Functions ----
|
||||
public void Kick(string reason = "")
|
||||
{
|
||||
GameServer.Kick(this, reason);
|
||||
}
|
||||
public void Kill()
|
||||
{
|
||||
GameServer.Kill(this);
|
||||
}
|
||||
public void ChangeTeam()
|
||||
{
|
||||
GameServer.ChangeTeam(this);
|
||||
}
|
||||
public void ChangeTeam(Team team)
|
||||
{
|
||||
GameServer.ChangeTeam(this, team);
|
||||
}
|
||||
public void KickFromSquad()
|
||||
{
|
||||
GameServer.KickFromSquad(this);
|
||||
}
|
||||
public void JoinSquad(Squads targetSquad)
|
||||
{
|
||||
GameServer.JoinSquad(this, targetSquad);
|
||||
}
|
||||
public void DisbandTheSquad()
|
||||
{
|
||||
GameServer.DisbandPlayerCurrentSquad(this);
|
||||
}
|
||||
public void PromoteToSquadLeader()
|
||||
{
|
||||
GameServer.PromoteSquadLeader(this);
|
||||
}
|
||||
public void WarnPlayer(string msg)
|
||||
{
|
||||
GameServer.WarnPlayer(this, msg);
|
||||
}
|
||||
public void Message(string msg)
|
||||
{
|
||||
GameServer.MessageToPlayer(this, msg);
|
||||
}
|
||||
public void Message(string msg, float fadeoutTime)
|
||||
{
|
||||
GameServer.MessageToPlayer(this, msg, fadeoutTime);
|
||||
}
|
||||
public void SetNewRole(GameRole role)
|
||||
{
|
||||
GameServer.SetRoleTo(this, role);
|
||||
}
|
||||
public void Teleport(Vector3 target)
|
||||
{
|
||||
|
||||
}
|
||||
public void SpawnPlayer(PlayerLoadout loadout, PlayerWearings wearings, Vector3 position, Vector3 lookDirection, PlayerStand stand, float spawnProtection)
|
||||
{
|
||||
GameServer.SpawnPlayer(this, loadout, wearings, position, lookDirection, stand, spawnProtection);
|
||||
}
|
||||
public void SetHP(float newHP)
|
||||
{
|
||||
GameServer.SetHP(this, newHP);
|
||||
}
|
||||
public void GiveDamage(float damage)
|
||||
{
|
||||
GameServer.GiveDamage(this, damage);
|
||||
}
|
||||
public void Heal(float hp)
|
||||
{
|
||||
GameServer.Heal(this, hp);
|
||||
}
|
||||
public void SetRunningSpeedMultiplier(float value)
|
||||
{
|
||||
GameServer.SetRunningSpeedMultiplier(this, value);
|
||||
}
|
||||
public void SetReceiveDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetReceiveDamageMultiplier(this, value);
|
||||
}
|
||||
public void SetGiveDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetGiveDamageMultiplier(this, value);
|
||||
}
|
||||
public void SetJumpMultiplier(float value)
|
||||
{
|
||||
GameServer.SetJumpMultiplier(this, value);
|
||||
}
|
||||
public void SetFallDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetFallDamageMultiplier(this, value);
|
||||
}
|
||||
public void SetPrimaryWeapon(WeaponItem item, int extraMagazines, bool clear = false)
|
||||
{
|
||||
GameServer.SetPrimaryWeapon(this, item, extraMagazines, clear);
|
||||
}
|
||||
public void SetSecondaryWeapon(WeaponItem item, int extraMagazines, bool clear = false)
|
||||
{
|
||||
GameServer.SetSecondaryWeapon(this, item, extraMagazines, clear);
|
||||
}
|
||||
public void SetFirstAidGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetFirstAid(this, item, extra, clear);
|
||||
}
|
||||
public void SetLightGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetLightGadget(this, item, extra, clear);
|
||||
}
|
||||
public void SetHeavyGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetHeavyGadget(this, item, extra, clear);
|
||||
}
|
||||
public void SetThrowable(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetThrowable(this, item, extra, clear);
|
||||
}
|
||||
|
||||
// ---- Static ----
|
||||
public static TPlayer CreateInstance<TPlayer>(Player<TPlayer>.Internal @internal) where TPlayer : Player<TPlayer>
|
||||
{
|
||||
TPlayer player = (TPlayer)Activator.CreateInstance(typeof(TPlayer));
|
||||
player.mInternal = @internal;
|
||||
return player;
|
||||
}
|
||||
|
||||
// ---- Overrides ----
|
||||
public override string ToString()
|
||||
{
|
||||
return Name + " (" + SteamID + ")";
|
||||
}
|
||||
|
||||
// ---- Internal ----
|
||||
public class Internal
|
||||
{
|
||||
public ulong SteamID;
|
||||
public string Name;
|
||||
public IPAddress IP;
|
||||
public GameServer<TPlayer> GameServer;
|
||||
public GameRole Role;
|
||||
public Team Team;
|
||||
public Squads Squad;
|
||||
public int PingMs = 999;
|
||||
|
||||
public bool IsAlive;
|
||||
public float HP;
|
||||
public Vector3 Position;
|
||||
public PlayerStand Standing;
|
||||
public LeaningSide Leaning;
|
||||
public LoadoutIndex CurrentLoadoutIndex;
|
||||
public bool InVehicle;
|
||||
public bool IsBleeding;
|
||||
public PlayerLoadout CurrentLoadout;
|
||||
public PlayerWearings CurrentWearings;
|
||||
|
||||
public mPlayerModifications _Modifications;
|
||||
public PlayerModifications<TPlayer> Modifications;
|
||||
|
||||
public Internal()
|
||||
{
|
||||
this.Modifications = new PlayerModifications<TPlayer>(this);
|
||||
this._Modifications = new mPlayerModifications();
|
||||
}
|
||||
|
||||
public void OnDie()
|
||||
{
|
||||
IsAlive = false;
|
||||
HP = -1f;
|
||||
Position = default;
|
||||
Standing = PlayerStand.Standing;
|
||||
Leaning = LeaningSide.None;
|
||||
CurrentLoadoutIndex = LoadoutIndex.Primary;
|
||||
InVehicle = false;
|
||||
IsBleeding = false;
|
||||
CurrentLoadout = new PlayerLoadout();
|
||||
CurrentWearings = new PlayerWearings();
|
||||
}
|
||||
}
|
||||
public class mPlayerModifications
|
||||
{
|
||||
public float RunningSpeedMultiplier = 1f;
|
||||
public float ReceiveDamageMultiplier = 1f;
|
||||
public float GiveDamageMultiplier = 1f;
|
||||
public float JumpHeightMultiplier = 1f;
|
||||
public float FallDamageMultiplier = 1f;
|
||||
public float ReloadSpeedMultiplier = 1f;
|
||||
public bool CanUseNightVision = true;
|
||||
public bool HasCollision = false;
|
||||
public float DownTimeGiveUpTime = 60f;
|
||||
public bool AirStrafe = true;
|
||||
public bool CanSpawn = true;
|
||||
public bool CanSpectate = true;
|
||||
public bool IsTextChatMuted = false;
|
||||
public bool IsVoiceChatMuted = false;
|
||||
public float RespawnTime = 10f;
|
||||
public bool CanRespawn = true;
|
||||
|
||||
public bool IsDirtyFlag = false;
|
||||
public void Write(BattleBitAPI.Common.Serialization.Stream ser)
|
||||
{
|
||||
ser.Write(this.RunningSpeedMultiplier);
|
||||
ser.Write(this.ReceiveDamageMultiplier);
|
||||
ser.Write(this.GiveDamageMultiplier);
|
||||
ser.Write(this.JumpHeightMultiplier);
|
||||
ser.Write(this.FallDamageMultiplier);
|
||||
ser.Write(this.ReloadSpeedMultiplier);
|
||||
ser.Write(this.CanUseNightVision);
|
||||
ser.Write(this.HasCollision);
|
||||
ser.Write(this.DownTimeGiveUpTime);
|
||||
ser.Write(this.AirStrafe);
|
||||
ser.Write(this.CanSpawn);
|
||||
ser.Write(this.CanSpectate);
|
||||
ser.Write(this.IsTextChatMuted);
|
||||
ser.Write(this.IsVoiceChatMuted);
|
||||
ser.Write(this.RespawnTime);
|
||||
ser.Write(this.CanRespawn);
|
||||
}
|
||||
public void Read(BattleBitAPI.Common.Serialization.Stream ser)
|
||||
{
|
||||
this.RunningSpeedMultiplier = ser.ReadFloat();
|
||||
if (this.RunningSpeedMultiplier <= 0f)
|
||||
this.RunningSpeedMultiplier = 0.01f;
|
||||
|
||||
this.ReceiveDamageMultiplier = ser.ReadFloat();
|
||||
this.GiveDamageMultiplier = ser.ReadFloat();
|
||||
this.JumpHeightMultiplier = ser.ReadFloat();
|
||||
this.FallDamageMultiplier = ser.ReadFloat();
|
||||
this.ReloadSpeedMultiplier = ser.ReadFloat();
|
||||
this.CanUseNightVision = ser.ReadBool();
|
||||
this.HasCollision = ser.ReadBool();
|
||||
this.DownTimeGiveUpTime = ser.ReadFloat();
|
||||
this.AirStrafe = ser.ReadBool();
|
||||
this.CanSpawn = ser.ReadBool();
|
||||
this.CanSpectate = ser.ReadBool();
|
||||
this.IsTextChatMuted = ser.ReadBool();
|
||||
this.IsVoiceChatMuted = ser.ReadBool();
|
||||
this.RespawnTime = ser.ReadFloat();
|
||||
this.CanRespawn = ser.ReadBool();
|
||||
}
|
||||
if (value == mInternal.Role)
|
||||
return;
|
||||
SetNewRole(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Team Team
|
||||
{
|
||||
get => mInternal.Team;
|
||||
set
|
||||
{
|
||||
if (mInternal.Team != value)
|
||||
ChangeTeam(value);
|
||||
}
|
||||
}
|
||||
|
||||
public Squads Squad
|
||||
{
|
||||
get => mInternal.Squad;
|
||||
set
|
||||
{
|
||||
if (value == mInternal.Squad)
|
||||
return;
|
||||
if (value == Squads.NoSquad)
|
||||
KickFromSquad();
|
||||
else
|
||||
JoinSquad(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool InSquad => mInternal.Squad != Squads.NoSquad;
|
||||
public int PingMs => mInternal.PingMs;
|
||||
|
||||
public float HP => mInternal.HP;
|
||||
public bool IsAlive => mInternal.HP >= 0f;
|
||||
public bool IsUp => mInternal.HP > 0f;
|
||||
public bool IsDown => mInternal.HP == 0f;
|
||||
public bool IsDead => mInternal.HP == -1f;
|
||||
|
||||
public Vector3 Position
|
||||
{
|
||||
get => mInternal.Position;
|
||||
set => Teleport(value);
|
||||
}
|
||||
|
||||
public PlayerStand StandingState => mInternal.Standing;
|
||||
public LeaningSide LeaningState => mInternal.Leaning;
|
||||
public LoadoutIndex CurrentLoadoutIndex => mInternal.CurrentLoadoutIndex;
|
||||
public bool InVehicle => mInternal.InVehicle;
|
||||
public bool IsBleeding => mInternal.IsBleeding;
|
||||
public PlayerLoadout CurrentLoadout => mInternal.CurrentLoadout;
|
||||
public PlayerWearings CurrentWearings => mInternal.CurrentWearings;
|
||||
public PlayerModifications<TPlayer> Modifications => mInternal.Modifications;
|
||||
|
||||
// ---- Events ----
|
||||
public virtual void OnCreated()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnConnected()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnSpawned()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnDowned()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnGivenUp()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnRevivedByAnotherPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnRevivedAnotherPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnDied()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnChangedTeam()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnChangedRole(GameRole newRole)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnJoinedSquad(Squads newSquad)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnLeftSquad(Squads oldSquad)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual async Task OnDisconnected()
|
||||
{
|
||||
}
|
||||
|
||||
// ---- Functions ----
|
||||
public void Kick(string reason = "")
|
||||
{
|
||||
GameServer.Kick(this, reason);
|
||||
}
|
||||
|
||||
public void Kill()
|
||||
{
|
||||
GameServer.Kill(this);
|
||||
}
|
||||
|
||||
public void ChangeTeam()
|
||||
{
|
||||
GameServer.ChangeTeam(this);
|
||||
}
|
||||
|
||||
public void ChangeTeam(Team team)
|
||||
{
|
||||
GameServer.ChangeTeam(this, team);
|
||||
}
|
||||
|
||||
public void KickFromSquad()
|
||||
{
|
||||
GameServer.KickFromSquad(this);
|
||||
}
|
||||
|
||||
public void JoinSquad(Squads targetSquad)
|
||||
{
|
||||
GameServer.JoinSquad(this, targetSquad);
|
||||
}
|
||||
|
||||
public void DisbandTheSquad()
|
||||
{
|
||||
GameServer.DisbandPlayerCurrentSquad(this);
|
||||
}
|
||||
|
||||
public void PromoteToSquadLeader()
|
||||
{
|
||||
GameServer.PromoteSquadLeader(this);
|
||||
}
|
||||
|
||||
public void WarnPlayer(string msg)
|
||||
{
|
||||
GameServer.WarnPlayer(this, msg);
|
||||
}
|
||||
|
||||
public void Message(string msg)
|
||||
{
|
||||
GameServer.MessageToPlayer(this, msg);
|
||||
}
|
||||
|
||||
public void Message(string msg, float fadeoutTime)
|
||||
{
|
||||
GameServer.MessageToPlayer(this, msg, fadeoutTime);
|
||||
}
|
||||
|
||||
public void SetNewRole(GameRole role)
|
||||
{
|
||||
GameServer.SetRoleTo(this, role);
|
||||
}
|
||||
|
||||
public void Teleport(Vector3 target)
|
||||
{
|
||||
}
|
||||
|
||||
public void SpawnPlayer(PlayerLoadout loadout, PlayerWearings wearings, Vector3 position, Vector3 lookDirection, PlayerStand stand, float spawnProtection)
|
||||
{
|
||||
GameServer.SpawnPlayer(this, loadout, wearings, position, lookDirection, stand, spawnProtection);
|
||||
}
|
||||
|
||||
public void SetHP(float newHP)
|
||||
{
|
||||
GameServer.SetHP(this, newHP);
|
||||
}
|
||||
|
||||
public void GiveDamage(float damage)
|
||||
{
|
||||
GameServer.GiveDamage(this, damage);
|
||||
}
|
||||
|
||||
public void Heal(float hp)
|
||||
{
|
||||
GameServer.Heal(this, hp);
|
||||
}
|
||||
|
||||
public void SetRunningSpeedMultiplier(float value)
|
||||
{
|
||||
GameServer.SetRunningSpeedMultiplier(this, value);
|
||||
}
|
||||
|
||||
public void SetReceiveDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetReceiveDamageMultiplier(this, value);
|
||||
}
|
||||
|
||||
public void SetGiveDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetGiveDamageMultiplier(this, value);
|
||||
}
|
||||
|
||||
public void SetJumpMultiplier(float value)
|
||||
{
|
||||
GameServer.SetJumpMultiplier(this, value);
|
||||
}
|
||||
|
||||
public void SetFallDamageMultiplier(float value)
|
||||
{
|
||||
GameServer.SetFallDamageMultiplier(this, value);
|
||||
}
|
||||
|
||||
public void SetPrimaryWeapon(WeaponItem item, int extraMagazines, bool clear = false)
|
||||
{
|
||||
GameServer.SetPrimaryWeapon(this, item, extraMagazines, clear);
|
||||
}
|
||||
|
||||
public void SetSecondaryWeapon(WeaponItem item, int extraMagazines, bool clear = false)
|
||||
{
|
||||
GameServer.SetSecondaryWeapon(this, item, extraMagazines, clear);
|
||||
}
|
||||
|
||||
public void SetFirstAidGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetFirstAid(this, item, extra, clear);
|
||||
}
|
||||
|
||||
public void SetLightGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetLightGadget(this, item, extra, clear);
|
||||
}
|
||||
|
||||
public void SetHeavyGadget(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetHeavyGadget(this, item, extra, clear);
|
||||
}
|
||||
|
||||
public void SetThrowable(string item, int extra, bool clear = false)
|
||||
{
|
||||
GameServer.SetThrowable(this, item, extra, clear);
|
||||
}
|
||||
|
||||
// ---- Static ----
|
||||
public static TPlayer CreateInstance<TPlayer>(Player<TPlayer>.Internal @internal) where TPlayer : Player<TPlayer>
|
||||
{
|
||||
var player = (TPlayer)Activator.CreateInstance(typeof(TPlayer));
|
||||
player.mInternal = @internal;
|
||||
return player;
|
||||
}
|
||||
|
||||
// ---- Overrides ----
|
||||
public override string ToString()
|
||||
{
|
||||
return Name + " (" + SteamID + ")";
|
||||
}
|
||||
|
||||
// ---- Internal ----
|
||||
public class Internal
|
||||
{
|
||||
public mPlayerModifications _Modifications;
|
||||
public PlayerLoadout CurrentLoadout;
|
||||
public LoadoutIndex CurrentLoadoutIndex;
|
||||
public PlayerWearings CurrentWearings;
|
||||
public GameServer<TPlayer> GameServer;
|
||||
public float HP;
|
||||
public bool InVehicle;
|
||||
public IPAddress IP;
|
||||
|
||||
public bool IsAlive;
|
||||
public bool IsBleeding;
|
||||
public LeaningSide Leaning;
|
||||
public PlayerModifications<TPlayer> Modifications;
|
||||
public string Name;
|
||||
public int PingMs = 999;
|
||||
public Vector3 Position;
|
||||
public GameRole Role;
|
||||
public Squads Squad;
|
||||
public PlayerStand Standing;
|
||||
public ulong SteamID;
|
||||
public Team Team;
|
||||
|
||||
public Internal()
|
||||
{
|
||||
Modifications = new PlayerModifications<TPlayer>(this);
|
||||
_Modifications = new mPlayerModifications();
|
||||
}
|
||||
|
||||
public void OnDie()
|
||||
{
|
||||
IsAlive = false;
|
||||
HP = -1f;
|
||||
Position = default;
|
||||
Standing = PlayerStand.Standing;
|
||||
Leaning = LeaningSide.None;
|
||||
CurrentLoadoutIndex = LoadoutIndex.Primary;
|
||||
InVehicle = false;
|
||||
IsBleeding = false;
|
||||
CurrentLoadout = new PlayerLoadout();
|
||||
CurrentWearings = new PlayerWearings();
|
||||
}
|
||||
}
|
||||
|
||||
public class mPlayerModifications
|
||||
{
|
||||
public bool AirStrafe = true;
|
||||
public bool CanRespawn = true;
|
||||
public bool CanSpawn = true;
|
||||
public bool CanSpectate = true;
|
||||
public bool CanUseNightVision = true;
|
||||
public float DownTimeGiveUpTime = 60f;
|
||||
public float FallDamageMultiplier = 1f;
|
||||
public float GiveDamageMultiplier = 1f;
|
||||
public bool HasCollision;
|
||||
|
||||
public bool IsDirtyFlag = false;
|
||||
public bool IsTextChatMuted;
|
||||
public bool IsVoiceChatMuted;
|
||||
public float JumpHeightMultiplier = 1f;
|
||||
public float ReceiveDamageMultiplier = 1f;
|
||||
public float ReloadSpeedMultiplier = 1f;
|
||||
public float RespawnTime = 10f;
|
||||
public float RunningSpeedMultiplier = 1f;
|
||||
|
||||
public void Write(Stream ser)
|
||||
{
|
||||
ser.Write(RunningSpeedMultiplier);
|
||||
ser.Write(ReceiveDamageMultiplier);
|
||||
ser.Write(GiveDamageMultiplier);
|
||||
ser.Write(JumpHeightMultiplier);
|
||||
ser.Write(FallDamageMultiplier);
|
||||
ser.Write(ReloadSpeedMultiplier);
|
||||
ser.Write(CanUseNightVision);
|
||||
ser.Write(HasCollision);
|
||||
ser.Write(DownTimeGiveUpTime);
|
||||
ser.Write(AirStrafe);
|
||||
ser.Write(CanSpawn);
|
||||
ser.Write(CanSpectate);
|
||||
ser.Write(IsTextChatMuted);
|
||||
ser.Write(IsVoiceChatMuted);
|
||||
ser.Write(RespawnTime);
|
||||
ser.Write(CanRespawn);
|
||||
}
|
||||
|
||||
public void Read(Stream ser)
|
||||
{
|
||||
RunningSpeedMultiplier = ser.ReadFloat();
|
||||
if (RunningSpeedMultiplier <= 0f)
|
||||
RunningSpeedMultiplier = 0.01f;
|
||||
|
||||
ReceiveDamageMultiplier = ser.ReadFloat();
|
||||
GiveDamageMultiplier = ser.ReadFloat();
|
||||
JumpHeightMultiplier = ser.ReadFloat();
|
||||
FallDamageMultiplier = ser.ReadFloat();
|
||||
ReloadSpeedMultiplier = ser.ReadFloat();
|
||||
CanUseNightVision = ser.ReadBool();
|
||||
HasCollision = ser.ReadBool();
|
||||
DownTimeGiveUpTime = ser.ReadFloat();
|
||||
AirStrafe = ser.ReadBool();
|
||||
CanSpawn = ser.ReadBool();
|
||||
CanSpectate = ser.ReadBool();
|
||||
IsTextChatMuted = ser.ReadBool();
|
||||
IsVoiceChatMuted = ser.ReadBool();
|
||||
RespawnTime = ser.ReadFloat();
|
||||
CanRespawn = ser.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,41 +1,45 @@
|
|||
using BattleBitAPI.Common;
|
||||
|
||||
namespace BattleBitAPI.Storage
|
||||
namespace BattleBitAPI.Storage;
|
||||
|
||||
public class DiskStorage : IPlayerStatsDatabase
|
||||
{
|
||||
public class DiskStorage : IPlayerStatsDatabase
|
||||
private readonly string mDirectory;
|
||||
|
||||
public DiskStorage(string directory)
|
||||
{
|
||||
private string mDirectory;
|
||||
public DiskStorage(string directory)
|
||||
{
|
||||
var info = new DirectoryInfo(directory);
|
||||
if (!info.Exists)
|
||||
info.Create();
|
||||
var info = new DirectoryInfo(directory);
|
||||
if (!info.Exists)
|
||||
info.Create();
|
||||
|
||||
this.mDirectory = info.FullName + Path.DirectorySeparatorChar;
|
||||
}
|
||||
mDirectory = info.FullName + Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
public async Task<PlayerStats> GetPlayerStatsOf(ulong steamID)
|
||||
{
|
||||
var file = this.mDirectory + steamID + ".data";
|
||||
if (File.Exists(file))
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = await File.ReadAllBytesAsync(file);
|
||||
return new PlayerStats(data);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public async Task SavePlayerStatsOf(ulong steamID, PlayerStats stats)
|
||||
{
|
||||
var file = this.mDirectory + steamID + ".data";
|
||||
public async Task<PlayerStats> GetPlayerStatsOf(ulong steamID)
|
||||
{
|
||||
var file = mDirectory + steamID + ".data";
|
||||
if (File.Exists(file))
|
||||
try
|
||||
{
|
||||
await File.WriteAllBytesAsync(file, stats.SerializeToByteArray());
|
||||
var data = await File.ReadAllBytesAsync(file);
|
||||
return new PlayerStats(data);
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task SavePlayerStatsOf(ulong steamID, PlayerStats stats)
|
||||
{
|
||||
var file = mDirectory + steamID + ".data";
|
||||
try
|
||||
{
|
||||
await File.WriteAllBytesAsync(file, stats.SerializeToByteArray());
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
using BattleBitAPI.Common;
|
||||
|
||||
namespace BattleBitAPI.Storage
|
||||
namespace BattleBitAPI.Storage;
|
||||
|
||||
public interface IPlayerStatsDatabase
|
||||
{
|
||||
public interface IPlayerStatsDatabase
|
||||
{
|
||||
public Task<PlayerStats> GetPlayerStatsOf(ulong steamID);
|
||||
public Task SavePlayerStatsOf(ulong steamID, PlayerStats stats);
|
||||
}
|
||||
}
|
||||
public Task<PlayerStats> GetPlayerStatsOf(ulong steamID);
|
||||
public Task SavePlayerStatsOf(ulong steamID, PlayerStats stats);
|
||||
}
|
22
Program.cs
22
Program.cs
|
@ -1,28 +1,26 @@
|
|||
using BattleBitAPI;
|
||||
using BattleBitAPI.Common;
|
||||
using BattleBitAPI.Server;
|
||||
using System.Threading.Channels;
|
||||
using System.Xml;
|
||||
|
||||
class Program
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var listener = new ServerListener<MyPlayer, MyGameServer>();
|
||||
listener.Start(29294);
|
||||
|
||||
Thread.Sleep(-1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class MyPlayer : Player<MyPlayer>
|
||||
|
||||
internal class MyPlayer : Player<MyPlayer>
|
||||
{
|
||||
public override async Task OnConnected()
|
||||
{
|
||||
}
|
||||
}
|
||||
class MyGameServer : GameServer<MyPlayer>
|
||||
|
||||
internal class MyGameServer : GameServer<MyPlayer>
|
||||
{
|
||||
public override async Task OnConnected()
|
||||
{
|
||||
|
@ -36,28 +34,34 @@ class MyGameServer : GameServer<MyPlayer>
|
|||
{
|
||||
await Console.Out.WriteLineAsync("Connected: " + player);
|
||||
}
|
||||
|
||||
public override async Task OnPlayerSpawned(MyPlayer player)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Spawned: " + player);
|
||||
}
|
||||
|
||||
public override async Task OnAPlayerDownedAnotherPlayer(OnPlayerKillArguments<MyPlayer> args)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Downed: " + args.Victim);
|
||||
}
|
||||
|
||||
public override async Task OnPlayerGivenUp(MyPlayer player)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Giveup: " + player);
|
||||
}
|
||||
|
||||
public override async Task OnPlayerDied(MyPlayer player)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Died: " + player);
|
||||
}
|
||||
|
||||
public override async Task OnAPlayerRevivedAnotherPlayer(MyPlayer from, MyPlayer to)
|
||||
{
|
||||
await Console.Out.WriteLineAsync(from + " revived " + to);
|
||||
}
|
||||
|
||||
public override async Task OnPlayerDisconnected(MyPlayer player)
|
||||
{
|
||||
await Console.Out.WriteLineAsync("Disconnected: " + player);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue