Fix various solution capability issues (syringes, drinks) (#4687)

* Fix syringe message stating you're attempting to draw from yourself when you aren't

* Fix various missing capabilities (syringes, beakers, drinks)

* And fix mug inject/dispense/etc, too!

* Injectors can now refill things, and switch over drinks and cups thereof to be refillable rather than injectable
This commit is contained in:
20kdc
2021-10-01 11:06:50 +01:00
committed by GitHub
parent 400a6277fc
commit 9600c8e983
5 changed files with 45 additions and 19 deletions

View File

@@ -127,7 +127,11 @@ namespace Content.Server.Chemistry.Components
{ {
if (solutionsSys.TryGetInjectableSolution(targetEntity.Uid, out var injectableSolution)) if (solutionsSys.TryGetInjectableSolution(targetEntity.Uid, out var injectableSolution))
{ {
TryInject(targetEntity, injectableSolution, eventArgs.User); TryInject(targetEntity, injectableSolution, eventArgs.User, false);
}
else if (solutionsSys.TryGetRefillableSolution(targetEntity.Uid, out var refillableSolution))
{
TryInject(targetEntity, refillableSolution, eventArgs.User, true);
} }
else if (targetEntity.TryGetComponent(out BloodstreamComponent? bloodstream)) else if (targetEntity.TryGetComponent(out BloodstreamComponent? bloodstream))
{ {
@@ -137,7 +141,7 @@ namespace Content.Server.Chemistry.Components
{ {
eventArgs.User.PopupMessage(eventArgs.User, eventArgs.User.PopupMessage(eventArgs.User,
Loc.GetString("injector-component-cannot-transfer-message", Loc.GetString("injector-component-cannot-transfer-message",
("owner", eventArgs.User))); ("target", targetEntity)));
} }
} }
else if (ToggleState == InjectorToggleMode.Draw) else if (ToggleState == InjectorToggleMode.Draw)
@@ -150,7 +154,7 @@ namespace Content.Server.Chemistry.Components
{ {
eventArgs.User.PopupMessage(eventArgs.User, eventArgs.User.PopupMessage(eventArgs.User,
Loc.GetString("injector-component-cannot-draw-message", Loc.GetString("injector-component-cannot-draw-message",
("owner", eventArgs.User))); ("target", targetEntity)));
} }
} }
@@ -181,7 +185,7 @@ namespace Content.Server.Chemistry.Components
if (realTransferAmount <= 0) if (realTransferAmount <= 0)
{ {
Owner.PopupMessage(user, Owner.PopupMessage(user,
Loc.GetString("injector-component-cannot-inject-message", ("owner", targetBloodstream.Owner))); Loc.GetString("injector-component-cannot-inject-message", ("target", targetBloodstream.Owner)));
return; return;
} }
@@ -210,7 +214,7 @@ namespace Content.Server.Chemistry.Components
AfterInject(); AfterInject();
} }
private void TryInject(IEntity targetEntity, Solution targetSolution, IEntity user) private void TryInject(IEntity targetEntity, Solution targetSolution, IEntity user, bool asRefill)
{ {
if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution) if (!EntitySystem.Get<SolutionContainerSystem>().TryGetSolution(Owner, SolutionName, out var solution)
|| solution.CurrentVolume == 0) || solution.CurrentVolume == 0)
@@ -233,8 +237,16 @@ namespace Content.Server.Chemistry.Components
removedSolution.DoEntityReaction(targetEntity, ReactionMethod.Injection); removedSolution.DoEntityReaction(targetEntity, ReactionMethod.Injection);
EntitySystem.Get<SolutionContainerSystem>() if (!asRefill)
.Inject(targetEntity.Uid, targetSolution, removedSolution); {
EntitySystem.Get<SolutionContainerSystem>()
.Inject(targetEntity.Uid, targetSolution, removedSolution);
}
else
{
EntitySystem.Get<SolutionContainerSystem>()
.Refill(targetEntity.Uid, targetSolution, removedSolution);
}
Owner.PopupMessage(user, Owner.PopupMessage(user,
Loc.GetString("injector-component-transfer-success-message", Loc.GetString("injector-component-transfer-success-message",

View File

@@ -9,11 +9,11 @@ injector-volume-label = Volume: [color=white]{$currentVolume}/{$totalVolume}[/co
injector-component-drawing-text = Now drawing injector-component-drawing-text = Now drawing
injector-component-injecting-text = Now injecting injector-component-injecting-text = Now injecting
injector-component-cannot-transfer-message = You aren't able to transfer to {$owner}! injector-component-cannot-transfer-message = You aren't able to transfer to {$target}!
injector-component-cannot-draw-message = You aren't able to draw from {$owner}! injector-component-cannot-draw-message = You aren't able to draw from {$target}!
injector-component-cannot-inject-message = You aren't able to inject to {$owner}! injector-component-cannot-inject-message = You aren't able to inject to {$target}!
injector-component-inject-success-message = You inject {$amount}u into {$target}! injector-component-inject-success-message = You inject {$amount}u into {$target}!
injector-component-transfer-success-message = You transfer {$amount}u into {$target}. injector-component-transfer-success-message = You transfer {$amount}u into {$target}.
injector-component-draw-success-message = You draw {$amount}u from {$target}. injector-component-draw-success-message = You draw {$amount}u from {$target}.
injector-component-target-already-full-message = {$target} is already full! injector-component-target-already-full-message = {$target} is already full!
injector-component-target-is-empty-message = {$target} is empty! injector-component-target-is-empty-message = {$target} is empty!

View File

@@ -58,6 +58,18 @@
damage: damage:
types: types:
Blunt: 5 Blunt: 5
- type: FitsInDispenser
solution: drink
- type: DrawableSolution
solution: drink
- type: RefillableSolution
solution: drink
- type: SolutionTransfer
canChangeTransferAmount: true
- type: UserInterface
interfaces:
- key: enum.TransferAmountUiKey.Key
type: TransferAmountBoundUserInterface
# Transformable container - normal glass # Transformable container - normal glass
- type: entity - type: entity
@@ -72,15 +84,7 @@
solutions: solutions:
drink: drink:
maxVol: 50 maxVol: 50
- type: FitsInDispenser
solution: drink
- type: SolutionTransfer
canChangeTransferAmount: true
- type: TransformableContainer - type: TransformableContainer
- type: UserInterface
interfaces:
- key: enum.TransferAmountUiKey.Key
type: TransferAmountBoundUserInterface
- type: entity - type: entity
parent: DrinkGlassBase parent: DrinkGlassBase

View File

@@ -9,6 +9,12 @@
solutions: solutions:
drink: drink:
maxVol: 10 maxVol: 10
- type: FitsInDispenser
solution: drink
- type: DrawableSolution
solution: drink
- type: RefillableSolution
solution: drink
- type: SolutionTransfer - type: SolutionTransfer
canChangeTransferAmount: true canChangeTransferAmount: true
maxTransferAmount: 10 maxTransferAmount: 10

View File

@@ -29,6 +29,10 @@
solution: beaker solution: beaker
- type: ExaminableSolution - type: ExaminableSolution
solution: beaker solution: beaker
- type: DrawableSolution
solution: beaker
- type: InjectableSolution
solution: beaker
- type: SolutionTransfer - type: SolutionTransfer
canChangeTransferAmount: true canChangeTransferAmount: true
- type: UserInterface - type: UserInterface