Flavors on DoAfter, instead of after (#11251)

This commit is contained in:
Flipp Syder
2022-09-13 19:36:19 -07:00
committed by GitHub
parent cf8454413b
commit b5b5e18a87
3 changed files with 14 additions and 6 deletions

View File

@@ -265,6 +265,8 @@ namespace Content.Server.Nutrition.EntitySystems
drink.CancelToken = new CancellationTokenSource();
var moveBreak = user != target;
var flavors = _flavorProfileSystem.GetLocalizedFlavorsMessage(user, drinkSolution);
_doAfterSystem.DoAfter(new DoAfterEventArgs(user, forceDrink ? drink.ForceFeedDelay : drink.Delay, drink.CancelToken.Token, target, drink.Owner)
{
BreakOnUserMove = moveBreak,
@@ -273,7 +275,7 @@ namespace Content.Server.Nutrition.EntitySystems
BreakOnTargetMove = moveBreak,
MovementThreshold = 0.01f,
DistanceThreshold = 1.0f,
TargetFinishedEvent = new DrinkEvent(user, drink, drinkSolution),
TargetFinishedEvent = new DrinkEvent(user, drink, drinkSolution, flavors),
BroadcastCancelledEvent = new DrinkCancelledEvent(drink),
NeedHand = true,
});
@@ -336,7 +338,7 @@ namespace Content.Server.Nutrition.EntitySystems
return;
}
var flavors = _flavorProfileSystem.GetLocalizedFlavorsMessage(args.User, drained);
var flavors = args.FlavorMessage;
if (forceDrink)
{

View File

@@ -94,6 +94,8 @@ namespace Content.Server.Nutrition.EntitySystems
if (!_solutionContainerSystem.TryGetSolution(food.Owner, food.SolutionName, out var foodSolution))
return false;
var flavors = _flavorProfileSystem.GetLocalizedFlavorsMessage(food.Owner, user, foodSolution);
if (food.UsesRemaining <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("food-system-try-use-food-is-empty",
@@ -134,7 +136,7 @@ namespace Content.Server.Nutrition.EntitySystems
BreakOnTargetMove = moveBreak,
MovementThreshold = 0.01f,
DistanceThreshold = 1.0f,
TargetFinishedEvent = new FeedEvent(user, food, foodSolution, utensils),
TargetFinishedEvent = new FeedEvent(user, food, foodSolution, flavors, utensils),
BroadcastCancelledEvent = new ForceFeedCancelledEvent(food),
NeedHand = true,
});
@@ -180,7 +182,7 @@ namespace Content.Server.Nutrition.EntitySystems
split.DoEntityReaction(uid, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(firstStomach.Value.Comp.Owner, split, firstStomach.Value.Comp);
var flavors = _flavorProfileSystem.GetLocalizedFlavorsMessage(args.Food.Owner, args.User, split);
var flavors = args.FlavorMessage;
if (forceFeed)
{

View File

@@ -22,13 +22,15 @@ public sealed class FeedEvent : EntityEventArgs
public readonly EntityUid User;
public readonly FoodComponent Food;
public readonly Solution FoodSolution;
public readonly string FlavorMessage;
public readonly List<UtensilComponent> Utensils;
public FeedEvent(EntityUid user, FoodComponent food, Solution foodSolution, List<UtensilComponent> utensils)
public FeedEvent(EntityUid user, FoodComponent food, Solution foodSolution, string flavorMessage, List<UtensilComponent> utensils)
{
User = user;
Food = food;
FoodSolution = foodSolution;
FlavorMessage = flavorMessage;
Utensils = utensils;
}
}
@@ -54,12 +56,14 @@ public sealed class DrinkEvent : EntityEventArgs
public readonly EntityUid User;
public readonly DrinkComponent Drink;
public readonly Solution DrinkSolution;
public readonly string FlavorMessage;
public DrinkEvent(EntityUid user, DrinkComponent drink, Solution drinkSolution)
public DrinkEvent(EntityUid user, DrinkComponent drink, Solution drinkSolution, string flavorMessage)
{
User = user;
Drink = drink;
DrinkSolution = drinkSolution;
FlavorMessage = flavorMessage;
}
}