using Content.Client.Pointing.Components; using Content.Client.Gravity; using Content.Shared.Mobs.Systems; using Content.Shared.Pointing; using Content.Shared.Verbs; using Robust.Client.GameObjects; using DrawDepth = Content.Shared.DrawDepth.DrawDepth; namespace Content.Client.Pointing; public sealed class PointingSystem : SharedPointingSystem { [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly FloatingVisualizerSystem _floatingSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent>(AddPointingVerb); SubscribeLocalEvent(OnArrowStartup); SubscribeLocalEvent(OnArrowAnimation); SubscribeLocalEvent(OnRogueArrowStartup); } private void OnArrowAnimation(EntityUid uid, PointingArrowComponent component, AnimationCompletedEvent args) { _floatingSystem.FloatAnimation(uid, component.Offset, component.AnimationKey, component.AnimationTime); } private void AddPointingVerb(GetVerbsEvent args) { if (args.Target.IsClientSide()) return; // Really this could probably be a properly predicted event, but that requires reworking pointing. For now // I'm just adding this verb exclusively to clients so that the verb-loading pop-in on the verb menu isn't // as bad. Important for this verb seeing as its usually an option on just about any entity. if (HasComp(args.Target)) { // this is a pointing arrow. no pointing here... return; } // Can the user point? Checking mob state directly instead of some action blocker, as many action blockers are blocked for // ghosts and there is no obvious choice for pointing (unless ghosts CanEmote?). if (_mobState.IsIncapacitated(args.User)) return; // We won't check in range or visibility, as this verb is currently only executable via the context menu, // and that should already have checked that, as well as handling the FOV-toggle stuff. Verb verb = new() { Text = Loc.GetString("pointing-verb-get-data-text"), IconTexture = "/Textures/Interface/VerbIcons/point.svg.192dpi.png", ClientExclusive = true, Act = () => RaiseNetworkEvent(new PointingAttemptEvent(args.Target)) }; args.Verbs.Add(verb); } private void OnArrowStartup(EntityUid uid, PointingArrowComponent component, ComponentStartup args) { if (TryComp(uid, out var sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; } _floatingSystem.FloatAnimation(uid, component.Offset, component.AnimationKey, component.AnimationTime); } private void OnRogueArrowStartup(EntityUid uid, RoguePointingArrowComponent arrow, ComponentStartup args) { if (TryComp(uid, out var sprite)) { sprite.DrawDepth = (int) DrawDepth.Overlays; sprite.NoRotation = false; } } }