Stop cancelling initial Airship spawn SnapTo RPC

This is used to hide players that are still selecting their spawn
location. If this is cancelled, players are left standing at the
location they were at when the last meeting was called, which is undesirable.
This commit is contained in:
miniduikboot committed 2021-07-05 20:01:20 +02:00
1 parent 11f2ffd24d
commit 241e867343
1 file changed
+16 -7
@@ -26,7 +26,7 @@ namespace Impostor.Server.Net.Inner.Objects.Components
private readonly ObjectPool<PlayerMovementEvent> _pool;
private ushort _lastSequenceId;
private bool _spawnSnapAllowed;
private AirshipSpawnState _spawnState;
public InnerCustomNetworkTransform(ICustomMessageManager<ICustomRpc> customMessageManager, Game game, ILogger<InnerCustomNetworkTransform> logger, InnerPlayerControl playerControl, IEventManager eventManager, ObjectPool<PlayerMovementEvent> pool) : base(customMessageManager, game)
{
@@ -36,6 +36,13 @@ namespace Impostor.Server.Net.Inner.Objects.Components
_pool = pool;
}
private enum AirshipSpawnState : byte
{
PreSpawn,
SelectingSpawn,
Spawned,
}
public Vector2 Position { get; private set; }
public Vector2 Velocity { get; private set; }
@@ -98,15 +105,17 @@ namespace Impostor.Server.Net.Inner.Objects.Components
if (Game.GameNet.ShipStatus is InnerAirshipStatus airshipStatus)
{
// As part of airship spawning, clients are sending snap to -25 40 for no reason(?), cancelling it works just fine
if (Approximately(position, airshipStatus.PreSpawnLocation))
// As part of airship spawning, clients are sending snap to -25 40 to move themself out of view
if (_spawnState == AirshipSpawnState.PreSpawn && Approximately(position, airshipStatus.PreSpawnLocation))
{
return false;
_spawnState = AirshipSpawnState.SelectingSpawn;
return true;
}
if (_spawnSnapAllowed && airshipStatus.SpawnLocations.Any(location => Approximately(position, location)))
// Once the spawn has been selected, the client sends a second snap to the select spawn location
if (_spawnState == AirshipSpawnState.SelectingSpawn && airshipStatus.SpawnLocations.Any(location => Approximately(position, location)))
{
_spawnSnapAllowed = false;
_spawnState = AirshipSpawnState.Spawned;
return true;
}
}
@@ -152,7 +161,7 @@ namespace Impostor.Server.Net.Inner.Objects.Components
internal void OnPlayerSpawn()
{
_spawnSnapAllowed = true;
_spawnState = AirshipSpawnState.PreSpawn;
}
private static bool SidGreaterThan(ushort newSid, ushort prevSid)