-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add name/loadout overrides Fix `PsyonixLoadouts.GetFromName` * Experimental multi-RL mode for epic * Update `rl_ball_sym` * Fix Linux launch * Update Bridge.dll * Implement group ids spec * Add `has_jumped`, `has_double_jumped` & `has_flipped` * Fix team parsing for loadouts * Update to new future spec * Update to new spec * Rename `loadout_config` -> `loadout_file` * Remove `num_cars` and `num_scripts` from toml config parser * Rename group id to agent id * Update RLBotCS/Server/BridgeMessage.cs Co-authored-by: Nicolaj 'Eastvillage' Ø Jensen <[email protected]> * Don't send `PlayerInfoRequest` if agent id is empty * Rename `SetMatchSettings` -> `ClearProcessPlayerReservation` * `PlayerIdMap` -> `PlayerIdPair` * Update `Bridge.dll` * group id -> agent id --------- Co-authored-by: Nicolaj 'Eastvillage' Ø Jensen <[email protected]>
- Loading branch information
1 parent
500a43a
commit b20bbe9
Showing
28 changed files
with
571 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using rlbot.flat; | ||
|
||
namespace RLBotCS.ManagerTools; | ||
|
||
public struct PlayerIdPair | ||
{ | ||
public uint Index; | ||
public int SpawnId; | ||
} | ||
|
||
public class AgentReservation | ||
{ | ||
private class PlayerMetadata | ||
{ | ||
public uint Index; | ||
public int SpawnId; | ||
public uint Team; | ||
public string AgentId = ""; | ||
public bool IsReserved; | ||
} | ||
|
||
private readonly List<PlayerMetadata> _knownPlayers = new(); | ||
|
||
public void SetPlayers(MatchSettingsT matchSettings) | ||
{ | ||
_knownPlayers.Clear(); | ||
|
||
uint indexOffset = 0; | ||
for (int i = 0; i < matchSettings.PlayerConfigurations.Count; i++) | ||
{ | ||
var playerConfig = matchSettings.PlayerConfigurations[i]; | ||
|
||
if (playerConfig.Variety.Type != PlayerClass.RLBot) | ||
{ | ||
if (playerConfig.Variety.Type == PlayerClass.Human) | ||
indexOffset++; | ||
|
||
continue; | ||
} | ||
|
||
uint index = (uint)i - indexOffset; | ||
_knownPlayers.Add( | ||
( | ||
new PlayerMetadata | ||
{ | ||
Index = index, | ||
SpawnId = playerConfig.SpawnId, | ||
Team = playerConfig.Team, | ||
AgentId = playerConfig.AgentId, | ||
} | ||
) | ||
); | ||
} | ||
} | ||
|
||
public (PlayerIdPair, uint)? ReservePlayer(string agentId) | ||
{ | ||
PlayerMetadata? player = _knownPlayers.FirstOrDefault( | ||
playerMetadata => !playerMetadata.IsReserved && playerMetadata.AgentId == agentId | ||
); | ||
if (player != null) | ||
{ | ||
player.IsReserved = true; | ||
|
||
return ( | ||
new PlayerIdPair { Index = player.Index, SpawnId = player.SpawnId }, | ||
player.Team | ||
); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public (List<PlayerIdPair>, uint)? ReservePlayers(string agentId) | ||
{ | ||
// find the first player in the group | ||
if (ReservePlayer(agentId) is (PlayerIdPair, uint) initalPlayer) | ||
{ | ||
var playerIdPair = initalPlayer.Item1; | ||
var team = initalPlayer.Item2; | ||
|
||
List<PlayerIdPair> players = new() { playerIdPair }; | ||
|
||
// find other players in the same group & team | ||
|
||
var otherPlayers = _knownPlayers.Where( | ||
playerMetadata => | ||
!playerMetadata.IsReserved | ||
&& playerMetadata.AgentId == agentId | ||
&& playerMetadata.Team == team | ||
); | ||
|
||
foreach (var playerMetadata in otherPlayers) | ||
{ | ||
playerMetadata.IsReserved = true; | ||
players.Add( | ||
new PlayerIdPair | ||
{ | ||
Index = playerMetadata.Index, | ||
SpawnId = playerMetadata.SpawnId | ||
} | ||
); | ||
} | ||
|
||
return (players, team); | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.