Remove IAfterInteract (#9715)

* remove gas analyzer iafterinteract

* solution transfer + obsolete

* cuffable

* remove
This commit is contained in:
Kara
2022-07-14 04:45:31 -07:00
committed by GitHub
parent a2d22837c6
commit fab331742a
11 changed files with 163 additions and 241 deletions

View File

@@ -14,15 +14,8 @@ namespace Content.Server.Chemistry.Components
/// Gives click behavior for transferring to/from other reagent containers.
/// </summary>
[RegisterComponent]
public sealed class SolutionTransferComponent : Component, IAfterInteract
public sealed class SolutionTransferComponent : Component
{
[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.
// Of course, only if possible.
/// <summary>
/// The amount of solution to be transferred from this solution when clicking on other solutions with it.
/// </summary>
@@ -102,70 +95,5 @@ namespace Content.Server.Chemistry.Components
MaximumTransferAmount.Int()));
TransferAmount = amount;
}
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
{
if (!eventArgs.CanReach || eventArgs.Target == null)
return false;
var target = eventArgs.Target!.Value;
var solutionsSys = EntitySystem.Get<SolutionContainerSystem>();
var transferSystem = EntitySystem.Get<SolutionTransferSystem>();
//Special case for reagent tanks, because normally clicking another container will give solution, not take it.
if (CanReceive && !_entities.HasComponent<RefillableSolutionComponent>(target) // target must not be refillable (e.g. Reagent Tanks)
&& solutionsSys.TryGetDrainableSolution(target, out var targetDrain) // target must be drainable
&& _entities.TryGetComponent(Owner, out RefillableSolutionComponent? refillComp)
&& solutionsSys.TryGetRefillableSolution(Owner, out var ownerRefill, refillable: refillComp))
{
var transferAmount = TransferAmount; // This is the player-configurable transfer amount of "Owner," not the target reagent tank.
if (_entities.TryGetComponent(Owner, out RefillableSolutionComponent? refill) && refill.MaxRefill != null) // Owner is the entity receiving solution from target.
{
transferAmount = FixedPoint2.Min(transferAmount, (FixedPoint2) refill.MaxRefill); // if the receiver has a smaller transfer limit, use that instead
}
var transferred = transferSystem.Transfer(eventArgs.User, target, targetDrain, Owner, ownerRefill, transferAmount);
if (transferred > 0)
{
var toTheBrim = ownerRefill.AvailableVolume == 0;
var msg = toTheBrim
? "comp-solution-transfer-fill-fully"
: "comp-solution-transfer-fill-normal";
target.PopupMessage(eventArgs.User,
Loc.GetString(msg, ("owner", eventArgs.Target), ("amount", transferred), ("target", Owner)));
return true;
}
}
// if target is refillable, and owner is drainable
if (CanSend && solutionsSys.TryGetRefillableSolution(target, out var targetRefill)
&& solutionsSys.TryGetDrainableSolution(Owner, out var ownerDrain))
{
var transferAmount = TransferAmount;
if (_entities.TryGetComponent(target, out RefillableSolutionComponent? refill) && refill.MaxRefill != null)
{
transferAmount = FixedPoint2.Min(transferAmount, (FixedPoint2) refill.MaxRefill);
}
var transferred = transferSystem.Transfer(eventArgs.User, Owner, ownerDrain, target, targetRefill, transferAmount);
if (transferred > 0)
{
Owner.PopupMessage(eventArgs.User,
Loc.GetString("comp-solution-transfer-transfer-solution",
("amount", transferred),
("target", target)));
return true;
}
}
return false;
}
}
}