let animals drink things (#18236)
* thirst .Owner removal * thirst file scope * drink update + minor refactor * drink file scope * let animals drink things * dont eat/drink when dont need to * admeme mouse override * moo --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -12,6 +12,7 @@ using Content.Server.Storage.Components;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Fluids.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Prototypes;
|
||||
@@ -23,12 +24,13 @@ namespace Content.Server.NPC.Systems;
|
||||
/// </summary>
|
||||
public sealed class NPCUtilitySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly ContainerSystem _container = default!;
|
||||
[Dependency] private readonly DrinkSystem _drink = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
||||
[Dependency] private readonly FoodSystem _food = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
||||
[Dependency] private readonly PuddleSystem _puddle = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
|
||||
@@ -132,13 +134,38 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
if (!_food.IsDigestibleBy(owner, targetUid, food))
|
||||
return 0f;
|
||||
|
||||
// no mouse don't eat the uranium-235
|
||||
var avoidBadFood = !HasComp<IgnoreBadFoodComponent>(owner);
|
||||
|
||||
// only eat when hungry or if it will eat anything
|
||||
if (TryComp<HungerComponent>(owner, out var hunger) && hunger.CurrentThreshold > HungerThreshold.Okay && avoidBadFood)
|
||||
return 0f;
|
||||
|
||||
// no mouse don't eat the uranium-235
|
||||
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
|
||||
return 0f;
|
||||
|
||||
return 1f;
|
||||
}
|
||||
case DrinkValueCon:
|
||||
{
|
||||
if (!TryComp<DrinkComponent>(targetUid, out var drink) || !drink.Opened)
|
||||
return 0f;
|
||||
|
||||
// only drink when thirsty
|
||||
if (TryComp<ThirstComponent>(owner, out var thirst) && thirst.CurrentThirstThreshold > ThirstThreshold.Okay)
|
||||
return 0f;
|
||||
|
||||
// no janicow don't drink the blood puddle
|
||||
if (HasComp<BadDrinkComponent>(targetUid))
|
||||
return 0f;
|
||||
|
||||
// needs to have something that will satiate thirst, mice wont try to drink 100% pure mutagen.
|
||||
var hydration = _drink.TotalHydration(targetUid, drink);
|
||||
if (hydration <= 1.0f)
|
||||
return 0f;
|
||||
|
||||
return 1f;
|
||||
}
|
||||
case TargetAccessibleCon:
|
||||
{
|
||||
if (_container.TryGetContainingContainer(targetUid, out var container))
|
||||
|
||||
Reference in New Issue
Block a user