Fix magic mirror prediction (#27356)
This commit is contained in:
@@ -72,9 +72,6 @@ public sealed class MagicMirrorBoundUserInterface : BoundUserInterface
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
if (_window != null)
|
||||
_window.OnClose -= Close;
|
||||
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
8
Content.Client/MagicMirror/MagicMirrorSystem.cs
Normal file
8
Content.Client/MagicMirror/MagicMirrorSystem.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Content.Shared.MagicMirror;
|
||||
|
||||
namespace Content.Client.MagicMirror;
|
||||
|
||||
public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -16,13 +16,12 @@ namespace Content.Server.MagicMirror;
|
||||
/// <summary>
|
||||
/// Allows humanoids to change their appearance mid-round.
|
||||
/// </summary>
|
||||
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<MagicMirrorComponent, MagicMirrorChangeColorDoAfterEvent>(OnChangeColorDoAfter);
|
||||
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorRemoveSlotDoAfterEvent>(OnRemoveSlotDoAfter);
|
||||
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorAddSlotDoAfterEvent>(OnAddSlotDoAfter);
|
||||
|
||||
SubscribeLocalEvent<MagicMirrorComponent, BoundUserInterfaceCheckRangeEvent>(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<MagicMirrorComponent> 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<MagicMirrorComponent> ent, ref BoundUIClosedEvent args)
|
||||
{
|
||||
ent.Comp.Target = null;
|
||||
Dirty(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Allows humanoids to change their appearance mid-round.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class MagicMirrorComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
@@ -16,7 +16,7 @@ public sealed partial class MagicMirrorComponent : Component
|
||||
/// <summary>
|
||||
/// Magic mirror target, used for validating UI messages.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntityUid? Target;
|
||||
|
||||
/// <summary>
|
||||
@@ -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<MagicMirrorComponent, BoundUserInterfaceCheckRangeEvent>(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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user