using Content.Shared.Mind; using JetBrains.Annotations; using Robust.Shared.Audio; using Robust.Shared.Player; using Robust.Shared.Prototypes; namespace Content.Shared._DV.Tips; /// /// Shared tip system that provides the public API for showing tips to players. /// public abstract class SharedTipSystem : EntitySystem { [Dependency] protected new readonly IPrototypeManager Prototype = default!; [Dependency] private readonly ISharedPlayerManager _player = default!; [Dependency] protected readonly SharedMindSystem Mind = default!; /// /// Shows a tip to a player. /// /// EntityUid of the player to show the tip to. /// to use, wrapped in a /// Whether to ignore the DisableTips CCvar on the client. /// Optional SoundSpecifier, will play the prototype's default sound if null. [PublicAPI] public void ShowTip(EntityUid uid, ProtoId tipId, bool ignoreCvar = false, SoundSpecifier? sound = null) { if (!Prototype.TryIndex(tipId, out var tipProto)) { Log.Warning($"Attempted to show non-existent tip: {tipId}"); return; } if (!Mind.TryGetMind(uid, out _, out var mind) || !_player.TryGetSessionById(mind.UserId, out var session)) return; ShowTip(session, tipProto, ignoreCvar, sound); } /// /// Shows a tip to a player. /// /// of the player to show the tip to. /// to use, wrapped in a /// Whether to ignore the DisableTips CCvar on the client. /// Optional SoundSpecifier, will play the prototype's default sound if null. [PublicAPI] public void ShowTip(ICommonSession session, ProtoId tipId, bool ignoreCvar = false, SoundSpecifier? sound = null) { if (!Prototype.TryIndex(tipId, out var tipProto)) { Log.Warning($"Attempted to show non-existent tip: {tipId}"); return; } ShowTip(session, tipProto, ignoreCvar, sound); } /// /// Shows a tip to a player. /// /// of the player to show the tip to. /// to use. /// Whether to ignore the DisableTips CCvar on the client. /// Optional SoundSpecifier, will play the prototype's default sound if null. [PublicAPI] public void ShowTip(ICommonSession session, TipPrototype tip, bool ignoreCvar = false, SoundSpecifier? sound = null) { RaiseNetworkEvent(new ShowTipEvent(tip.ID, sound ?? tip.Sound, ignoreCvar), session); } }