Add setoutfit command (#2874)
* Add setoutfit command * Adds setoutfit as a verb and adds a proper UI to the command * Removes from AdminMenuWindow * Changes the SetOutfit verb to be a component verb instead of a global verb * Addresses reviews * Remove empty method * Remove on server aswell
This commit is contained in:
55
Content.Server/SetOutfitEui.cs
Normal file
55
Content.Server/SetOutfitEui.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Database;
|
||||
using Content.Server.Eui;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Eui;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.IoC;
|
||||
using System;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
|
||||
namespace Content.Server
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class SetOutfitEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
private readonly IEntity _target;
|
||||
public SetOutfitEui(IEntity entity)
|
||||
{
|
||||
_target = entity;
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
base.Opened();
|
||||
|
||||
StateDirty();
|
||||
_adminManager.OnPermsChanged += AdminManagerOnPermsChanged;
|
||||
}
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
return new SetOutfitEuiState
|
||||
{
|
||||
TargetEntityId = _target.Uid
|
||||
};
|
||||
}
|
||||
|
||||
private void AdminManagerOnPermsChanged(AdminPermsChangedEventArgs obj)
|
||||
{
|
||||
// Close UI if user loses +FUN.
|
||||
if (obj.Player == Player && !UserAdminFlagCheck(AdminFlags.Fun))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
private bool UserAdminFlagCheck(AdminFlags flags)
|
||||
{
|
||||
return _adminManager.HasAdminFlag(Player, flags);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user