1
0

NetworkPayload.cs 734 B

123456789101112131415161718192021222324
  1. using System.Diagnostics.CodeAnalysis;
  2. using Robust.Shared.Utility;
  3. namespace Content.Shared.DeviceNetwork;
  4. public sealed class NetworkPayload : Dictionary<string, object?>
  5. {
  6. /// <summary>
  7. /// Tries to get a value from the payload and checks if that value is of type T.
  8. /// </summary>
  9. /// <typeparam name="T">The type that should be casted to</typeparam>
  10. /// <returns>Whether the value was present in the payload and of the required type</returns>
  11. public bool TryGetValue<T>(string key, [NotNullWhen(true)] out T? value)
  12. {
  13. if (this.TryCastValue(key, out T? result))
  14. {
  15. value = result;
  16. return true;
  17. }
  18. value = default;
  19. return false;
  20. }
  21. }