Stop eating food if you drop it (#29854)
* Stop eating food if you drop it * woops, unused param * comments --------- Co-authored-by: plykiya <plykiya@protonmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ using Content.Shared.Database;
|
|||||||
using Content.Shared.DoAfter;
|
using Content.Shared.DoAfter;
|
||||||
using Content.Shared.EntityEffects;
|
using Content.Shared.EntityEffects;
|
||||||
using Content.Shared.FixedPoint;
|
using Content.Shared.FixedPoint;
|
||||||
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
@@ -48,6 +49,7 @@ public sealed class DrinkSystem : SharedDrinkSystem
|
|||||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||||
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||||
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
|
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
|
||||||
[Dependency] private readonly StomachSystem _stomach = default!;
|
[Dependency] private readonly StomachSystem _stomach = default!;
|
||||||
@@ -156,6 +158,9 @@ public sealed class DrinkSystem : SharedDrinkSystem
|
|||||||
_appearance.SetData(uid, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
_appearance.SetData(uid, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to feed the drink item to the target entity
|
||||||
|
/// </summary>
|
||||||
private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, EntityUid item)
|
private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, EntityUid item)
|
||||||
{
|
{
|
||||||
if (!HasComp<BodyComponent>(target))
|
if (!HasComp<BodyComponent>(target))
|
||||||
@@ -210,9 +215,9 @@ public sealed class DrinkSystem : SharedDrinkSystem
|
|||||||
BreakOnDamage = true,
|
BreakOnDamage = true,
|
||||||
MovementThreshold = 0.01f,
|
MovementThreshold = 0.01f,
|
||||||
DistanceThreshold = 1.0f,
|
DistanceThreshold = 1.0f,
|
||||||
// Mice and the like can eat without hands.
|
// do-after will stop if item is dropped when trying to feed someone else
|
||||||
// TODO maybe set this based on some CanEatWithoutHands event or component?
|
// or if the item started out in the user's own hands
|
||||||
NeedHand = forceDrink,
|
NeedHand = forceDrink || _hands.IsHolding(user, item),
|
||||||
};
|
};
|
||||||
|
|
||||||
_doAfter.TryStartDoAfter(doAfterEventArgs);
|
_doAfter.TryStartDoAfter(doAfterEventArgs);
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ public sealed class FoodSystem : EntitySystem
|
|||||||
args.Handled = result.Handled;
|
args.Handled = result.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to feed the food item to the target entity
|
||||||
|
/// </summary>
|
||||||
public (bool Success, bool Handled) TryFeed(EntityUid user, EntityUid target, EntityUid food, FoodComponent foodComp)
|
public (bool Success, bool Handled) TryFeed(EntityUid user, EntityUid target, EntityUid food, FoodComponent foodComp)
|
||||||
{
|
{
|
||||||
//Suppresses eating yourself and alive mobs
|
//Suppresses eating yourself and alive mobs
|
||||||
@@ -189,9 +192,9 @@ public sealed class FoodSystem : EntitySystem
|
|||||||
BreakOnDamage = true,
|
BreakOnDamage = true,
|
||||||
MovementThreshold = 0.01f,
|
MovementThreshold = 0.01f,
|
||||||
DistanceThreshold = MaxFeedDistance,
|
DistanceThreshold = MaxFeedDistance,
|
||||||
// Mice and the like can eat without hands.
|
// do-after will stop if item is dropped when trying to feed someone else
|
||||||
// TODO maybe set this based on some CanEatWithoutHands event or component?
|
// or if the item started out in the user's own hands
|
||||||
NeedHand = forceFeed,
|
NeedHand = forceFeed || _hands.IsHolding(user, food),
|
||||||
};
|
};
|
||||||
|
|
||||||
_doAfter.TryStartDoAfter(doAfterArgs);
|
_doAfter.TryStartDoAfter(doAfterArgs);
|
||||||
|
|||||||
Reference in New Issue
Block a user