diff --git a/api/BitMod/BitMod.csproj b/api/BitMod/BitMod.csproj index 460a9c9..6846346 100644 --- a/api/BitMod/BitMod.csproj +++ b/api/BitMod/BitMod.csproj @@ -13,7 +13,7 @@ - + diff --git a/api/BitMod/Compatibility/BitPlayer.cs b/api/BitMod/Compatibility/BitPlayer.cs index 8c1ecd7..ba69a5a 100644 --- a/api/BitMod/Compatibility/BitPlayer.cs +++ b/api/BitMod/Compatibility/BitPlayer.cs @@ -4,7 +4,22 @@ namespace BitMod.Compatibility; -public class BitPlayer : Player, IBitObject +public class BitPlayer : Player, IBitObject, IMount { public Mount Mount { get; } = new Mount(); + + public void Store(T value) where T : class + => Mount.Store(value); + + public T? Get() where T : class + => Mount.Get(); + + public T? Super(Type super) where T : class + => Mount.Super(super); + + public bool Has() + => Mount.Has(); + + public bool Has(Type t) + => Mount.Has(t); } diff --git a/api/BitMod/Compatibility/BitServer.cs b/api/BitMod/Compatibility/BitServer.cs index 8bdf1d3..ff817eb 100644 --- a/api/BitMod/Compatibility/BitServer.cs +++ b/api/BitMod/Compatibility/BitServer.cs @@ -4,10 +4,25 @@ namespace BitMod.Compatibility; -public class BitServer : GameServer, IBitObject +public class BitServer : GameServer, IBitObject, IMount { public Mount Mount { get; } + public void Store(T value) where T : class + => Mount.Store(value); + + public T? Get() where T : class + => Mount.Get(); + + public T? Super(Type super) where T : class + => Mount.Super(super); + + public bool Has() + => Mount.Has(); + + public bool Has(Type t) + => Mount.Has(t); + public override string ToString() => $"{this.GameIP}:{this.GamePort}"; diff --git a/api/BitMod/Events/Squad/SquadLeaderChangedEventArgs.cs b/api/BitMod/Events/Squad/SquadLeaderChangedEventArgs.cs new file mode 100644 index 0000000..a5c9fa4 --- /dev/null +++ b/api/BitMod/Events/Squad/SquadLeaderChangedEventArgs.cs @@ -0,0 +1,34 @@ +using BattleBitAPI.Server; + +using BitMod.Compatibility; +using BitMod.Events.Accessors; +using BitMod.Events.Base; + +namespace BitMod.Events.Squad; + +public class SquadLeaderChangedEventArgs : IEventArgs, IGameserverEvent, IResponsiblePlayerEvent +{ + public SquadLeaderChangedEventArgs(BitServer server, Squad squad, BitPlayer leader) + { + Server = server; + Leader = leader; + Squad = squad; + } + + /// + /// The squad that had it's leadership changed + /// + public Squad Squad { get; } + + /// + /// The new leader + /// + public BitPlayer Leader { get; } + + /// + /// The server this event happened on + /// + public BitServer Server { get; } + + public BitPlayer? ResponsiblePlayer => Leader; +} diff --git a/api/BitMod/Handler/RoutingGameserver.cs b/api/BitMod/Handler/RoutingGameserver.cs index 76991ba..2bddfda 100644 --- a/api/BitMod/Handler/RoutingGameserver.cs +++ b/api/BitMod/Handler/RoutingGameserver.cs @@ -55,15 +55,6 @@ public override async Task OnPlayerChangeTeam(BitPlayer player, Team team) public override async Task OnPlayerRequestingToChangeTeam(BitPlayer player, Team requestedTeam) => _invoker.Hook(new PlayerChangingTeamEventArgs(this, player, requestedTeam), true); - public override async Task OnPlayerJoinedSquad(BitPlayer player, Squad squad) - => _invoker.Event(new PlayerJoinedSquadEventArgs(this, player, squad)); - - public override async Task OnPlayerLeftSquad(BitPlayer player, Squad squad) - => _invoker.Event(new PlayerLeftSquadEventArgs(this, player, squad)); - - public override async Task OnSquadPointsChanged(Squad squad, int newPoints) - => _invoker.Event(new SquadPointsChangedEventArgs(this, squad, newPoints)); - public override async Task OnPlayerGivenUp(BitPlayer player) => _invoker.Event(new PlayerGivenUpEventArgs(this, player)); @@ -78,6 +69,22 @@ public override async Task OnPlayerRequestingToChangeRole(BitPlayer player #endregion + #region Squad + + public override async Task OnSquadLeaderChanged(Squad squad, BitPlayer newLeader) + => _invoker.Event(new SquadLeaderChangedEventArgs(this, squad, newLeader)); + + public override async Task OnPlayerJoinedSquad(BitPlayer player, Squad squad) + => _invoker.Event(new PlayerJoinedSquadEventArgs(this, player, squad)); + + public override async Task OnPlayerLeftSquad(BitPlayer player, Squad squad) + => _invoker.Event(new PlayerLeftSquadEventArgs(this, player, squad)); + + public override async Task OnSquadPointsChanged(Squad squad, int newPoints) + => _invoker.Event(new SquadPointsChangedEventArgs(this, squad, newPoints)); + + #endregion + #region Gameserver public override async Task OnConnected()