Fix 3000 errors
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Items;
|
||||
using Content.Server.Sprite;
|
||||
using Content.Server.Labels.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.ActionBlocker;
|
||||
@@ -18,15 +17,12 @@ using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Log;
|
||||
using Content.Server.Labels.Components;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
@@ -41,6 +37,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[ComponentReference(typeof(SharedChemMasterComponent))]
|
||||
public class ChemMasterComponent : SharedChemMasterComponent, IActivate
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private uint _pillType = 1;
|
||||
|
||||
@@ -51,7 +49,7 @@ namespace Content.Server.Chemistry.Components
|
||||
private bool _bufferModeTransfer = true;
|
||||
|
||||
[ViewVariables]
|
||||
private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
|
||||
[ViewVariables]
|
||||
private Solution BufferSolution => _bufferSolution ??= EntitySystem.Get<SolutionContainerSystem>().EnsureSolution(Owner, SolutionName);
|
||||
@@ -107,7 +105,7 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <param name="obj">A user interface message from the client.</param>
|
||||
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
|
||||
{
|
||||
if (obj.Session.AttachedEntity == null)
|
||||
if (obj.Session.AttachedEntity is not {Valid: true} player)
|
||||
return;
|
||||
|
||||
var msg = (UiActionMessage) obj.Message;
|
||||
@@ -117,13 +115,13 @@ namespace Content.Server.Chemistry.Components
|
||||
_ => true,
|
||||
};
|
||||
|
||||
if (!PlayerCanUseChemMaster(obj.Session.AttachedEntity, needsPower))
|
||||
if (!PlayerCanUseChemMaster(player, needsPower))
|
||||
return;
|
||||
|
||||
switch (msg.Action)
|
||||
{
|
||||
case UiAction.Eject:
|
||||
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, obj.Session.AttachedEntityUid);
|
||||
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, player);
|
||||
break;
|
||||
case UiAction.ChemButton:
|
||||
TransferReagent(msg.Id, msg.Amount, msg.IsBuffer);
|
||||
@@ -143,7 +141,7 @@ namespace Content.Server.Chemistry.Components
|
||||
case UiAction.CreatePills:
|
||||
case UiAction.CreateBottles:
|
||||
_label = msg.Label;
|
||||
TryCreatePackage(obj.Session.AttachedEntity, msg.Action, msg.Label, msg.PillAmount, msg.BottleAmount);
|
||||
TryCreatePackage(player, msg.Action, msg.Label, msg.PillAmount, msg.BottleAmount);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
@@ -158,10 +156,10 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <param name="playerEntity">The player entity.</param>
|
||||
/// <param name="needsPower">whether the device requires power</param>
|
||||
/// <returns>Returns true if the entity can use the chem master, and false if it cannot.</returns>
|
||||
private bool PlayerCanUseChemMaster(IEntity? playerEntity, bool needsPower = true)
|
||||
private bool PlayerCanUseChemMaster(EntityUid playerEntity, bool needsPower = true)
|
||||
{
|
||||
//Need player entity to check if they are still able to use the chem master
|
||||
if (playerEntity == null)
|
||||
if (playerEntity == default)
|
||||
return false;
|
||||
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
@@ -182,18 +180,18 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <returns>Returns a <see cref="SharedChemMasterComponent.ChemMasterBoundUserInterfaceState"/></returns>
|
||||
private ChemMasterBoundUserInterfaceState GetUserInterfaceState()
|
||||
{
|
||||
var beaker = BeakerSlot.Item;
|
||||
if (beaker is null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
if (BeakerSlot.Item is not {Valid: true} beaker ||
|
||||
!_entities.TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var beakerSolution))
|
||||
{
|
||||
return new ChemMasterBoundUserInterfaceState(Powered, false, FixedPoint2.New(0), FixedPoint2.New(0),
|
||||
"", _label, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName, new List<Solution.ReagentQuantity>(), BufferSolution.Contents, _bufferModeTransfer,
|
||||
"", _label, _entities.GetComponent<MetaDataComponent>(Owner).EntityName, new List<Solution.ReagentQuantity>(), BufferSolution.Contents, _bufferModeTransfer,
|
||||
BufferSolution.TotalVolume, _pillType);
|
||||
}
|
||||
|
||||
return new ChemMasterBoundUserInterfaceState(Powered, true, beakerSolution.CurrentVolume,
|
||||
beakerSolution.MaxVolume,
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(beaker).EntityName, _label, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName, beakerSolution.Contents, BufferSolution.Contents, _bufferModeTransfer,
|
||||
_entities.GetComponent<MetaDataComponent>(beaker).EntityName, _label, _entities.GetComponent<MetaDataComponent>(Owner).EntityName, beakerSolution.Contents, BufferSolution.Contents, _bufferModeTransfer,
|
||||
BufferSolution.TotalVolume, _pillType);
|
||||
}
|
||||
|
||||
@@ -205,10 +203,11 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
private void TransferReagent(string id, FixedPoint2 amount, bool isBuffer)
|
||||
{
|
||||
if (!BeakerSlot.HasItem && _bufferModeTransfer) return;
|
||||
var beaker = BeakerSlot.Item;
|
||||
if (!BeakerSlot.HasItem && _bufferModeTransfer)
|
||||
return;
|
||||
|
||||
if (beaker is null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
if (BeakerSlot.Item is not {Valid: true} beaker ||
|
||||
!_entities.TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var beakerSolution))
|
||||
return;
|
||||
|
||||
@@ -282,7 +281,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return _bufferSolution.Contents[_bufferSolution.Contents.Count - 1].ReagentId;
|
||||
}
|
||||
|
||||
private void TryCreatePackage(IEntity user, UiAction action, string label, int pillAmount, int bottleAmount)
|
||||
private void TryCreatePackage(EntityUid user, UiAction action, string label, int pillAmount, int bottleAmount)
|
||||
{
|
||||
if (BufferSolution.TotalVolume == 0)
|
||||
{
|
||||
@@ -302,13 +301,13 @@ namespace Content.Server.Chemistry.Components
|
||||
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(30));
|
||||
for (int i = 0; i < bottleAmount; i++)
|
||||
{
|
||||
var bottle = IoCManager.Resolve<IEntityManager>().SpawnEntity("ChemistryEmptyBottle01", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
var bottle = _entities.SpawnEntity("ChemistryEmptyBottle01", _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
//Adding label
|
||||
LabelComponent labelComponent = bottle.EnsureComponent<LabelComponent>();
|
||||
labelComponent.OriginalName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(bottle).EntityName;
|
||||
string val = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(bottle).EntityName + $" ({label})";
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(bottle).EntityName = val;
|
||||
labelComponent.OriginalName = _entities.GetComponent<MetaDataComponent>(bottle).EntityName;
|
||||
string val = _entities.GetComponent<MetaDataComponent>(bottle).EntityName + $" ({label})";
|
||||
_entities.GetComponent<MetaDataComponent>(bottle).EntityName = val;
|
||||
labelComponent.CurrentLabel = label;
|
||||
|
||||
var bufferSolution = BufferSolution.SplitSolution(actualVolume);
|
||||
@@ -317,8 +316,8 @@ namespace Content.Server.Chemistry.Components
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(bottle, bottleSolution, bufferSolution);
|
||||
|
||||
//Try to give them the bottle
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user, out var hands) &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(bottle, out var item))
|
||||
if (_entities.TryGetComponent<HandsComponent?>(user, out var hands) &&
|
||||
_entities.TryGetComponent<ItemComponent?>(bottle, out var item))
|
||||
{
|
||||
if (hands.CanPutInHand(item))
|
||||
{
|
||||
@@ -328,7 +327,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
//Put it on the floor
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(bottle).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).Coordinates;
|
||||
_entities.GetComponent<TransformComponent>(bottle).Coordinates = _entities.GetComponent<TransformComponent>(user).Coordinates;
|
||||
//Give it an offset
|
||||
bottle.RandomOffset(0.2f);
|
||||
}
|
||||
@@ -345,13 +344,13 @@ namespace Content.Server.Chemistry.Components
|
||||
var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(50));
|
||||
for (int i = 0; i < pillAmount; i++)
|
||||
{
|
||||
var pill = IoCManager.Resolve<IEntityManager>().SpawnEntity("pill", IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
var pill = _entities.SpawnEntity("pill", _entities.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
|
||||
//Adding label
|
||||
LabelComponent labelComponent = pill.EnsureComponent<LabelComponent>();
|
||||
labelComponent.OriginalName = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pill).EntityName;
|
||||
string val = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pill).EntityName + $" ({label})";
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pill).EntityName = val;
|
||||
labelComponent.OriginalName = _entities.GetComponent<MetaDataComponent>(pill).EntityName;
|
||||
string val = _entities.GetComponent<MetaDataComponent>(pill).EntityName + $" ({label})";
|
||||
_entities.GetComponent<MetaDataComponent>(pill).EntityName = val;
|
||||
labelComponent.CurrentLabel = label;
|
||||
|
||||
var bufferSolution = BufferSolution.SplitSolution(actualVolume);
|
||||
@@ -359,15 +358,15 @@ namespace Content.Server.Chemistry.Components
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(pill, pillSolution, bufferSolution);
|
||||
|
||||
//Change pill Sprite component state
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pill, out SpriteComponent? sprite))
|
||||
if (!_entities.TryGetComponent(pill, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
sprite?.LayerSetState(0, "pill" + _pillType);
|
||||
|
||||
//Try to give them the bottle
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<HandsComponent?>(user, out var hands) &&
|
||||
IoCManager.Resolve<IEntityManager>().TryGetComponent<ItemComponent?>(pill, out var item))
|
||||
if (_entities.TryGetComponent<HandsComponent?>(user, out var hands) &&
|
||||
_entities.TryGetComponent<ItemComponent?>(pill, out var item))
|
||||
{
|
||||
if (hands.CanPutInHand(item))
|
||||
{
|
||||
@@ -377,7 +376,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
//Put it on the floor
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pill).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).Coordinates;
|
||||
_entities.GetComponent<TransformComponent>(pill).Coordinates = _entities.GetComponent<TransformComponent>(user).Coordinates;
|
||||
//Give it an offset
|
||||
pill.RandomOffset(0.2f);
|
||||
}
|
||||
@@ -395,12 +394,12 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <param name="args">Data relevant to the event such as the actor which triggered it.</param>
|
||||
void IActivate.Activate(ActivateEventArgs args)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
|
||||
if (!_entities.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out HandsComponent? hands))
|
||||
if (!_entities.TryGetComponent(args.User, out HandsComponent? hands))
|
||||
{
|
||||
Owner.PopupMessage(args.User, Loc.GetString("chem-master-component-activate-no-hands"));
|
||||
return;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReactWithEntity(IEntity entity, double solutionFraction)
|
||||
protected override void ReactWithEntity(EntityUid entity, double solutionFraction)
|
||||
{
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
return;
|
||||
@@ -82,7 +82,7 @@ namespace Content.Server.Chemistry.Components
|
||||
IoCManager.Resolve<IEntityManager>().SpawnEntity(_foamedMetalPrototype, IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
}
|
||||
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity((EntityUid) Owner);
|
||||
IoCManager.Resolve<IEntityManager>().QueueDeleteEntity(Owner);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -41,9 +40,9 @@ namespace Content.Server.Chemistry.Components
|
||||
Dirty();
|
||||
}
|
||||
|
||||
public bool TryDoInject(IEntity? target, IEntity user)
|
||||
public bool TryDoInject(EntityUid? target, EntityUid user)
|
||||
{
|
||||
if (target == null || !EligibleEntity(target))
|
||||
if (target == default || !EligibleEntity(target.Value))
|
||||
return false;
|
||||
|
||||
string? msgFormat = null;
|
||||
@@ -67,7 +66,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!solutionsSys.TryGetInjectableSolution(target, out var targetSolution))
|
||||
if (!solutionsSys.TryGetInjectableSolution(target.Value, out var targetSolution))
|
||||
{
|
||||
user.PopupMessage(user,
|
||||
Loc.GetString("hypospray-cant-inject", ("target", target)));
|
||||
@@ -78,9 +77,9 @@ namespace Content.Server.Chemistry.Components
|
||||
("other", target)));
|
||||
if (target != user)
|
||||
{
|
||||
target.PopupMessage(Loc.GetString("hypospray-component-feel-prick-message"));
|
||||
target.Value.PopupMessage(Loc.GetString("hypospray-component-feel-prick-message"));
|
||||
var meleeSys = EntitySystem.Get<MeleeWeaponSystem>();
|
||||
var angle = Angle.FromWorldVec(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target).WorldPosition - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition);
|
||||
var angle = Angle.FromWorldVec(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(target.Value).WorldPosition - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(user).WorldPosition);
|
||||
meleeSys.SendLunge(angle, user);
|
||||
}
|
||||
|
||||
@@ -107,11 +106,11 @@ namespace Content.Server.Chemistry.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
removedSolution.DoEntityReaction(target, ReactionMethod.Injection);
|
||||
removedSolution.DoEntityReaction(target.Value, ReactionMethod.Injection);
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(target, targetSolution, removedSolution);
|
||||
EntitySystem.Get<SolutionContainerSystem>().TryAddSolution(target.Value, targetSolution, removedSolution);
|
||||
|
||||
static bool EligibleEntity(IEntity entity)
|
||||
static bool EligibleEntity(EntityUid entity)
|
||||
{
|
||||
// TODO: Does checking for BodyComponent make sense as a "can be hypospray'd" tag?
|
||||
// In SS13 the hypospray ONLY works on mobs, NOT beakers or anything else.
|
||||
|
||||
@@ -4,7 +4,6 @@ using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
@@ -14,7 +13,6 @@ using Content.Shared.Popups;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -28,6 +26,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[RegisterComponent]
|
||||
public class InjectorComponent : SharedInjectorComponent, IAfterInteract, IUse
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public const string SolutionName = "injector";
|
||||
|
||||
/// <summary>
|
||||
@@ -81,7 +81,7 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <summary>
|
||||
/// Toggle between draw/inject state if applicable
|
||||
/// </summary>
|
||||
private void Toggle(IEntity user)
|
||||
private void Toggle(EntityUid user)
|
||||
{
|
||||
if (_injectOnly)
|
||||
{
|
||||
@@ -117,26 +117,24 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
|
||||
//Make sure we have the attacking entity
|
||||
if (eventArgs.Target == null || !IoCManager.Resolve<IEntityManager>().HasComponent<SolutionContainerManagerComponent>(Owner))
|
||||
if (eventArgs.Target is not {Valid: true} target ||
|
||||
!_entities.HasComponent<SolutionContainerManagerComponent>(Owner))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var targetEntity = eventArgs.Target;
|
||||
|
||||
|
||||
// Handle injecting/drawing for solutions
|
||||
if (ToggleState == InjectorToggleMode.Inject)
|
||||
{
|
||||
if (solutionsSys.TryGetInjectableSolution(targetEntity, out var injectableSolution))
|
||||
if (solutionsSys.TryGetInjectableSolution(target, out var injectableSolution))
|
||||
{
|
||||
TryInject(targetEntity, injectableSolution, eventArgs.User, false);
|
||||
TryInject(target, injectableSolution, eventArgs.User, false);
|
||||
}
|
||||
else if (solutionsSys.TryGetRefillableSolution(targetEntity, out var refillableSolution))
|
||||
else if (solutionsSys.TryGetRefillableSolution(target, out var refillableSolution))
|
||||
{
|
||||
TryInject(targetEntity, refillableSolution, eventArgs.User, true);
|
||||
TryInject(target, refillableSolution, eventArgs.User, true);
|
||||
}
|
||||
else if (IoCManager.Resolve<IEntityManager>().TryGetComponent(targetEntity, out BloodstreamComponent? bloodstream))
|
||||
else if (_entities.TryGetComponent(target, out BloodstreamComponent? bloodstream))
|
||||
{
|
||||
TryInjectIntoBloodstream(bloodstream, eventArgs.User);
|
||||
}
|
||||
@@ -144,20 +142,20 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
eventArgs.User.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("injector-component-cannot-transfer-message",
|
||||
("target", targetEntity)));
|
||||
("target", target)));
|
||||
}
|
||||
}
|
||||
else if (ToggleState == InjectorToggleMode.Draw)
|
||||
{
|
||||
if (solutionsSys.TryGetDrawableSolution(targetEntity, out var drawableSolution))
|
||||
if (solutionsSys.TryGetDrawableSolution(target, out var drawableSolution))
|
||||
{
|
||||
TryDraw(targetEntity, drawableSolution, eventArgs.User);
|
||||
TryDraw(target, drawableSolution, eventArgs.User);
|
||||
}
|
||||
else
|
||||
{
|
||||
eventArgs.User.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("injector-component-cannot-draw-message",
|
||||
("target", targetEntity)));
|
||||
("target", target)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +173,7 @@ namespace Content.Server.Chemistry.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryInjectIntoBloodstream(BloodstreamComponent targetBloodstream, IEntity user)
|
||||
private void TryInjectIntoBloodstream(BloodstreamComponent targetBloodstream, EntityUid user)
|
||||
{
|
||||
// Get transfer amount. May be smaller than _transferAmount if not enough room
|
||||
var realTransferAmount = FixedPoint2.Min(_transferAmount, targetBloodstream.Solution.AvailableVolume);
|
||||
@@ -204,7 +202,7 @@ namespace Content.Server.Chemistry.Components
|
||||
AfterInject();
|
||||
}
|
||||
|
||||
private void TryInject(IEntity targetEntity, Solution targetSolution, IEntity user, bool asRefill)
|
||||
private void TryInject(EntityUid targetEntity, Solution targetSolution, EntityUid user, bool asRefill)
|
||||
{
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)
|
||||
|| solution.CurrentVolume == 0)
|
||||
@@ -266,7 +264,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void TryDraw(IEntity targetEntity, Solution targetSolution, IEntity user)
|
||||
private void TryDraw(EntityUid targetEntity, Solution targetSolution, EntityUid user)
|
||||
{
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)
|
||||
|| solution.AvailableVolume == 0)
|
||||
@@ -304,7 +302,7 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
|
||||
_entities.EntitySysManager.GetEntitySystem<SolutionContainerSystem>()
|
||||
.TryGetSolution(Owner, SolutionName, out var solution);
|
||||
|
||||
var currentVolume = solution?.CurrentVolume ?? FixedPoint2.Zero;
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Content.Server.Chemistry.Components
|
||||
public static string SolutionName = "reagent";
|
||||
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[ViewVariables] [DataField("pack")] private string _packPrototypeId = "";
|
||||
|
||||
@@ -63,7 +64,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
[ViewVariables]
|
||||
private bool Powered => !IoCManager.Resolve<IEntityManager>().TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
private bool Powered => !_entities.TryGetComponent(Owner, out ApcPowerReceiverComponent? receiver) || receiver.Powered;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(ReagentDispenserUiKey.Key);
|
||||
|
||||
@@ -142,13 +143,13 @@ namespace Content.Server.Chemistry.Components
|
||||
_ => true,
|
||||
};
|
||||
|
||||
if (!PlayerCanUseDispenser(obj.Session.AttachedEntity, needsPower))
|
||||
if (!PlayerCanUseDispenser(obj.Session.AttachedEntity.Value, needsPower))
|
||||
return;
|
||||
|
||||
switch (msg.Button)
|
||||
{
|
||||
case UiButton.Eject:
|
||||
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, obj.Session.AttachedEntityUid);
|
||||
EntitySystem.Get<ItemSlotsSystem>().TryEjectToHands(((IComponent) this).Owner, BeakerSlot, obj.Session.AttachedEntity);
|
||||
break;
|
||||
case UiButton.Clear:
|
||||
TryClear();
|
||||
@@ -200,7 +201,7 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
/// <param name="playerEntity">The player entity.</param>
|
||||
/// <returns>Returns true if the entity can use the dispenser, and false if it cannot.</returns>
|
||||
private bool PlayerCanUseDispenser(IEntity? playerEntity, bool needsPower = true)
|
||||
private bool PlayerCanUseDispenser(EntityUid? playerEntity, bool needsPower = true)
|
||||
{
|
||||
//Need player entity to check if they are still able to use the dispenser
|
||||
if (playerEntity == null)
|
||||
@@ -209,7 +210,7 @@ namespace Content.Server.Chemistry.Components
|
||||
var actionBlocker = EntitySystem.Get<ActionBlockerSystem>();
|
||||
|
||||
//Check if player can interact in their current state
|
||||
if (!actionBlocker.CanInteract(playerEntity) || !actionBlocker.CanUse(playerEntity))
|
||||
if (!actionBlocker.CanInteract(playerEntity.Value) || !actionBlocker.CanUse(playerEntity.Value))
|
||||
return false;
|
||||
//Check if device is powered
|
||||
if (needsPower && !Powered)
|
||||
@@ -224,18 +225,18 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <returns>Returns a <see cref="SharedReagentDispenserComponent.ReagentDispenserBoundUserInterfaceState"/></returns>
|
||||
private ReagentDispenserBoundUserInterfaceState GetUserInterfaceState()
|
||||
{
|
||||
var beaker = BeakerSlot.Item;
|
||||
if (beaker == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
if (BeakerSlot.Item is not {Valid: true} beaker ||
|
||||
!_entities.TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var solution))
|
||||
{
|
||||
return new ReagentDispenserBoundUserInterfaceState(Powered, false, FixedPoint2.New(0),
|
||||
FixedPoint2.New(0),
|
||||
string.Empty, Inventory, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName, null, _dispenseAmount);
|
||||
string.Empty, Inventory, _entities.GetComponent<MetaDataComponent>(Owner).EntityName, null, _dispenseAmount);
|
||||
}
|
||||
|
||||
return new ReagentDispenserBoundUserInterfaceState(Powered, true, solution.CurrentVolume,
|
||||
solution.MaxVolume,
|
||||
IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(beaker).EntityName, Inventory, IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityName, solution.Contents.ToList(), _dispenseAmount);
|
||||
_entities.GetComponent<MetaDataComponent>(beaker).EntityName, Inventory, _entities.GetComponent<MetaDataComponent>(Owner).EntityName, solution.Contents.ToList(), _dispenseAmount);
|
||||
}
|
||||
|
||||
public void UpdateUserInterface()
|
||||
@@ -249,11 +250,9 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
private void TryClear()
|
||||
{
|
||||
var beaker = BeakerSlot.Item;
|
||||
|
||||
if (beaker == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(beaker, fits.Solution, out var solution))
|
||||
if (BeakerSlot.Item is not {Valid: true} beaker ||
|
||||
!_entities.TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var solution))
|
||||
return;
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>().RemoveAllSolution(beaker, solution);
|
||||
@@ -267,11 +266,9 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <param name="dispenseIndex">The index of the reagent in <c>Inventory</c>.</param>
|
||||
private void TryDispense(int dispenseIndex)
|
||||
{
|
||||
var beaker = BeakerSlot.Item;
|
||||
|
||||
if (beaker is null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(beaker, out FitsInDispenserComponent? fits)
|
||||
|| !EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryGetSolution(beaker, fits.Solution, out var solution)) return;
|
||||
if (BeakerSlot.Item is not {Valid: true} beaker ||
|
||||
!_entities.TryGetComponent(beaker, out FitsInDispenserComponent? fits) ||
|
||||
!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(beaker, fits.Solution, out var solution)) return;
|
||||
|
||||
EntitySystem.Get<SolutionContainerSystem>()
|
||||
.TryAddReagent(beaker, solution, Inventory[dispenseIndex].ID, _dispenseAmount, out _);
|
||||
@@ -285,12 +282,12 @@ namespace Content.Server.Chemistry.Components
|
||||
/// <param name="args">Data relevant to the event such as the actor which triggered it.</param>
|
||||
void IActivate.Activate(ActivateEventArgs args)
|
||||
{
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out ActorComponent? actor))
|
||||
if (!_entities.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(args.User, out HandsComponent? hands))
|
||||
if (!_entities.TryGetComponent(args.User, out HandsComponent? hands))
|
||||
{
|
||||
Owner.PopupMessage(args.User, Loc.GetString("reagent-dispenser-component-activate-no-hands"));
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ReactWithEntity(IEntity entity, double solutionFraction)
|
||||
protected override void ReactWithEntity(EntityUid entity, double solutionFraction)
|
||||
{
|
||||
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution))
|
||||
return;
|
||||
@@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.Components
|
||||
{
|
||||
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityLifeStage) >= EntityLifeStage.Deleted)
|
||||
return;
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) Owner);
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity(Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
[Dependency] protected readonly IMapManager MapManager = default!;
|
||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public int Amount { get; set; }
|
||||
public SolutionAreaEffectInceptionComponent? Inception { get; set; }
|
||||
|
||||
@@ -46,11 +48,11 @@ namespace Content.Server.Chemistry.Components
|
||||
if (Inception != null)
|
||||
return;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().HasComponent<SolutionAreaEffectInceptionComponent>(Owner))
|
||||
if (_entities.HasComponent<SolutionAreaEffectInceptionComponent>(Owner))
|
||||
return;
|
||||
|
||||
Amount = amount;
|
||||
var inception = IoCManager.Resolve<IEntityManager>().AddComponent<SolutionAreaEffectInceptionComponent>(Owner);
|
||||
var inception = _entities.AddComponent<SolutionAreaEffectInceptionComponent>(Owner);
|
||||
|
||||
inception.Add(this);
|
||||
inception.Setup(amount, duration, spreadDelay, removeDelay);
|
||||
@@ -62,7 +64,7 @@ namespace Content.Server.Chemistry.Components
|
||||
/// </summary>
|
||||
public void Spread()
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype == null)
|
||||
if (_entities.GetComponent<MetaDataComponent>(Owner).EntityPrototype == null)
|
||||
{
|
||||
Logger.Error("AreaEffectComponent needs its owner to be spawned by a prototype.");
|
||||
return;
|
||||
@@ -70,24 +72,26 @@ namespace Content.Server.Chemistry.Components
|
||||
|
||||
void SpreadToDir(Direction dir)
|
||||
{
|
||||
var grid = MapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
|
||||
var coords = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
var grid = MapManager.GetGrid(_entities.GetComponent<TransformComponent>(Owner).GridID);
|
||||
var coords = _entities.GetComponent<TransformComponent>(Owner).Coordinates;
|
||||
foreach (var neighbor in grid.GetInDir(coords, dir))
|
||||
{
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(neighbor,
|
||||
if (_entities.TryGetComponent(neighbor,
|
||||
out SolutionAreaEffectComponent? comp) && comp.Inception == Inception)
|
||||
return;
|
||||
|
||||
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(neighbor,
|
||||
if (_entities.TryGetComponent(neighbor,
|
||||
out AirtightComponent? airtight) && airtight.AirBlocked)
|
||||
return;
|
||||
}
|
||||
|
||||
var newEffect = IoCManager.Resolve<IEntityManager>().SpawnEntity(IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner).EntityPrototype.ID, grid.DirectionToGrid(coords, dir));
|
||||
var newEffect = _entities.SpawnEntity(
|
||||
_entities.GetComponent<MetaDataComponent>(Owner).EntityPrototype?.ID,
|
||||
grid.DirectionToGrid(coords, dir));
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(newEffect, out SolutionAreaEffectComponent? effectComponent))
|
||||
if (!_entities.TryGetComponent(newEffect, out SolutionAreaEffectComponent? effectComponent))
|
||||
{
|
||||
IoCManager.Resolve<IEntityManager>().DeleteEntity((EntityUid) newEffect);
|
||||
_entities.DeleteEntity(newEffect);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -132,8 +136,8 @@ namespace Content.Server.Chemistry.Components
|
||||
return;
|
||||
|
||||
var chemistry = EntitySystem.Get<ReactiveSystem>();
|
||||
var mapGrid = MapManager.GetGrid(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).GridID);
|
||||
var tile = mapGrid.GetTileRef(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Owner).Coordinates.ToVector2i(IoCManager.Resolve<IEntityManager>(), MapManager));
|
||||
var mapGrid = MapManager.GetGrid(_entities.GetComponent<TransformComponent>(Owner).GridID);
|
||||
var tile = mapGrid.GetTileRef(_entities.GetComponent<TransformComponent>(Owner).Coordinates.ToVector2i(_entities, MapManager));
|
||||
|
||||
var solutionFraction = 1 / Math.Floor(averageExposures);
|
||||
|
||||
@@ -164,7 +168,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void ReactWithEntity(IEntity entity, double solutionFraction);
|
||||
protected abstract void ReactWithEntity(EntityUid entity, double solutionFraction);
|
||||
|
||||
public void TryAddSolution(Solution solution)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
@@ -25,6 +24,8 @@ namespace Content.Server.Chemistry.Components
|
||||
[RegisterComponent]
|
||||
public sealed class SolutionTransferComponent : Component, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
// Behavior is as such:
|
||||
// If it's a reagent tank, TAKE reagent.
|
||||
// If it's anything else, GIVE reagent.
|
||||
@@ -116,21 +117,21 @@ namespace Content.Server.Chemistry.Components
|
||||
if (!eventArgs.InRangeUnobstructed() || eventArgs.Target == null)
|
||||
return false;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<SolutionContainerManagerComponent>(Owner))
|
||||
if (!_entities.HasComponent<SolutionContainerManagerComponent>(Owner))
|
||||
return false;
|
||||
|
||||
var target = eventArgs.Target!;
|
||||
if (!IoCManager.Resolve<IEntityManager>().HasComponent<SolutionContainerManagerComponent>(target))
|
||||
var target = eventArgs.Target!.Value;
|
||||
if (!_entities.HasComponent<SolutionContainerManagerComponent>(target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (CanReceive && IoCManager.Resolve<IEntityManager>().TryGetComponent(target, out ReagentTankComponent? tank)
|
||||
if (CanReceive && _entities.TryGetComponent(target, out ReagentTankComponent? tank)
|
||||
&& solutionsSys.TryGetRefillableSolution(Owner, out var ownerRefill)
|
||||
&& solutionsSys.TryGetDrainableSolution(eventArgs.Target, out var targetDrain))
|
||||
&& solutionsSys.TryGetDrainableSolution(target, out var targetDrain))
|
||||
{
|
||||
var transferred = DoTransfer(eventArgs.User, eventArgs.Target, targetDrain, Owner, ownerRefill, tank.TransferAmount);
|
||||
var transferred = DoTransfer(eventArgs.User, target, targetDrain, Owner, ownerRefill, tank.TransferAmount);
|
||||
if (transferred > 0)
|
||||
{
|
||||
var toTheBrim = ownerRefill.AvailableVolume == 0;
|
||||
@@ -144,7 +145,7 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
}
|
||||
|
||||
if (CanSend && solutionsSys.TryGetRefillableSolution(eventArgs.Target, out var targetRefill)
|
||||
if (CanSend && solutionsSys.TryGetRefillableSolution(target, out var targetRefill)
|
||||
&& solutionsSys.TryGetDrainableSolution(Owner, out var ownerDrain))
|
||||
{
|
||||
var transferred = DoTransfer(eventArgs.User, Owner, ownerDrain, target, targetRefill, TransferAmount);
|
||||
@@ -164,10 +165,10 @@ namespace Content.Server.Chemistry.Components
|
||||
}
|
||||
|
||||
/// <returns>The actual amount transferred.</returns>
|
||||
private static FixedPoint2 DoTransfer(IEntity user,
|
||||
IEntity sourceEntity,
|
||||
private static FixedPoint2 DoTransfer(EntityUid user,
|
||||
EntityUid sourceEntity,
|
||||
Solution source,
|
||||
IEntity targetEntity,
|
||||
EntityUid targetEntity,
|
||||
Solution target,
|
||||
FixedPoint2 amount)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user