Fix being able to remotely give drinks to your fellow man (#3223)
This commit is contained in:
@@ -11,6 +11,7 @@ using Content.Shared.GameObjects.Components.Nutrition;
|
|||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Content.Shared.Utility;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
@@ -141,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TryUseDrink(args.User);
|
return TryUseDrink(args.User, args.User);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Force feeding a drink to someone.
|
//Force feeding a drink to someone.
|
||||||
@@ -152,7 +153,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TryUseDrink(eventArgs.Target, true);
|
return TryUseDrink(eventArgs.User, eventArgs.Target, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||||
@@ -166,7 +167,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
message.AddMarkup(Loc.GetString("[color={0}]{1}[/color]", color, openedText));
|
message.AddMarkup(Loc.GetString("[color={0}]{1}[/color]", color, openedText));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryUseDrink(IEntity target, bool forced = false)
|
private bool TryUseDrink(IEntity user, IEntity target, bool forced = false)
|
||||||
{
|
{
|
||||||
if (!Opened)
|
if (!Opened)
|
||||||
{
|
{
|
||||||
@@ -193,6 +194,13 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (user != target &&
|
||||||
|
!user.InRangeUnobstructed(target, popup: true))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var transferAmount = ReagentUnit.Min(TransferAmount, interactions.DrainAvailable);
|
var transferAmount = ReagentUnit.Min(TransferAmount, interactions.DrainAvailable);
|
||||||
var drain = interactions.Drain(transferAmount);
|
var drain = interactions.Drain(transferAmount);
|
||||||
var firstStomach = stomachs.FirstOrDefault(stomach => stomach.CanTransferSolution(drain));
|
var firstStomach = stomachs.FirstOrDefault(stomach => stomach.CanTransferSolution(drain));
|
||||||
|
|||||||
Reference in New Issue
Block a user