From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:37:09 +0000 (+1000) Subject: Fix magic mirror prediction (#27356) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=e1a52477706b6ebc2b4d74f5a98e6f913279e905;p=space-station-14.git Fix magic mirror prediction (#27356) --- diff --git a/Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs b/Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs index bfbf2efe4f..f6979bf8d7 100644 --- a/Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs +++ b/Content.Client/MagicMirror/MagicMirrorBoundUserInterface.cs @@ -72,9 +72,6 @@ public sealed class MagicMirrorBoundUserInterface : BoundUserInterface if (!disposing) return; - if (_window != null) - _window.OnClose -= Close; - _window?.Dispose(); } } diff --git a/Content.Client/MagicMirror/MagicMirrorSystem.cs b/Content.Client/MagicMirror/MagicMirrorSystem.cs new file mode 100644 index 0000000000..9b0b1dea0b --- /dev/null +++ b/Content.Client/MagicMirror/MagicMirrorSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared.MagicMirror; + +namespace Content.Client.MagicMirror; + +public sealed class MagicMirrorSystem : SharedMagicMirrorSystem +{ + +} diff --git a/Content.Server/MagicMirror/MagicMirrorSystem.cs b/Content.Server/MagicMirror/MagicMirrorSystem.cs index 188ff40b02..84f1f1c3e5 100644 --- a/Content.Server/MagicMirror/MagicMirrorSystem.cs +++ b/Content.Server/MagicMirror/MagicMirrorSystem.cs @@ -16,13 +16,12 @@ namespace Content.Server.MagicMirror; /// /// Allows humanoids to change their appearance mid-round. /// -public sealed class MagicMirrorSystem : EntitySystem +public sealed class MagicMirrorSystem : SharedMagicMirrorSystem { [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly MarkingManager _markings = default!; [Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!; - [Dependency] private readonly SharedInteractionSystem _interaction = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; public override void Initialize() @@ -45,16 +44,6 @@ public sealed class MagicMirrorSystem : EntitySystem SubscribeLocalEvent(OnChangeColorDoAfter); SubscribeLocalEvent(OnRemoveSlotDoAfter); SubscribeLocalEvent(OnAddSlotDoAfter); - - SubscribeLocalEvent(OnMirrorRangeCheck); - } - - private void OnMirrorRangeCheck(EntityUid uid, MagicMirrorComponent component, ref BoundUserInterfaceCheckRangeEvent args) - { - if (!Exists(component.Target) || !_interaction.InRangeUnobstructed(uid, component.Target.Value)) - { - args.Result = BoundUserInterfaceRangeResult.Fail; - } } private void OnMagicMirrorInteract(Entity mirror, ref AfterInteractEvent args) @@ -309,12 +298,15 @@ public sealed class MagicMirrorSystem : EntitySystem facialHair, humanoid.MarkingSet.PointsLeft(MarkingCategories.FacialHair) + facialHair.Count); + // TODO: Component states component.Target = targetUid; _uiSystem.SetUiState(mirrorUid, MagicMirrorUiKey.Key, state); + Dirty(mirrorUid, component); } private void OnUiClosed(Entity ent, ref BoundUIClosedEvent args) { ent.Comp.Target = null; + Dirty(ent); } } diff --git a/Content.Server/MagicMirror/MagicMirrorComponent.cs b/Content.Shared/MagicMirror/MagicMirrorComponent.cs similarity index 89% rename from Content.Server/MagicMirror/MagicMirrorComponent.cs rename to Content.Shared/MagicMirror/MagicMirrorComponent.cs index 624a381ca5..6357543905 100644 --- a/Content.Server/MagicMirror/MagicMirrorComponent.cs +++ b/Content.Shared/MagicMirror/MagicMirrorComponent.cs @@ -1,13 +1,13 @@ using Content.Shared.DoAfter; -using Content.Shared.Humanoid; using Robust.Shared.Audio; +using Robust.Shared.GameStates; -namespace Content.Server.MagicMirror; +namespace Content.Shared.MagicMirror; /// /// Allows humanoids to change their appearance mid-round. /// -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class MagicMirrorComponent : Component { [DataField] @@ -16,7 +16,7 @@ public sealed partial class MagicMirrorComponent : Component /// /// Magic mirror target, used for validating UI messages. /// - [DataField] + [DataField, AutoNetworkedField] public EntityUid? Target; /// diff --git a/Content.Shared/MagicMirror/SharedMagicMirrorSystem.cs b/Content.Shared/MagicMirror/SharedMagicMirrorSystem.cs index 0b22e02498..f9c941ffe3 100644 --- a/Content.Shared/MagicMirror/SharedMagicMirrorSystem.cs +++ b/Content.Shared/MagicMirror/SharedMagicMirrorSystem.cs @@ -1,10 +1,29 @@ using Content.Shared.DoAfter; using Content.Shared.Humanoid.Markings; -using Robust.Shared.Player; +using Content.Shared.Interaction; using Robust.Shared.Serialization; namespace Content.Shared.MagicMirror; +public abstract class SharedMagicMirrorSystem : EntitySystem +{ + [Dependency] private readonly SharedInteractionSystem _interaction = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnMirrorRangeCheck); + } + + private void OnMirrorRangeCheck(EntityUid uid, MagicMirrorComponent component, ref BoundUserInterfaceCheckRangeEvent args) + { + if (!Exists(component.Target) || !_interaction.InRangeUnobstructed(uid, component.Target.Value)) + { + args.Result = BoundUserInterfaceRangeResult.Fail; + } + } +} + [Serializable, NetSerializable] public enum MagicMirrorUiKey : byte {