From 164cf6b3496aea1fc49679fc2d5b3e72ff78531d Mon Sep 17 00:00:00 2001 From: MrOkiDoki <0mrokidoki@gmail.com> Date: Mon, 14 Aug 2023 17:13:31 +0300 Subject: [PATCH] TODO: implement new fields --- .../Common/Arguments/OnPlayerKillArguments.cs | 1 + BattleBitAPI/Server/GameServer.cs | 12 +- .../Server/Internal/GamemodeRotation.cs | 1 + BattleBitAPI/Server/Internal/MapRotation.cs | 4 +- .../Server/Internal/PlayerModifications.cs | 28 ++++ BattleBitAPI/Server/Internal/RoundSettings.cs | 1 + .../Server/Internal/ServerSettings.cs | 8 +- BattleBitAPI/{ => Server}/Player.cs | 120 ++++++++++++++---- BattleBitAPI/Server/ServerListener.cs | 1 + Program.cs | 10 +- 10 files changed, 150 insertions(+), 36 deletions(-) create mode 100644 BattleBitAPI/Server/Internal/PlayerModifications.cs rename BattleBitAPI/{ => Server}/Player.cs (63%) diff --git a/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs index ca8389a..a0e0e2c 100644 --- a/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs +++ b/BattleBitAPI/Common/Arguments/OnPlayerKillArguments.cs @@ -1,4 +1,5 @@ using System.Numerics; +using CommunityServerAPI.BattleBitAPI.Server; namespace BattleBitAPI.Common { diff --git a/BattleBitAPI/Server/GameServer.cs b/BattleBitAPI/Server/GameServer.cs index cddc911..c3c0169 100644 --- a/BattleBitAPI/Server/GameServer.cs +++ b/BattleBitAPI/Server/GameServer.cs @@ -908,13 +908,14 @@ namespace BattleBitAPI.Server { public float DamageMultiplier = 1.0f; public bool BleedingEnabled = true; - public bool StamineEnabled = false; + public bool StaminaEnabled = false; public bool FriendlyFireEnabled = false; public bool HideMapVotes = true; public bool OnlyWinnerTeamCanVote = false; public bool HitMarkersEnabled = true; public bool PointLogEnabled = true; public bool SpectatorEnabled = true; + public float CaptureFlagSpeedMultiplier = 1f; public byte MedicLimitPerSquad = 8; public byte EngineerLimitPerSquad = 8; @@ -925,13 +926,15 @@ namespace BattleBitAPI.Server { ser.Write(this.DamageMultiplier); ser.Write(this.BleedingEnabled); - ser.Write(this.StamineEnabled); + ser.Write(this.StaminaEnabled); ser.Write(this.FriendlyFireEnabled); ser.Write(this.HideMapVotes); ser.Write(this.OnlyWinnerTeamCanVote); ser.Write(this.HitMarkersEnabled); ser.Write(this.PointLogEnabled); ser.Write(this.SpectatorEnabled); + ser.Write(this.CaptureFlagSpeedMultiplier); + ser.Write(this.MedicLimitPerSquad); ser.Write(this.EngineerLimitPerSquad); ser.Write(this.SupportLimitPerSquad); @@ -941,13 +944,14 @@ namespace BattleBitAPI.Server { this.DamageMultiplier = ser.ReadFloat(); this.BleedingEnabled = ser.ReadBool(); - this.StamineEnabled = ser.ReadBool(); + this.StaminaEnabled = ser.ReadBool(); this.FriendlyFireEnabled = ser.ReadBool(); this.HideMapVotes = ser.ReadBool(); this.OnlyWinnerTeamCanVote = ser.ReadBool(); this.HitMarkersEnabled = ser.ReadBool(); this.PointLogEnabled = ser.ReadBool(); this.SpectatorEnabled = ser.ReadBool(); + this.CaptureFlagSpeedMultiplier = ser.ReadFloat(); this.MedicLimitPerSquad = ser.ReadInt8(); this.EngineerLimitPerSquad = ser.ReadInt8(); @@ -958,7 +962,7 @@ namespace BattleBitAPI.Server { this.DamageMultiplier = 1.0f; this.BleedingEnabled = true; - this.StamineEnabled = false; + this.StaminaEnabled = false; this.FriendlyFireEnabled = false; this.HideMapVotes = true; this.OnlyWinnerTeamCanVote = false; diff --git a/BattleBitAPI/Server/Internal/GamemodeRotation.cs b/BattleBitAPI/Server/Internal/GamemodeRotation.cs index 999b11b..7c5ee4d 100644 --- a/BattleBitAPI/Server/Internal/GamemodeRotation.cs +++ b/BattleBitAPI/Server/Internal/GamemodeRotation.cs @@ -1,4 +1,5 @@ using BattleBitAPI.Common; +using CommunityServerAPI.BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/Internal/MapRotation.cs b/BattleBitAPI/Server/Internal/MapRotation.cs index e68d321..c718005 100644 --- a/BattleBitAPI/Server/Internal/MapRotation.cs +++ b/BattleBitAPI/Server/Internal/MapRotation.cs @@ -1,4 +1,6 @@ -namespace BattleBitAPI.Server +using CommunityServerAPI.BattleBitAPI.Server; + +namespace BattleBitAPI.Server { public class MapRotation where TPlayer : Player { diff --git a/BattleBitAPI/Server/Internal/PlayerModifications.cs b/BattleBitAPI/Server/Internal/PlayerModifications.cs new file mode 100644 index 0000000..4f9c77e --- /dev/null +++ b/BattleBitAPI/Server/Internal/PlayerModifications.cs @@ -0,0 +1,28 @@ +namespace BattleBitAPI.Server +{ + public class PlayerModifications where TPlayer : Player + { + private Player.Internal @internal; + public PlayerModifications(Player.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; } + } +} diff --git a/BattleBitAPI/Server/Internal/RoundSettings.cs b/BattleBitAPI/Server/Internal/RoundSettings.cs index ae1187f..a25a203 100644 --- a/BattleBitAPI/Server/Internal/RoundSettings.cs +++ b/BattleBitAPI/Server/Internal/RoundSettings.cs @@ -1,4 +1,5 @@ using BattleBitAPI.Common; +using CommunityServerAPI.BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/BattleBitAPI/Server/Internal/ServerSettings.cs b/BattleBitAPI/Server/Internal/ServerSettings.cs index f2ae763..b84bdf8 100644 --- a/BattleBitAPI/Server/Internal/ServerSettings.cs +++ b/BattleBitAPI/Server/Internal/ServerSettings.cs @@ -1,4 +1,6 @@ -namespace BattleBitAPI.Server +using CommunityServerAPI.BattleBitAPI.Server; + +namespace BattleBitAPI.Server { public class ServerSettings where TPlayer : Player { @@ -28,10 +30,10 @@ } public bool StamineEnabled { - get => mResources._RoomSettings.StamineEnabled; + get => mResources._RoomSettings.StaminaEnabled; set { - mResources._RoomSettings.StamineEnabled = value; + mResources._RoomSettings.StaminaEnabled = value; mResources.IsDirtyRoomSettings = true; } } diff --git a/BattleBitAPI/Player.cs b/BattleBitAPI/Server/Player.cs similarity index 63% rename from BattleBitAPI/Player.cs rename to BattleBitAPI/Server/Player.cs index 47a69b9..c05f783 100644 --- a/BattleBitAPI/Player.cs +++ b/BattleBitAPI/Server/Player.cs @@ -1,9 +1,7 @@ using BattleBitAPI.Common; -using BattleBitAPI.Networking; using BattleBitAPI.Server; using System.Net; using System.Numerics; -using System.Windows.Markup; namespace BattleBitAPI { @@ -69,6 +67,7 @@ namespace BattleBitAPI public bool IsBleeding => mInternal.IsBleeding; public PlayerLoadout CurrentLoadout => mInternal.CurrentLoadout; public PlayerWearings CurrentWearings => mInternal.CurrentWearings; + public PlayerModifications Modifications => mInternal.Modifications; // ---- Events ---- public virtual void OnCreated() @@ -128,51 +127,51 @@ namespace BattleBitAPI // ---- Functions ---- public void Kick(string reason = "") { - this.GameServer.Kick(this, reason); + GameServer.Kick(this, reason); } public void Kill() { - this.GameServer.Kill(this); + GameServer.Kill(this); } public void ChangeTeam() { - this.GameServer.ChangeTeam(this); + GameServer.ChangeTeam(this); } public void ChangeTeam(Team team) { - this.GameServer.ChangeTeam(this, team); + GameServer.ChangeTeam(this, team); } public void KickFromSquad() { - this.GameServer.KickFromSquad(this); + GameServer.KickFromSquad(this); } public void JoinSquad(Squads targetSquad) { - this.GameServer.JoinSquad(this, targetSquad); + GameServer.JoinSquad(this, targetSquad); } public void DisbandTheSquad() { - this.GameServer.DisbandPlayerCurrentSquad(this); + GameServer.DisbandPlayerCurrentSquad(this); } public void PromoteToSquadLeader() { - this.GameServer.PromoteSquadLeader(this); + GameServer.PromoteSquadLeader(this); } public void WarnPlayer(string msg) { - this.GameServer.WarnPlayer(this, msg); + GameServer.WarnPlayer(this, msg); } public void Message(string msg) { - this.GameServer.MessageToPlayer(this, msg); + GameServer.MessageToPlayer(this, msg); } public void Message(string msg, float fadeoutTime) { - this.GameServer.MessageToPlayer(this, msg, fadeoutTime); + GameServer.MessageToPlayer(this, msg, fadeoutTime); } public void SetNewRole(GameRole role) { - this.GameServer.SetRoleTo(this, role); + GameServer.SetRoleTo(this, role); } public void Teleport(Vector3 target) { @@ -250,7 +249,7 @@ namespace BattleBitAPI // ---- Overrides ---- public override string ToString() { - return this.Name + " (" + this.SteamID + ")"; + return Name + " (" + SteamID + ")"; } // ---- Internal ---- @@ -276,18 +275,89 @@ namespace BattleBitAPI public PlayerLoadout CurrentLoadout; public PlayerWearings CurrentWearings; + public mPlayerModifications _Modifications; + public PlayerModifications Modifications; + + public Internal() + { + this.Modifications = new PlayerModifications(this); + this._Modifications = new mPlayerModifications(); + } + public void OnDie() { - this.IsAlive = false; - this.HP = -1f; - this.Position = default; - this.Standing = PlayerStand.Standing; - this.Leaning = LeaningSide.None; - this.CurrentLoadoutIndex = LoadoutIndex.Primary; - this.InVehicle = false; - this.IsBleeding = false; - this.CurrentLoadout = new PlayerLoadout(); - this.CurrentWearings = new PlayerWearings(); + 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(); } } } diff --git a/BattleBitAPI/Server/ServerListener.cs b/BattleBitAPI/Server/ServerListener.cs index 018a167..5a4d261 100644 --- a/BattleBitAPI/Server/ServerListener.cs +++ b/BattleBitAPI/Server/ServerListener.cs @@ -9,6 +9,7 @@ using BattleBitAPI.Common.Extentions; using BattleBitAPI.Common.Serialization; using BattleBitAPI.Networking; using CommunityServerAPI.BattleBitAPI; +using CommunityServerAPI.BattleBitAPI.Server; namespace BattleBitAPI.Server { diff --git a/Program.cs b/Program.cs index 54d3401..022a2b9 100644 --- a/Program.cs +++ b/Program.cs @@ -18,19 +18,23 @@ class Program } class MyPlayer : Player { - + public override async Task OnConnected() + { + } } class MyGameServer : GameServer { public override async Task OnConnected() { ForceStartGame(); + + ServerSettings.PointLogEnabled = false; } public override async Task OnPlayerConnected(MyPlayer player) { - await Console.Out.WriteLineAsync("Connected: "+player); + await Console.Out.WriteLineAsync("Connected: " + player); } public override async Task OnPlayerSpawned(MyPlayer player) { @@ -50,7 +54,7 @@ class MyGameServer : GameServer } public override async Task OnAPlayerRevivedAnotherPlayer(MyPlayer from, MyPlayer to) { - await Console.Out.WriteLineAsync(from+" revived "+to); + await Console.Out.WriteLineAsync(from + " revived " + to); } public override async Task OnPlayerDisconnected(MyPlayer player) {