Merge pull request #80 from MrOkiDoki/develop

1.0.6
This commit is contained in:
MrOkiDoki 2023-08-30 06:39:31 -07:00 committed by GitHub
commit fcb89ff28e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 197 additions and 5 deletions

View File

@ -2,7 +2,7 @@
{
public static class Const
{
public static string Version = "1.0.5v";
public static string Version = "1.0.6v";
// ---- Networking ----
/// <summary>
@ -11,7 +11,7 @@
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>
/// </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.

View File

@ -0,0 +1,18 @@
namespace BattleBitAPI.Common
{
public struct EndGamePlayer<TPlayer> : IComparable<EndGamePlayer<TPlayer>> where TPlayer : Player<TPlayer>
{
public Player<TPlayer> Player;
public int Score;
public EndGamePlayer(Player<TPlayer> player, int score)
{
this.Player = player;
this.Score = score;
}
public int CompareTo(EndGamePlayer<TPlayer> other)
{
return other.Score.CompareTo(this.Score);
}
}
}

View File

@ -0,0 +1,6 @@
namespace BattleBitAPI.Common
{
public class EndGamePlayer
{
}
}

View File

@ -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();
}
}
}

View File

@ -0,0 +1,8 @@
namespace BattleBitAPI.Common
{
public enum VoxelTextures : byte
{
Default = 0,
NeonOrange = 1,
}
}

View File

@ -16,6 +16,9 @@
SetPlayerWeapon = 16,
SetPlayerGadget = 17,
SetPlayerModifications = 18,
EndgameWithPlayers = 19,
PlaceVoxelBlock = 20,
RemoveVoxelBlock = 21,
PlayerConnected = 50,
PlayerDisconnected = 51,

View File

@ -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<EndGamePlayer<TPlayer>> 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<TPlayer> 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<TPlayer> IterateMembersOf(Squad<TPlayer> squad)
{

View File

@ -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;
}
}
}

View File

@ -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;
}
}
}

View File

@ -882,7 +882,6 @@ namespace BattleBitAPI.Server
}
break;
}
case NetworkCommuncation.PlayerConnected:
{
if (stream.CanRead(8 + 2 + 4 + (1 + 1 + 1)))

View File

@ -18,7 +18,7 @@
<PackageProjectUrl>https://github.com/MrOkiDoki/BattleBit-Community-Server-API</PackageProjectUrl>
<RepositoryUrl>https://github.com/MrOkiDoki/BattleBit-Community-Server-API</RepositoryUrl>
<PackageTags>BattleBit</PackageTags>
<Version>1.0.4.2</Version>
<Version>1.0.6</Version>
</PropertyGroup>
<ItemGroup>