using Content.Server.DeviceNetwork.Components; using Robust.Shared.Utility; namespace Content.Server.DeviceNetwork { /// /// A collection of constants to help with using device networks /// public static class DeviceNetworkConstants { #region Commands /// /// The key for command names /// E.g. [DeviceNetworkConstants.Command] = "ping" /// public const string Command = "command"; /// /// The command for setting a devices state /// E.g. to turn a light on or off /// public const string CmdSetState = "set_state"; /// /// The command for a device that just updated its state /// E.g. suit sensors broadcasting owners vitals state /// public const string CmdUpdatedState = "updated_state"; #endregion #region SetState /// /// Used with the command to turn a device on or off /// public const string StateEnabled = "state_enabled"; #endregion #region DisplayHelpers /// /// Converts the unsigned int to string and inserts a number before the last digit /// public static string FrequencyToString(this uint frequency) { var result = frequency.ToString(); if (result.Length <= 2) return result + ".0"; return result.Insert(result.Length - 1, "."); } /// /// Either returns the localized name representation of the corresponding /// or converts the id to string /// public static string DeviceNetIdToLocalizedName(this int id) { if (!Enum.IsDefined(typeof(DeviceNetworkComponent.DeviceNetIdDefaults), id)) return id.ToString(); var result = ((DeviceNetworkComponent.DeviceNetIdDefaults) id).ToString(); var resultKebab = "device-net-id-" + CaseConversion.PascalToKebab(result); return !Loc.TryGetString(resultKebab, out var name) ? result : name; } #endregion } }