From da20e7ff607a2d881461c361ac52472ca36b4ee3 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Date: Sat, 20 Jul 2024 00:09:59 -0700 Subject: [PATCH] CVar Food/Drink AutoEating (#571)

Media

https://github.com/user-attachments/assets/1276c50a-b50b-45a9-a69f-17bca32c736c

--- # Changelog :cl: - tweak: You no longer eat food like a starving wolf or something --- .../Nutrition/EntitySystems/DrinkSystem.cs | 5 ++++- .../Nutrition/EntitySystems/FoodSystem.cs | 5 ++++- Content.Shared/CCVar/CCVars.cs | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 4cc583b867c..47e7fa6802c 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -9,6 +9,7 @@ using Content.Server.Popups; using Content.Shared.Administration.Logs; using Content.Shared.Body.Components; +using Content.Shared.CCVar; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components.SolutionManager; @@ -29,6 +30,7 @@ using Content.Shared.Verbs; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; +using Robust.Shared.Configuration; using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; @@ -56,6 +58,7 @@ public sealed class DrinkSystem : EntitySystem [Dependency] private readonly SolutionContainerSystem _solutionContainer = default!; [Dependency] private readonly StomachSystem _stomach = default!; [Dependency] private readonly ForensicsSystem _forensics = default!; + [Dependency] private readonly IConfigurationManager _config = default!; public override void Initialize() { @@ -399,7 +402,7 @@ private void OnDoAfter(Entity entity, ref ConsumeDoAfterEvent ar _forensics.TransferDna(entity, args.Target.Value); - if (!forceDrink && solution.Volume > 0) + if (_config.GetCVar(CCVars.GameAutoEatDrinks) && !forceDrink && solution.Volume > 0) args.Repeat = true; } diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index e6c6085fc64..06d1c4b42d3 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -31,6 +31,8 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Utility; using System.Linq; +using Content.Shared.CCVar; +using Robust.Shared.Configuration; namespace Content.Server.Nutrition.EntitySystems; @@ -55,6 +57,7 @@ public sealed class FoodSystem : EntitySystem [Dependency] private readonly StackSystem _stack = default!; [Dependency] private readonly StomachSystem _stomach = default!; [Dependency] private readonly UtensilSystem _utensil = default!; + [Dependency] private readonly IConfigurationManager _config = default!; public const float MaxFeedDistance = 1.0f; @@ -287,7 +290,7 @@ private void OnDoAfter(Entity entity, ref ConsumeDoAfterEvent arg _utensil.TryBreak(utensil, args.User); } - args.Repeat = !forceFeed; + args.Repeat = _config.GetCVar(CCVars.GameAutoEatFood) && !forceFeed; if (TryComp(entity, out var stack)) { diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 4f9c6960056..3f603c61949 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -381,6 +381,19 @@ public static readonly CVarDef public static readonly CVarDef GameLoadoutsPoints = CVarDef.Create("game.loadouts_points", 14, CVar.REPLICATED); + + /// + /// Whether to repeat eating doafters after completion + /// + public static readonly CVarDef GameAutoEatFood = + CVarDef.Create("game.auto_eat_food", false, CVar.REPLICATED); + + /// + /// Whether to repeat drinking doafters after completion + /// + public static readonly CVarDef GameAutoEatDrinks = + CVarDef.Create("game.auto_eat_drinks", false, CVar.REPLICATED); + #if EXCEPTION_TOLERANCE /// /// Amount of times round start must fail before the server is shut down.