From ce7200888cef3b7446ae6fed501d67572eee59b7 Mon Sep 17 00:00:00 2001 From: MrOkiDoki <0mrokidoki@gmail.com> Date: Wed, 30 Aug 2023 16:39:12 +0300 Subject: [PATCH] 1.0.6 --- BattleBitAPI/Common/Conts.cs | 4 +- BattleBitAPI/Common/Data/EndGamePlayer.cs | 18 +++++ BattleBitAPI/Common/Data/EndGamePlayer1.cs | 6 ++ BattleBitAPI/Common/Data/VoxelBlockData.cs | 16 ++++ BattleBitAPI/Common/Enums/VoxelTextures.cs | 8 ++ .../Networking/NetworkCommuncation.cs | 3 + BattleBitAPI/Server/GameServer.cs | 81 ++++++++++++++++++- .../Server/Internal/PlayerModifications.cs | 47 +++++++++++ .../Server/Internal/ServerSettings.cs | 16 ++++ BattleBitAPI/Server/ServerListener.cs | 1 - CommunityServerAPI.csproj | 2 +- 11 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 BattleBitAPI/Common/Data/EndGamePlayer.cs create mode 100644 BattleBitAPI/Common/Data/EndGamePlayer1.cs create mode 100644 BattleBitAPI/Common/Data/VoxelBlockData.cs create mode 100644 BattleBitAPI/Common/Enums/VoxelTextures.cs diff --git a/BattleBitAPI/Common/Conts.cs b/BattleBitAPI/Common/Conts.cs index 72efa1c..8bed8fb 100644 --- a/BattleBitAPI/Common/Conts.cs +++ b/BattleBitAPI/Common/Conts.cs @@ -2,7 +2,7 @@ { public static class Const { - public static string Version = "1.0.5v"; + public static string Version = "1.0.6v"; // ---- Networking ---- /// @@ -11,7 +11,7 @@ public const int MaxNetworkPackageSize = 1024 * 1024 * 4;//4mb /// /// How long should server/client wait until connection is determined as timed out when no packages is being sent for long time. - /// + /// public const int NetworkTimeout = 60 * 1000;//60 seconds /// /// How frequently client/server will send keep alive to each other when no message is being sent to each other for a while. diff --git a/BattleBitAPI/Common/Data/EndGamePlayer.cs b/BattleBitAPI/Common/Data/EndGamePlayer.cs new file mode 100644 index 0000000..80071e3 --- /dev/null +++ b/BattleBitAPI/Common/Data/EndGamePlayer.cs @@ -0,0 +1,18 @@ +namespace BattleBitAPI.Common +{ + public struct EndGamePlayer : IComparable> where TPlayer : Player + { + public Player Player; + public int Score; + + public EndGamePlayer(Player player, int score) + { + this.Player = player; + this.Score = score; + } + public int CompareTo(EndGamePlayer other) + { + return other.Score.CompareTo(this.Score); + } + } +} diff --git a/BattleBitAPI/Common/Data/EndGamePlayer1.cs b/BattleBitAPI/Common/Data/EndGamePlayer1.cs new file mode 100644 index 0000000..bab499c --- /dev/null +++ b/BattleBitAPI/Common/Data/EndGamePlayer1.cs @@ -0,0 +1,6 @@ +namespace BattleBitAPI.Common +{ + public class EndGamePlayer + { + } +} \ No newline at end of file diff --git a/BattleBitAPI/Common/Data/VoxelBlockData.cs b/BattleBitAPI/Common/Data/VoxelBlockData.cs new file mode 100644 index 0000000..afe5182 --- /dev/null +++ b/BattleBitAPI/Common/Data/VoxelBlockData.cs @@ -0,0 +1,16 @@ +namespace BattleBitAPI.Common +{ + public struct VoxelBlockData + { + public VoxelTextures TextureID; + + public void Write(BattleBitAPI.Common.Serialization.Stream ser) + { + ser.Write((byte)TextureID); + } + public void Read(BattleBitAPI.Common.Serialization.Stream ser) + { + this.TextureID = (VoxelTextures)ser.ReadInt8(); + } + } +} diff --git a/BattleBitAPI/Common/Enums/VoxelTextures.cs b/BattleBitAPI/Common/Enums/VoxelTextures.cs new file mode 100644 index 0000000..429988b --- /dev/null +++ b/BattleBitAPI/Common/Enums/VoxelTextures.cs @@ -0,0 +1,8 @@ +namespace BattleBitAPI.Common +{ + public enum VoxelTextures : byte + { + Default = 0, + NeonOrange = 1, + } +} diff --git a/BattleBitAPI/Networking/NetworkCommuncation.cs b/BattleBitAPI/Networking/NetworkCommuncation.cs index e504326..e667ae9 100644 --- a/BattleBitAPI/Networking/NetworkCommuncation.cs +++ b/BattleBitAPI/Networking/NetworkCommuncation.cs @@ -16,6 +16,9 @@ SetPlayerWeapon = 16, SetPlayerGadget = 17, SetPlayerModifications = 18, + EndgameWithPlayers = 19, + PlaceVoxelBlock = 20, + RemoveVoxelBlock = 21, PlayerConnected = 50, PlayerDisconnected = 51, diff --git a/BattleBitAPI/Server/GameServer.cs b/BattleBitAPI/Server/GameServer.cs index f3cc261..c140294 100644 --- a/BattleBitAPI/Server/GameServer.cs +++ b/BattleBitAPI/Server/GameServer.cs @@ -571,10 +571,63 @@ namespace BattleBitAPI.Server { ExecuteCommand("forcestart"); } + public void SetServerSizeForNextMatch(MapSize size) + { + switch (size) + { + case MapSize.None: + ExecuteCommand("setsize none"); + break; + + case MapSize._8v8: + ExecuteCommand("setsize tiny"); + break; + + case MapSize._16vs16: + ExecuteCommand("setsize small"); + break; + + case MapSize._32vs32: + ExecuteCommand("setsize medium"); + break; + + case MapSize._64vs64: + ExecuteCommand("setsize big"); + break; + + case MapSize._127vs127: + ExecuteCommand("setsize ultra"); + break; + } + } public void ForceEndGame() { ExecuteCommand("endgame"); } + public void ForceEndGame(Team team) + { + if (team == Team.None) + ExecuteCommand("endgame draw"); + else if (team == Team.TeamA) + ExecuteCommand("endgame a"); + else if (team == Team.TeamB) + ExecuteCommand("endgame b"); + } + public void ForceEndGame(List> players) + { + using (var packet = Common.Serialization.Stream.Get()) + { + packet.Write((byte)NetworkCommuncation.EndgameWithPlayers); + packet.Write((uint)players.Count); + foreach (var item in players) + { + packet.Write(item.Player.SteamID); + packet.Write(item.Score); + } + + WriteToSocket(packet); + } + } public void SayToAllChat(string msg) { ExecuteCommand("say " + msg); @@ -677,7 +730,7 @@ namespace BattleBitAPI.Server } public void Teleport(ulong steamID, Vector3 position) { - ExecuteCommand("teleport " + steamID + " " + position.X+","+ position.Y+","+ position.Z); + ExecuteCommand("teleport " + steamID + " " + ((int)position.X) + "," + ((int)position.Y) + "," + ((int)position.Z)); } public void Teleport(Player player, Vector3 position) { @@ -880,6 +933,32 @@ namespace BattleBitAPI.Server SetThrowable(player.SteamID, tool, extra, clear); } + public void PlaceVoxelBlock(Vector3 position, VoxelBlockData data) + { + using (var packet = Common.Serialization.Stream.Get()) + { + packet.Write((byte)NetworkCommuncation.PlaceVoxelBlock); + packet.Write(position.X); + packet.Write(position.Y); + packet.Write(position.Z); + data.Write(packet); + + WriteToSocket(packet); + } + } + public void DestroyVoxelBlock(Vector3 position) + { + using (var packet = Common.Serialization.Stream.Get()) + { + packet.Write((byte)NetworkCommuncation.RemoveVoxelBlock); + packet.Write(position.X); + packet.Write(position.Y); + packet.Write(position.Z); + + WriteToSocket(packet); + } + } + // ---- Squads ---- public IEnumerable IterateMembersOf(Squad squad) { diff --git a/BattleBitAPI/Server/Internal/PlayerModifications.cs b/BattleBitAPI/Server/Internal/PlayerModifications.cs index 91c5da6..5ef72a1 100644 --- a/BattleBitAPI/Server/Internal/PlayerModifications.cs +++ b/BattleBitAPI/Server/Internal/PlayerModifications.cs @@ -1,4 +1,5 @@ using BattleBitAPI.Common; +using System.Runtime.ConstrainedExecution; namespace BattleBitAPI.Server { @@ -314,6 +315,39 @@ namespace BattleBitAPI.Server @internal._Modifications.IsDirtyFlag = true; } } + public bool Freeze + { + get => @internal._Modifications.Freeze; + set + { + if (@internal._Modifications.Freeze == value) + return; + @internal._Modifications.Freeze = value; + @internal._Modifications.IsDirtyFlag = true; + } + } + public float ReviveHP + { + get => @internal._Modifications.ReviveHP; + set + { + if (@internal._Modifications.ReviveHP == value) + return; + @internal._Modifications.ReviveHP = value; + @internal._Modifications.IsDirtyFlag = true; + } + } + public bool HideOnMap + { + get => @internal._Modifications.HideOnMap; + set + { + if (@internal._Modifications.HideOnMap == value) + return; + @internal._Modifications.HideOnMap = value; + @internal._Modifications.IsDirtyFlag = true; + } + } public void DisableBleeding() { @@ -356,6 +390,9 @@ namespace BattleBitAPI.Server public bool IsExposedOnMap = false; public SpawningRule SpawningRule; public VehicleType AllowedVehicles; + public bool Freeze = false; + public float ReviveHP = 35f; + public bool HideOnMap = false; public bool IsDirtyFlag = false; public void Write(BattleBitAPI.Common.Serialization.Stream ser) @@ -388,6 +425,9 @@ namespace BattleBitAPI.Server ser.Write(this.IsExposedOnMap); ser.Write((ulong)this.SpawningRule); ser.Write((byte)this.AllowedVehicles); + ser.Write(this.Freeze); + ser.Write(this.ReviveHP); + ser.Write(this.HideOnMap); } public void Read(BattleBitAPI.Common.Serialization.Stream ser) { @@ -422,6 +462,10 @@ namespace BattleBitAPI.Server this.IsExposedOnMap = ser.ReadBool(); this.SpawningRule = (SpawningRule)ser.ReadUInt64(); this.AllowedVehicles = (VehicleType)ser.ReadInt8(); + + this.Freeze = ser.ReadBool(); + this.ReviveHP = ser.ReadFloat(); + this.HideOnMap = ser.ReadBool(); } public void Reset() { @@ -451,6 +495,9 @@ namespace BattleBitAPI.Server this.KillFeed = false; this.SpawningRule = SpawningRule.All; this.AllowedVehicles = VehicleType.All; + this.Freeze = false; + this.ReviveHP = 35f; + this.HideOnMap = false; } } } diff --git a/BattleBitAPI/Server/Internal/ServerSettings.cs b/BattleBitAPI/Server/Internal/ServerSettings.cs index 052f845..32450d6 100644 --- a/BattleBitAPI/Server/Internal/ServerSettings.cs +++ b/BattleBitAPI/Server/Internal/ServerSettings.cs @@ -202,6 +202,17 @@ namespace BattleBitAPI.Server mResources.IsDirtyRoomSettings = true; } } + public bool TeamlessMode + { + get => mResources._RoomSettings.TeamlessMode; + set + { + if (mResources._RoomSettings.TeamlessMode == value) + return; + mResources._RoomSettings.TeamlessMode = value; + mResources.IsDirtyRoomSettings = true; + } + } // ---- Reset ---- public void Reset() @@ -233,6 +244,7 @@ namespace BattleBitAPI.Server public float HelicopterSpawnDelayMultipler = 1.0f; public bool UnlockAllAttachments = false; + public bool TeamlessMode = false; public void Write(Common.Serialization.Stream ser) { @@ -257,6 +269,7 @@ namespace BattleBitAPI.Server ser.Write(this.HelicopterSpawnDelayMultipler); ser.Write(this.UnlockAllAttachments); + ser.Write(this.TeamlessMode); } public void Read(Common.Serialization.Stream ser) { @@ -281,6 +294,8 @@ namespace BattleBitAPI.Server this.HelicopterSpawnDelayMultipler = ser.ReadFloat(); this.UnlockAllAttachments = ser.ReadBool(); + this.TeamlessMode = ser.ReadBool(); + } public void Reset() { @@ -305,6 +320,7 @@ namespace BattleBitAPI.Server this.HelicopterSpawnDelayMultipler = 1.0f; this.UnlockAllAttachments = false; + this.TeamlessMode = false; } } } diff --git a/BattleBitAPI/Server/ServerListener.cs b/BattleBitAPI/Server/ServerListener.cs index 2530598..a583673 100644 --- a/BattleBitAPI/Server/ServerListener.cs +++ b/BattleBitAPI/Server/ServerListener.cs @@ -882,7 +882,6 @@ namespace BattleBitAPI.Server } break; } - case NetworkCommuncation.PlayerConnected: { if (stream.CanRead(8 + 2 + 4 + (1 + 1 + 1))) diff --git a/CommunityServerAPI.csproj b/CommunityServerAPI.csproj index 23e1f89..41229f9 100644 --- a/CommunityServerAPI.csproj +++ b/CommunityServerAPI.csproj @@ -18,7 +18,7 @@ https://github.com/MrOkiDoki/BattleBit-Community-Server-API https://github.com/MrOkiDoki/BattleBit-Community-Server-API BattleBit - 1.0.4.2 + 1.0.6