actually fix magic mirrors (#28282)

This commit is contained in:
Nemanja
2024-05-26 00:46:41 -04:00
committed by GitHub
parent b177fb8179
commit d747fa98f8
2 changed files with 26 additions and 27 deletions

View File

@@ -1,7 +1,6 @@
using System.Linq;
using Content.Server.DoAfter;
using Content.Server.Humanoid;
using Content.Shared.UserInterface;
using Content.Shared.DoAfter;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Markings;
@@ -24,7 +23,6 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MagicMirrorComponent, ActivatableUIOpenAttemptEvent>(OnOpenUIAttempt);
Subs.BuiEvents<MagicMirrorComponent>(MagicMirrorUiKey.Key,
subs =>
@@ -36,7 +34,6 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
subs.Event<MagicMirrorRemoveSlotMessage>(OnTryMagicMirrorRemoveSlot);
});
SubscribeLocalEvent<MagicMirrorComponent, AfterInteractEvent>(OnMagicMirrorInteract);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorSelectDoAfterEvent>(OnSelectSlotDoAfter);
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorChangeColorDoAfterEvent>(OnChangeColorDoAfter);
@@ -44,23 +41,6 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
SubscribeLocalEvent<MagicMirrorComponent, MagicMirrorAddSlotDoAfterEvent>(OnAddSlotDoAfter);
}
private void OnMagicMirrorInteract(Entity<MagicMirrorComponent> mirror, ref AfterInteractEvent args)
{
if (!args.CanReach || args.Target == null)
return;
if (!_uiSystem.TryOpenUi(mirror.Owner, MagicMirrorUiKey.Key, args.User))
return;
UpdateInterface(mirror.Owner, args.Target.Value, mirror.Comp);
}
private void OnOpenUIAttempt(EntityUid uid, MagicMirrorComponent mirror, ActivatableUIOpenAttemptEvent args)
{
if (!HasComp<HumanoidAppearanceComponent>(args.User))
args.Cancel();
}
private void OnMagicMirrorSelect(EntityUid uid, MagicMirrorComponent component, MagicMirrorSelectMessage message)
{
if (component.Target is not { } target)
@@ -83,7 +63,8 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
BreakOnMove = true,
BreakOnHandChange = false,
NeedHand = true
}, out var doAfterId);
},
out var doAfterId);
component.DoAfter = doAfterId;
_audio.PlayPvs(component.ChangeHairSound, uid);
@@ -137,7 +118,8 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
BreakOnMove = true,
BreakOnHandChange = false,
NeedHand = true
}, out var doAfterId);
},
out var doAfterId);
component.DoAfter = doAfterId;
}
@@ -189,7 +171,8 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
BreakOnDamage = true,
BreakOnHandChange = false,
NeedHand = true
}, out var doAfterId);
},
out var doAfterId);
component.DoAfter = doAfterId;
_audio.PlayPvs(component.ChangeHairSound, uid);
@@ -241,7 +224,8 @@ public sealed class MagicMirrorSystem : SharedMagicMirrorSystem
BreakOnMove = true,
BreakOnHandChange = false,
NeedHand = true
}, out var doAfterId);
},
out var doAfterId);
component.DoAfter = doAfterId;
_audio.PlayPvs(component.ChangeHairSound, uid);