Adds repeating DoAfters to Food and Drink (#15233)

This commit is contained in:
keronshb
2023-04-15 18:14:26 -04:00
committed by GitHub
parent 39e59f11bf
commit c6aae19a16
7 changed files with 33 additions and 11 deletions

View File

@@ -130,7 +130,7 @@ namespace Content.Server.Nutrition.EntitySystems
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is eating {ToPrettyString(food):food} {SolutionContainerSystem.ToPrettyString(foodSolution)}");
}
var doAfterEventArgs = new DoAfterArgs(
var doAfterArgs = new DoAfterArgs(
user,
forceFeed ? foodComp.ForceFeedDelay : foodComp.Delay,
new ConsumeDoAfterEvent(foodSolution.Name, flavors),
@@ -146,10 +146,11 @@ namespace Content.Server.Nutrition.EntitySystems
// Mice and the like can eat without hands.
// TODO maybe set this based on some CanEatWithoutHands event or component?
NeedHand = forceFeed,
//Works better with cancel duplicate on because you can just use again to stop
CancelDuplicate = false,
};
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
_doAfterSystem.TryStartDoAfter(doAfterArgs);
return true;
}
@@ -170,16 +171,15 @@ namespace Content.Server.Nutrition.EntitySystems
if (!TryGetRequiredUtensils(args.User, component, out var utensils))
return;
args.Handled = true;
var forceFeed = args.User != args.Target;
args.Handled = true;
var transferAmount = component.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) component.TransferAmount, solution.Volume) : solution.Volume;
var split = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount);
//TODO: Get the stomach UID somehow without nabbing owner
var firstStomach = stomachs.FirstOrNull(stomach => _stomachSystem.CanTransferSolution(stomach.Comp.Owner, split));
var forceFeed = args.User != args.Target;
// No stomach so just popup a message that they can't eat.
if (firstStomach == null)
{
@@ -222,7 +222,12 @@ namespace Content.Server.Nutrition.EntitySystems
}
if (component.UsesRemaining > 0)
{
if (!forceFeed)
args.Repeat = true;
return;
}
if (string.IsNullOrEmpty(component.TrashPrototype))
EntityManager.QueueDeleteEntity(uid);