44using LabExtended . API . CustomVoice ;
55using LabExtended . API . RemoteAdmin ;
66using LabExtended . API . FileStorage ;
7- using LabExtended . API . PositionSync ;
87
98using LabExtended . API . Settings . Menus ;
109using LabExtended . API . Settings . Entries ;
5049using CommandSystem ;
5150
5251using Footprinting ;
53-
52+ using LabApi . Events . Arguments . PlayerEvents ;
53+ using LabApi . Events . Handlers ;
54+ using LabExtended . Attributes ;
5455using NetworkManagerUtils . Dummies ;
5556
5657using NorthwoodLib . Pools ;
57-
58+ using PlayerRoles . FirstPersonControl . NetworkMessages ;
5859using UserSettings . ServerSpecific ;
5960
6061#pragma warning disable CS8602 // Dereference of a possibly null reference.
@@ -587,17 +588,17 @@ public ExPlayer(ReferenceHub referenceHub, SwitchContainer toggles) : base(refer
587588 /// Gets the player's hint cache.
588589 /// <para><i>null for players that cannot receive hints (ie. NPCs and the server player).</i></para>
589590 /// </summary>
590- public HintCache ? Hints { get ; }
591+ public HintCache ? Hints { get ; private set ; }
591592
592593 /// <summary>
593594 /// Gets the player's position container.
594595 /// </summary>
595- public new PositionContainer Position { get ; }
596+ public new PositionContainer Position { get ; private set ; }
596597
597598 /// <summary>
598599 /// Gets the player's rotation container.
599600 /// </summary>
600- public new RotationContainer Rotation { get ; }
601+ public new RotationContainer Rotation { get ; private set ; }
601602
602603 /// <summary>
603604 /// Gets the player's role container.
@@ -708,16 +709,16 @@ public ExPlayer(ReferenceHub referenceHub, SwitchContainer toggles) : base(refer
708709 HashSetPool < PersonalHintElement > . Shared . Rent ( ) ;
709710
710711 /// <summary>
711- /// Gets the player's sent role cache.
712+ /// Gets a list of sent role cache.
712713 /// </summary>
713- public Dictionary < uint , RoleTypeId > SentRoles { get ; internal set ; } =
714+ public Dictionary < uint , RoleTypeId > SentRoles { get ; private set ; } =
714715 DictionaryPool < uint , RoleTypeId > . Shared . Rent ( ) ;
715716
716717 /// <summary>
717- /// Gets the player's sent positions cache .
718+ /// Gets a list of sent positions.
718719 /// </summary>
719- public Dictionary < uint , PositionCache > SentPositions { get ; internal set ; }
720- = DictionaryPool < uint , PositionCache > . Shared . Rent ( ) ;
720+ public Dictionary < uint , PositionSync . SentPosition > SentPositions { get ; private set ; } =
721+ DictionaryPool < uint , PositionSync . SentPosition > . Shared . Rent ( ) ;
721722
722723 /// <summary>
723724 /// Gets the currently spectated player.
@@ -1373,13 +1374,9 @@ public void Dispose()
13731374 if ( ply == null )
13741375 return ;
13751376
1376- ply . SentRoles ? . Remove ( NetworkId ) ;
13771377 ply . PersonalGhostFlags &= ~ GhostBit ;
13781378 } ) ;
1379-
1380- if ( Hints != null )
1381- ObjectPool < HintCache > . Shared . Return ( Hints ) ;
1382-
1379+
13831380 Effects ? . Dispose ( ) ;
13841381 Effects = null ! ;
13851382
@@ -1394,6 +1391,17 @@ public void Dispose()
13941391
13951392 TemporaryStorage ? . Dispose ( ) ;
13961393 TemporaryStorage = null ! ;
1394+
1395+ if ( HintElements != null )
1396+ {
1397+ HintElements . ForEach ( x =>
1398+ {
1399+ x . IsActive = false ;
1400+ x . OnDisabled ( ) ;
1401+ } ) ;
1402+
1403+ HashSetPool < PersonalHintElement > . Shared . Return ( HintElements ) ;
1404+ }
13971405
13981406 if ( PersistentStorage != null )
13991407 {
@@ -1404,54 +1412,40 @@ public void Dispose()
14041412 PersistentStorage = null ! ;
14051413 }
14061414
1407- if ( SentRoles != null )
1408- {
1409- DictionaryPool < uint , RoleTypeId > . Shared . Return ( SentRoles ) ;
1410- SentRoles = null ! ;
1411- }
1412-
1413- if ( SentPositions != null )
1414- {
1415- DictionaryPool < uint , PositionCache > . Shared . Return ( SentPositions ) ;
1416- SentPositions = null ! ;
1417- }
1418-
14191415 if ( settingsIdLookup != null )
1420- {
14211416 DictionaryPool < string , SettingsEntry > . Shared . Return ( settingsIdLookup ) ;
1422- settingsIdLookup = null ;
1423- }
14241417
14251418 if ( settingsAssignedIdLookup != null )
1426- {
14271419 DictionaryPool < int , SettingsEntry > . Shared . Return ( settingsAssignedIdLookup ) ;
1428- settingsAssignedIdLookup = null ;
1429- }
14301420
14311421 if ( settingsMenuLookup != null )
1432- {
14331422 DictionaryPool < string , SettingsMenu > . Shared . Return ( settingsMenuLookup ) ;
1434- settingsMenuLookup = null ;
1435- }
14361423
14371424 if ( removeNextFrame != null )
1438- {
14391425 ListPool < HintElement > . Shared . Return ( removeNextFrame ) ;
1440- removeNextFrame = null ! ;
1441- }
14421426
1443- if ( HintElements != null )
1444- {
1445- HintElements . ForEach ( x =>
1446- {
1447- x . IsActive = false ;
1448- x . OnDisabled ( ) ;
1449- } ) ;
1427+ if ( Hints != null )
1428+ ObjectPool < HintCache > . Shared . Return ( Hints ) ;
1429+
1430+ if ( SentRoles != null )
1431+ DictionaryPool < uint , RoleTypeId > . Shared . Return ( SentRoles ) ;
1432+
1433+ if ( SentPositions != null )
1434+ DictionaryPool < uint , PositionSync . SentPosition > . Shared . Return ( SentPositions ) ;
14501435
1451- HashSetPool < PersonalHintElement > . Shared . Return ( HintElements ) ;
1436+ settingsIdLookup = null ;
1437+ settingsMenuLookup = null ;
1438+ settingsAssignedIdLookup = null ;
14521439
1453- HintElements = null ! ;
1454- }
1440+ removeNextFrame = null ! ;
1441+
1442+ Hints = null ;
1443+
1444+ SentRoles = null ! ;
1445+ SentPositions = null ! ;
1446+
1447+ Position = null ! ;
1448+ Rotation = null ! ;
14551449 }
14561450
14571451 #region Operators
@@ -1499,7 +1493,7 @@ public override string ToString()
14991493 /// Converts the <see cref="NetPeer"/> instance to it's corresponding <see cref="ExPlayer"/>.
15001494 /// </summary>
15011495 /// <param name="peer">The instance to convert.</param>
1502- public static implicit operator ExPlayer ( NetPeer peer )
1496+ public static implicit operator ExPlayer ? ( NetPeer peer )
15031497 => Get ( peer ) ;
15041498
15051499 /// <summary>
@@ -1521,14 +1515,14 @@ public static implicit operator ExPlayer(NetPeer peer)
15211515 /// </summary>
15221516 /// <param name="sender">The instance to convert.</param>
15231517 public static implicit operator ExPlayer ( CommandSender sender )
1524- => Get ( sender ) ;
1518+ => Get ( sender ) ! ;
15251519
15261520 /// <summary>
15271521 /// Converts the <see cref="PlayerRoleBase"/> instance to it's corresponding <see cref="ExPlayer"/>.
15281522 /// </summary>
15291523 /// <param name="role">The instance to convert.</param>
15301524 public static implicit operator ExPlayer ( PlayerRoleBase role )
1531- => ( role is null || ! role . TryGetOwner ( out var owner ) ? null : Get ( owner ) ) ;
1525+ => ( role is null || ! role . TryGetOwner ( out var owner ) ? null : Get ( owner ) ) ! ;
15321526
15331527 /// <summary>
15341528 /// Converts the <see cref="Footprint"/> instance to it's corresponding <see cref="ExPlayer"/>.
0 commit comments