* Rename SolutionContainerCaps -> Capability * Move IExamine event to Chemistry System. * ECS the ISolutionChange into SolutionChangeEvent * Unify SolutionContainer into a single shared component * Replace ISolutionInteraction with SolutionContainerComponent * Move all methods from SolutionContainer to ChemistrySystem * Refactor EntitySystem calls to Dependencies * Refactor SolutionContainer to SolutionManager * Fix yamls * Fix test fails * Fix post merge issues * Fix various issues with SolutionManager * More fixes * Fix more components * Fix events not being directed * Fixes for Hypospray * Separate removal and iteration on Metabolism * Fix creampie problems * Address some of sloth's issues * Refactors for Systems * Refactored solution location * Fix tests * Address more sloth issues * Fix dependency * Fix merge conflicts * Add xmldocs for Capabilities components * Remove HasSolution/TryGetDefaultSolution and Add/Remove Drainable/Refillable * Replace Grindable/Juiceable with Extractable * Refactor field names * Fix Drainable * Fix some issues with spillable and injector * Fix issues with Grinder * Fix Beaker having duplicate solutions * Fix foaming * Address some MGS issues * Fix Uid issues * Fix errors in solution Tranfer * Fixed some extra values constant values * Cola is drinkable now
151 lines
5.6 KiB
C#
151 lines
5.6 KiB
C#
using Content.Server.Administration.Managers;
|
|
using Content.Server.EUI;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Chemistry.Reagent;
|
|
using Content.Shared.Eui;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Content.Server.Administration.Verbs
|
|
{
|
|
[GlobalVerb]
|
|
internal sealed class AdminAddReagentVerb : GlobalVerb
|
|
{
|
|
public override bool RequireInteractionRange => false;
|
|
public override bool BlockedByContainers => false;
|
|
|
|
private const AdminFlags ReqFlags = AdminFlags.Fun;
|
|
|
|
private static void OpenAddReagentMenu(IPlayerSession player, IEntity target)
|
|
{
|
|
var euiMgr = IoCManager.Resolve<EuiManager>();
|
|
euiMgr.OpenEui(new AdminAddReagentEui(target), player);
|
|
}
|
|
|
|
public override void GetData(IEntity user, IEntity target, VerbData data)
|
|
{
|
|
// ISolutionInteractionsComponent doesn't exactly have an interface for "admin tries to refill this", so...
|
|
// Still have a path for SolutionContainerComponent in case it doesn't allow direct refilling.
|
|
if (!(target.HasComponent<SolutionContainerManagerComponent>()
|
|
&& target.HasComponent<InjectableSolutionComponent>()))
|
|
{
|
|
data.Visibility = VerbVisibility.Invisible;
|
|
return;
|
|
}
|
|
|
|
data.Text = Loc.GetString("admin-add-reagent-verb-get-data-text");
|
|
data.IconTexture = "/Textures/Interface/VerbIcons/spill.svg.192dpi.png";
|
|
data.CategoryData = VerbCategories.Debug;
|
|
data.Visibility = VerbVisibility.Invisible;
|
|
|
|
var adminManager = IoCManager.Resolve<IAdminManager>();
|
|
|
|
if (user.TryGetComponent<ActorComponent>(out var player))
|
|
{
|
|
if (adminManager.HasAdminFlag(player.PlayerSession, ReqFlags))
|
|
{
|
|
data.Visibility = VerbVisibility.Visible;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Activate(IEntity user, IEntity target)
|
|
{
|
|
var groupController = IoCManager.Resolve<IAdminManager>();
|
|
if (user.TryGetComponent<ActorComponent>(out var player))
|
|
{
|
|
if (groupController.HasAdminFlag(player.PlayerSession, ReqFlags))
|
|
OpenAddReagentMenu(player.PlayerSession, target);
|
|
}
|
|
}
|
|
|
|
private sealed class AdminAddReagentEui : BaseEui
|
|
{
|
|
private readonly IEntity _target;
|
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
|
|
|
public AdminAddReagentEui(IEntity target)
|
|
{
|
|
_target = target;
|
|
|
|
IoCManager.InjectDependencies(this);
|
|
}
|
|
|
|
public override void Opened()
|
|
{
|
|
StateDirty();
|
|
}
|
|
|
|
public override EuiStateBase GetNewState()
|
|
{
|
|
if (EntitySystem.Get<SolutionContainerSystem>()
|
|
.TryGetSolution(_target, "default", out var container))
|
|
{
|
|
return new AdminAddReagentEuiState
|
|
{
|
|
CurVolume = container.CurrentVolume,
|
|
MaxVolume = container.MaxVolume
|
|
};
|
|
}
|
|
|
|
return new AdminAddReagentEuiState
|
|
{
|
|
CurVolume = ReagentUnit.Zero,
|
|
MaxVolume = ReagentUnit.Zero
|
|
};
|
|
}
|
|
|
|
public override void HandleMessage(EuiMessageBase msg)
|
|
{
|
|
switch (msg)
|
|
{
|
|
case AdminAddReagentEuiMsg.Close:
|
|
Close();
|
|
break;
|
|
case AdminAddReagentEuiMsg.DoAdd doAdd:
|
|
// Double check that user wasn't de-adminned in the mean time...
|
|
// Or the target was deleted.
|
|
if (!_adminManager.HasAdminFlag(Player, ReqFlags) || _target.Deleted)
|
|
{
|
|
Close();
|
|
return;
|
|
}
|
|
|
|
var id = doAdd.ReagentId;
|
|
var amount = doAdd.Amount;
|
|
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
|
|
|
|
if (_target.TryGetComponent(out InjectableSolutionComponent? injectable)
|
|
&& solutionsSys.TryGetSolution(_target, injectable.Name, out var targetSolution))
|
|
{
|
|
var solution = new Solution(id, amount);
|
|
solutionsSys.Inject(_target.Uid, targetSolution, solution);
|
|
}
|
|
else
|
|
{
|
|
//TODO decide how to find the solution
|
|
if (solutionsSys.TryGetSolution(_target, "default", out var solution))
|
|
{
|
|
solutionsSys.TryAddReagent(_target.Uid,solution, id, amount, out _);
|
|
}
|
|
}
|
|
|
|
StateDirty();
|
|
|
|
if (doAdd.CloseAfter)
|
|
Close();
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|