2022-02-07 00:37:38 +11:00
using System.Threading ;
2021-11-11 16:10:57 -07:00
using Content.Server.Body.Components ;
using Content.Server.Body.Systems ;
2021-10-29 13:40:15 +01:00
using Content.Server.Chemistry.Components.SolutionManager ;
using Content.Server.Chemistry.EntitySystems ;
2021-11-29 16:27:15 +13:00
using Content.Server.DoAfter ;
2021-12-05 04:18:30 +01:00
using Content.Server.Fluids.EntitySystems ;
2021-09-12 16:22:58 +10:00
using Content.Server.Nutrition.Components ;
2021-11-09 11:28:27 +01:00
using Content.Server.Popups ;
2021-11-29 16:27:15 +13:00
using Content.Shared.Administration.Logs ;
2021-11-02 11:40:55 +11:00
using Content.Shared.Body.Components ;
using Content.Shared.Chemistry.Reagent ;
2021-11-29 16:27:15 +13:00
using Content.Shared.Database ;
2021-11-02 11:40:55 +11:00
using Content.Shared.Examine ;
2021-11-03 16:48:03 -07:00
using Content.Shared.FixedPoint ;
2022-07-10 18:36:53 -07:00
using Content.Shared.IdentityManagement ;
2021-11-02 11:40:55 +11:00
using Content.Shared.Interaction ;
2022-03-13 01:33:23 +13:00
using Content.Shared.Interaction.Events ;
2023-01-13 16:57:10 -08:00
using Content.Shared.Mobs.Components ;
using Content.Shared.Mobs.Systems ;
2021-10-03 06:56:29 +02:00
using Content.Shared.Nutrition.Components ;
2021-09-12 16:22:58 +10:00
using Content.Shared.Throwing ;
2022-04-23 19:38:21 -04:00
using Content.Shared.Verbs ;
2021-09-06 15:49:44 +02:00
using JetBrains.Annotations ;
2021-09-12 16:22:58 +10:00
using Robust.Shared.Audio ;
using Robust.Shared.Player ;
using Robust.Shared.Random ;
2021-11-30 18:25:02 -07:00
using Robust.Shared.Utility ;
2021-09-06 15:49:44 +02:00
namespace Content.Server.Nutrition.EntitySystems
{
[UsedImplicitly]
2022-02-16 00:23:23 -07:00
public sealed class DrinkSystem : EntitySystem
2021-09-06 15:49:44 +02:00
{
2021-12-03 03:51:05 +13:00
[Dependency] private readonly FoodSystem _foodSystem = default ! ;
Flavor profiles (#10991)
* flavor profiles
TODO: every single flavor! yeah!!!
* adds basic localization, and flavors/lastFlavor values for when you get the flavor profile message
* multiple and single flavor messages
* start on flavor localization, multiple flavors in localized flavors
* flavor prototypes
* a few more flavors, descriptions on what each section of the flavor file should be doing
* localization for flavor profiles in drink/food system
* adds an event that allows a flavor profile list to be transformed base on the user entity
* raises it on the food entity too
* changes a field in flavor, adds some more flavors, starts adding flavor prototypes
* adds basic flavors to several entities, and consumable drinks, renames flavor field to 'flavors'
* changes call ordering in flavorprofile, adds flavor to ignored components server-side
flavor is really just a popup message, and those are all processed server-side
* fixes where food tried to get the flavor of the user instead of the food
* single flavors will now get the localized string
* getting the flavor message now ensures that flavors are deduplicated
* makes flavor processing more strictly unique bu making everything hashsets
* yeah, that could just not have distinctby now
* adds flavorprofile directly to food base instead for generic food taste
* FlavorProfileModificationEvent now passes a hashset of strings and not flavorprototypes
* flavorprofilesystem now broadcasts the flavor profile modification event
* adds more flavors to the flavor profile loc file
* skips a flavor, if the flavor string is null/empty
* adds some more flavors, adds generic medicine flavor to medicinal chemicals
* more food flavors, adds flavors to swallowing
* adds some cocktails to the set of flavor profiles
* regenerates flavor prototypes
* adds flavor type to all flavors, adds whitespace between variants
* adds more flavors, adds flavors to several chemicals and food items
this is the part that took the longest
* changes backup flavor message
* spelling mistake
* more flavors, and flavors on food
* readds all the type fields, whoops
* fixes localization strings for forcefeeding food/drink
* fixes multiple flavor profile
* adds flavor limit for flavors
* makes that fetch the cvardef instead
2022-09-08 16:14:49 -07:00
[Dependency] private readonly FlavorProfileSystem _flavorProfileSystem = default ! ;
2021-09-12 16:22:58 +10:00
[Dependency] private readonly IRobustRandom _random = default ! ;
2021-09-06 15:49:44 +02:00
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default ! ;
2021-11-09 11:28:27 +01:00
[Dependency] private readonly PopupSystem _popupSystem = default ! ;
2021-11-11 16:10:57 -07:00
[Dependency] private readonly BodySystem _bodySystem = default ! ;
[Dependency] private readonly StomachSystem _stomachSystem = default ! ;
2021-11-29 16:27:15 +13:00
[Dependency] private readonly DoAfterSystem _doAfterSystem = default ! ;
2022-05-28 23:41:17 -07:00
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default ! ;
2022-12-19 19:25:35 -08:00
[Dependency] private readonly MobStateSystem _mobStateSystem = default ! ;
2021-12-05 04:18:30 +01:00
[Dependency] private readonly SpillableSystem _spillableSystem = default ! ;
2022-02-17 15:40:03 +13:00
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default ! ;
2023-01-10 06:59:43 -05:00
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default ! ;
[Dependency] private readonly SharedAudioSystem _audio = default ! ;
2021-09-06 15:49:44 +02:00
public override void Initialize ( )
{
base . Initialize ( ) ;
SubscribeLocalEvent < DrinkComponent , SolutionChangedEvent > ( OnSolutionChange ) ;
SubscribeLocalEvent < DrinkComponent , ComponentInit > ( OnDrinkInit ) ;
2021-09-12 16:22:58 +10:00
SubscribeLocalEvent < DrinkComponent , LandEvent > ( HandleLand ) ;
2021-11-02 11:40:55 +11:00
SubscribeLocalEvent < DrinkComponent , UseInHandEvent > ( OnUse ) ;
SubscribeLocalEvent < DrinkComponent , AfterInteractEvent > ( AfterInteract ) ;
2022-04-23 19:38:21 -04:00
SubscribeLocalEvent < DrinkComponent , GetVerbsEvent < AlternativeVerb > > ( AddDrinkVerb ) ;
2021-11-02 11:40:55 +11:00
SubscribeLocalEvent < DrinkComponent , ExaminedEvent > ( OnExamined ) ;
2022-04-15 23:17:48 +02:00
SubscribeLocalEvent < DrinkComponent , SolutionTransferAttemptEvent > ( OnTransferAttempt ) ;
2022-10-23 00:46:28 +02:00
SubscribeLocalEvent < BodyComponent , DrinkEvent > ( OnDrink ) ;
2022-02-07 00:37:38 +11:00
SubscribeLocalEvent < DrinkCancelledEvent > ( OnDrinkCancelled ) ;
2021-12-07 19:19:26 +13:00
}
2021-11-02 11:40:55 +11:00
public bool IsEmpty ( EntityUid uid , DrinkComponent ? component = null )
{
if ( ! Resolve ( uid , ref component ) )
return true ;
return _solutionContainerSystem . DrainAvailable ( uid ) < = 0 ;
}
private void OnExamined ( EntityUid uid , DrinkComponent component , ExaminedEvent args )
{
if ( ! component . Opened | | ! args . IsInDetailsRange )
return ;
var color = IsEmpty ( uid , component ) ? "gray" : "yellow" ;
var openedText =
Loc . GetString ( IsEmpty ( uid , component ) ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened" ) ;
2021-11-04 23:16:28 -05:00
args . Message . AddMarkup ( $"\n{Loc.GetString(" drink - component - on - examine - details - text ", (" colorName ", color), (" text ", openedText))}" ) ;
2022-06-21 22:02:24 -04:00
if ( ! IsEmpty ( uid , component ) )
{
if ( TryComp < ExaminableSolutionComponent > ( component . Owner , out var comp ) )
{
//provide exact measurement for beakers
args . Message . AddMarkup ( $" - {Loc.GetString(" drink - component - on - examine - exact - volume ", (" amount ", _solutionContainerSystem.DrainAvailable(uid)))}" ) ;
}
else
{
//general approximation
string remainingString ;
switch ( ( int ) _solutionContainerSystem . PercentFull ( uid ) )
{
case int perc when perc = = 100 :
remainingString = "drink-component-on-examine-is-full" ;
break ;
case int perc when perc > 66 :
remainingString = "drink-component-on-examine-is-mostly-full" ;
break ;
case int perc when perc > 33 :
remainingString = HalfEmptyOrHalfFull ( args ) ;
break ;
default :
remainingString = "drink-component-on-examine-is-mostly-empty" ;
break ;
}
args . Message . AddMarkup ( $" - {Loc.GetString(remainingString)}" ) ;
}
}
2021-11-02 11:40:55 +11:00
}
private void SetOpen ( EntityUid uid , bool opened = false , DrinkComponent ? component = null )
{
if ( ! Resolve ( uid , ref component ) )
return ;
if ( opened = = component . Opened )
return ;
component . Opened = opened ;
if ( ! _solutionContainerSystem . TryGetSolution ( uid , component . SolutionName , out _ ) )
return ;
if ( EntityManager . TryGetComponent < AppearanceComponent > ( uid , out var appearance ) )
{
2023-01-10 06:59:43 -05:00
_appearanceSystem . SetData ( uid , DrinkCanStateVisual . Opened , opened , appearance ) ;
2021-11-02 11:40:55 +11:00
}
}
private void AfterInteract ( EntityUid uid , DrinkComponent component , AfterInteractEvent args )
{
2022-02-05 15:39:01 +13:00
if ( args . Handled | | args . Target = = null | | ! args . CanReach )
2021-11-02 11:40:55 +11:00
return ;
2022-02-07 00:37:38 +11:00
args . Handled = TryDrink ( args . User , args . Target . Value , component ) ;
2021-11-02 11:40:55 +11:00
}
private void OnUse ( EntityUid uid , DrinkComponent component , UseInHandEvent args )
{
if ( args . Handled ) return ;
2021-11-29 16:27:15 +13:00
2021-11-02 11:40:55 +11:00
if ( ! component . Opened )
{
//Do the opening stuff like playing the sounds.
2023-01-10 06:59:43 -05:00
_audio . PlayPvs ( _audio . GetSound ( component . OpenSounds ) , args . User ) ;
2021-11-02 11:40:55 +11:00
SetOpen ( uid , true , component ) ;
return ;
}
2022-02-07 00:37:38 +11:00
args . Handled = TryDrink ( args . User , args . User , component ) ;
2021-09-12 16:22:58 +10:00
}
private void HandleLand ( EntityUid uid , DrinkComponent component , LandEvent args )
{
if ( component . Pressurized & &
! component . Opened & &
_random . Prob ( 0.25f ) & &
_solutionContainerSystem . TryGetDrainableSolution ( uid , out var interactions ) )
{
component . Opened = true ;
2021-10-03 06:56:29 +02:00
UpdateAppearance ( component ) ;
2021-09-12 16:22:58 +10:00
2023-01-12 16:41:40 +13:00
var solution = _solutionContainerSystem . Drain ( uid , interactions , interactions . Volume ) ;
2021-12-07 17:48:49 +01:00
_spillableSystem . SpillAt ( uid , solution , "PuddleSmear" ) ;
2021-09-12 16:22:58 +10:00
2023-01-10 06:59:43 -05:00
_audio . PlayPvs ( _audio . GetSound ( component . BurstSound ) , uid , AudioParams . Default . WithVolume ( - 4 ) ) ;
2021-09-12 16:22:58 +10:00
}
2021-09-06 15:49:44 +02:00
}
private void OnDrinkInit ( EntityUid uid , DrinkComponent component , ComponentInit args )
{
2021-11-02 11:40:55 +11:00
SetOpen ( uid , component . DefaultToOpened , component ) ;
2021-09-06 15:49:44 +02:00
2021-11-02 11:40:55 +11:00
if ( EntityManager . TryGetComponent ( uid , out DrainableSolutionComponent ? existingDrainable ) )
2021-09-06 15:49:44 +02:00
{
// Beakers have Drink component but they should use the existing Drainable
component . SolutionName = existingDrainable . Solution ;
}
else
{
2021-11-02 11:40:55 +11:00
_solutionContainerSystem . EnsureSolution ( uid , component . SolutionName ) ;
2021-09-06 15:49:44 +02:00
}
2021-10-03 06:56:29 +02:00
UpdateAppearance ( component ) ;
2022-04-15 23:17:48 +02:00
2022-08-17 12:47:58 +12:00
if ( TryComp ( uid , out RefillableSolutionComponent ? refillComp ) )
refillComp . Solution = component . SolutionName ;
if ( TryComp ( uid , out DrainableSolutionComponent ? drainComp ) )
drainComp . Solution = component . SolutionName ;
2021-09-06 15:49:44 +02:00
}
private void OnSolutionChange ( EntityUid uid , DrinkComponent component , SolutionChangedEvent args )
{
2021-10-03 06:56:29 +02:00
UpdateAppearance ( component ) ;
}
public void UpdateAppearance ( DrinkComponent component )
{
2021-12-07 22:22:34 +11:00
if ( ! EntityManager . TryGetComponent ( ( component ) . Owner , out AppearanceComponent ? appearance ) | |
! EntityManager . HasComponent < SolutionContainerManagerComponent > ( ( component ) . Owner ) )
2021-10-03 06:56:29 +02:00
{
return ;
}
2021-12-07 22:22:34 +11:00
var drainAvailable = _solutionContainerSystem . DrainAvailable ( ( component ) . Owner ) ;
2023-01-10 06:59:43 -05:00
_appearanceSystem . SetData ( component . Owner , FoodVisuals . Visual , drainAvailable . Float ( ) , appearance ) ;
_appearanceSystem . SetData ( component . Owner , DrinkCanStateVisual . Opened , component . Opened , appearance ) ;
2021-09-06 15:49:44 +02:00
}
2021-11-02 11:40:55 +11:00
2022-04-15 23:17:48 +02:00
private void OnTransferAttempt ( EntityUid uid , DrinkComponent component , SolutionTransferAttemptEvent args )
{
if ( ! component . Opened )
{
args . Cancel ( Loc . GetString ( "drink-component-try-use-drink-not-open" ,
( "owner" , EntityManager . GetComponent < MetaDataComponent > ( component . Owner ) . EntityName ) ) ) ;
}
}
2022-02-07 00:37:38 +11:00
private bool TryDrink ( EntityUid user , EntityUid target , DrinkComponent drink )
2021-11-02 11:40:55 +11:00
{
2022-02-07 00:37:38 +11:00
// cannot stack do-afters
2021-12-07 19:19:26 +13:00
if ( drink . CancelToken ! = null )
{
return true ;
}
2022-10-23 00:46:28 +02:00
if ( ! EntityManager . HasComponent < BodyComponent > ( target ) )
2022-02-07 00:37:38 +11:00
return false ;
2021-11-29 16:27:15 +13:00
if ( ! drink . Opened )
2021-11-02 11:40:55 +11:00
{
2021-11-29 16:27:15 +13:00
_popupSystem . PopupEntity ( Loc . GetString ( "drink-component-try-use-drink-not-open" ,
2022-12-19 10:41:47 +13:00
( "owner" , EntityManager . GetComponent < MetaDataComponent > ( drink . Owner ) . EntityName ) ) , drink . Owner , user ) ;
2021-11-29 16:27:15 +13:00
return true ;
2021-11-02 11:40:55 +11:00
}
2022-02-07 00:37:38 +11:00
if ( ! _solutionContainerSystem . TryGetDrainableSolution ( drink . Owner , out var drinkSolution ) | |
2023-01-12 16:41:40 +13:00
drinkSolution . Volume < = 0 )
2021-11-02 11:40:55 +11:00
{
2021-11-29 16:27:15 +13:00
_popupSystem . PopupEntity ( Loc . GetString ( "drink-component-try-use-drink-is-empty" ,
2022-12-19 10:41:47 +13:00
( "entity" , EntityManager . GetComponent < MetaDataComponent > ( drink . Owner ) . EntityName ) ) , drink . Owner , user ) ;
2021-11-29 16:27:15 +13:00
return true ;
}
2021-11-02 11:40:55 +11:00
2022-02-07 00:37:38 +11:00
if ( _foodSystem . IsMouthBlocked ( target , user ) )
2021-12-03 03:51:05 +13:00
return true ;
2022-02-17 15:40:03 +13:00
if ( ! _interactionSystem . InRangeUnobstructed ( user , drink . Owner , popup : true ) )
2021-11-29 16:27:15 +13:00
return true ;
2021-11-02 11:40:55 +11:00
2022-02-07 00:37:38 +11:00
var forceDrink = user ! = target ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
if ( forceDrink )
2021-12-07 19:19:26 +13:00
{
2022-07-31 15:43:38 +12:00
var userName = Identity . Entity ( user , EntityManager ) ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
_popupSystem . PopupEntity ( Loc . GetString ( "drink-component-force-feed" , ( "user" , userName ) ) ,
2022-12-19 10:41:47 +13:00
user , target ) ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
// logging
2022-05-28 23:41:17 -07:00
_adminLogger . Add ( LogType . ForceFeed , LogImpact . Medium , $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to drink {ToPrettyString(drink.Owner):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}" ) ;
2021-11-29 16:27:15 +13:00
}
2022-12-02 19:19:44 -06:00
else
{
// log voluntary drinking
_adminLogger . Add ( LogType . Ingestion , LogImpact . Low , $"{ToPrettyString(target):target} is drinking {ToPrettyString(drink.Owner):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}" ) ;
}
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
drink . CancelToken = new CancellationTokenSource ( ) ;
2022-03-17 12:46:18 +11:00
var moveBreak = user ! = target ;
2022-09-13 19:36:19 -07:00
var flavors = _flavorProfileSystem . GetLocalizedFlavorsMessage ( user , drinkSolution ) ;
2022-07-24 07:33:52 -04:00
_doAfterSystem . DoAfter ( new DoAfterEventArgs ( user , forceDrink ? drink . ForceFeedDelay : drink . Delay , drink . CancelToken . Token , target , drink . Owner )
2021-11-29 16:27:15 +13:00
{
2022-03-17 12:46:18 +11:00
BreakOnUserMove = moveBreak ,
2021-11-29 16:27:15 +13:00
BreakOnDamage = true ,
BreakOnStun = true ,
2022-03-17 12:46:18 +11:00
BreakOnTargetMove = moveBreak ,
2022-02-07 00:37:38 +11:00
MovementThreshold = 0.01f ,
2022-07-24 07:33:52 -04:00
DistanceThreshold = 1.0f ,
2022-09-13 19:36:19 -07:00
TargetFinishedEvent = new DrinkEvent ( user , drink , drinkSolution , flavors ) ,
2022-02-07 00:37:38 +11:00
BroadcastCancelledEvent = new DrinkCancelledEvent ( drink ) ,
NeedHand = true ,
2021-11-29 16:27:15 +13:00
} ) ;
return true ;
}
/// <summary>
/// Raised directed at a victim when someone has force fed them a drink.
/// </summary>
2022-10-23 00:46:28 +02:00
private void OnDrink ( EntityUid uid , BodyComponent body , DrinkEvent args )
2021-11-29 16:27:15 +13:00
{
2021-12-07 19:19:26 +13:00
if ( args . Drink . Deleted )
return ;
args . Drink . CancelToken = null ;
2023-01-12 16:41:40 +13:00
var transferAmount = FixedPoint2 . Min ( args . Drink . TransferAmount , args . DrinkSolution . Volume ) ;
2022-02-07 00:37:38 +11:00
var drained = _solutionContainerSystem . Drain ( args . Drink . Owner , args . DrinkSolution , transferAmount ) ;
var forceDrink = uid ! = args . User ;
2021-11-29 16:27:15 +13:00
2022-10-23 00:46:28 +02:00
if ( ! _bodySystem . TryGetBodyOrganComponents < StomachComponent > ( uid , out var stomachs , body ) )
2021-11-29 16:27:15 +13:00
{
2022-02-07 00:37:38 +11:00
_popupSystem . PopupEntity (
forceDrink ?
Loc . GetString ( "drink-component-try-use-drink-cannot-drink-other" ) :
Loc . GetString ( "drink-component-try-use-drink-had-enough" ) ,
2022-12-19 10:41:47 +13:00
uid , args . User ) ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
if ( EntityManager . HasComponent < RefillableSolutionComponent > ( uid ) )
{
_spillableSystem . SpillAt ( args . User , drained , "PuddleSmear" ) ;
return ;
}
_solutionContainerSystem . Refill ( uid , args . DrinkSolution , drained ) ;
2021-11-29 16:27:15 +13:00
return ;
}
2021-11-30 18:25:02 -07:00
var firstStomach = stomachs . FirstOrNull (
2021-12-07 22:22:34 +11:00
stomach = > _stomachSystem . CanTransferSolution ( ( stomach . Comp ) . Owner , drained ) ) ;
2021-11-29 16:27:15 +13:00
// All stomach are full or can't handle whatever solution we have.
if ( firstStomach = = null )
{
2022-07-07 11:21:26 -07:00
_popupSystem . PopupEntity ( Loc . GetString ( "drink-component-try-use-drink-had-enough" ) ,
2022-12-19 10:41:47 +13:00
uid , uid ) ;
2022-07-07 11:21:26 -07:00
if ( forceDrink )
{
_popupSystem . PopupEntity ( Loc . GetString ( "drink-component-try-use-drink-had-enough-other" ) ,
2022-12-19 10:41:47 +13:00
uid , args . User ) ;
2022-07-07 11:21:26 -07:00
_spillableSystem . SpillAt ( uid , drained , "PuddleSmear" ) ;
}
else
{
_solutionContainerSystem . TryAddSolution ( args . Drink . Owner , args . DrinkSolution , drained ) ;
}
2021-11-29 16:27:15 +13:00
return ;
}
2022-09-13 19:36:19 -07:00
var flavors = args . FlavorMessage ;
Flavor profiles (#10991)
* flavor profiles
TODO: every single flavor! yeah!!!
* adds basic localization, and flavors/lastFlavor values for when you get the flavor profile message
* multiple and single flavor messages
* start on flavor localization, multiple flavors in localized flavors
* flavor prototypes
* a few more flavors, descriptions on what each section of the flavor file should be doing
* localization for flavor profiles in drink/food system
* adds an event that allows a flavor profile list to be transformed base on the user entity
* raises it on the food entity too
* changes a field in flavor, adds some more flavors, starts adding flavor prototypes
* adds basic flavors to several entities, and consumable drinks, renames flavor field to 'flavors'
* changes call ordering in flavorprofile, adds flavor to ignored components server-side
flavor is really just a popup message, and those are all processed server-side
* fixes where food tried to get the flavor of the user instead of the food
* single flavors will now get the localized string
* getting the flavor message now ensures that flavors are deduplicated
* makes flavor processing more strictly unique bu making everything hashsets
* yeah, that could just not have distinctby now
* adds flavorprofile directly to food base instead for generic food taste
* FlavorProfileModificationEvent now passes a hashset of strings and not flavorprototypes
* flavorprofilesystem now broadcasts the flavor profile modification event
* adds more flavors to the flavor profile loc file
* skips a flavor, if the flavor string is null/empty
* adds some more flavors, adds generic medicine flavor to medicinal chemicals
* more food flavors, adds flavors to swallowing
* adds some cocktails to the set of flavor profiles
* regenerates flavor prototypes
* adds flavor type to all flavors, adds whitespace between variants
* adds more flavors, adds flavors to several chemicals and food items
this is the part that took the longest
* changes backup flavor message
* spelling mistake
* more flavors, and flavors on food
* readds all the type fields, whoops
* fixes localization strings for forcefeeding food/drink
* fixes multiple flavor profile
* adds flavor limit for flavors
* makes that fetch the cvardef instead
2022-09-08 16:14:49 -07:00
2022-02-07 00:37:38 +11:00
if ( forceDrink )
{
2022-07-31 15:43:38 +12:00
var targetName = Identity . Entity ( uid , EntityManager ) ;
var userName = Identity . Entity ( args . User , EntityManager ) ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
_popupSystem . PopupEntity (
2022-12-19 10:41:47 +13:00
Loc . GetString ( "drink-component-force-feed-success" , ( "user" , userName ) , ( "flavors" , flavors ) ) , uid , uid ) ;
2021-11-29 16:27:15 +13:00
2022-02-07 00:37:38 +11:00
_popupSystem . PopupEntity (
Loc . GetString ( "drink-component-force-feed-success-user" , ( "target" , targetName ) ) ,
2022-12-19 10:41:47 +13:00
args . User , args . User ) ;
2022-12-02 19:19:44 -06:00
// log successful forced drinking
_adminLogger . Add ( LogType . ForceFeed , LogImpact . Medium , $"{ToPrettyString(uid):user} forced {ToPrettyString(args.User):target} to drink {ToPrettyString(args.Drink.Owner):drink}" ) ;
2022-02-07 00:37:38 +11:00
}
else
{
_popupSystem . PopupEntity (
Flavor profiles (#10991)
* flavor profiles
TODO: every single flavor! yeah!!!
* adds basic localization, and flavors/lastFlavor values for when you get the flavor profile message
* multiple and single flavor messages
* start on flavor localization, multiple flavors in localized flavors
* flavor prototypes
* a few more flavors, descriptions on what each section of the flavor file should be doing
* localization for flavor profiles in drink/food system
* adds an event that allows a flavor profile list to be transformed base on the user entity
* raises it on the food entity too
* changes a field in flavor, adds some more flavors, starts adding flavor prototypes
* adds basic flavors to several entities, and consumable drinks, renames flavor field to 'flavors'
* changes call ordering in flavorprofile, adds flavor to ignored components server-side
flavor is really just a popup message, and those are all processed server-side
* fixes where food tried to get the flavor of the user instead of the food
* single flavors will now get the localized string
* getting the flavor message now ensures that flavors are deduplicated
* makes flavor processing more strictly unique bu making everything hashsets
* yeah, that could just not have distinctby now
* adds flavorprofile directly to food base instead for generic food taste
* FlavorProfileModificationEvent now passes a hashset of strings and not flavorprototypes
* flavorprofilesystem now broadcasts the flavor profile modification event
* adds more flavors to the flavor profile loc file
* skips a flavor, if the flavor string is null/empty
* adds some more flavors, adds generic medicine flavor to medicinal chemicals
* more food flavors, adds flavors to swallowing
* adds some cocktails to the set of flavor profiles
* regenerates flavor prototypes
* adds flavor type to all flavors, adds whitespace between variants
* adds more flavors, adds flavors to several chemicals and food items
this is the part that took the longest
* changes backup flavor message
* spelling mistake
* more flavors, and flavors on food
* readds all the type fields, whoops
* fixes localization strings for forcefeeding food/drink
* fixes multiple flavor profile
* adds flavor limit for flavors
* makes that fetch the cvardef instead
2022-09-08 16:14:49 -07:00
Loc . GetString ( "drink-component-try-use-drink-success-slurp-taste" , ( "flavors" , flavors ) ) , args . User ,
2022-12-19 10:41:47 +13:00
args . User ) ;
Flavor profiles (#10991)
* flavor profiles
TODO: every single flavor! yeah!!!
* adds basic localization, and flavors/lastFlavor values for when you get the flavor profile message
* multiple and single flavor messages
* start on flavor localization, multiple flavors in localized flavors
* flavor prototypes
* a few more flavors, descriptions on what each section of the flavor file should be doing
* localization for flavor profiles in drink/food system
* adds an event that allows a flavor profile list to be transformed base on the user entity
* raises it on the food entity too
* changes a field in flavor, adds some more flavors, starts adding flavor prototypes
* adds basic flavors to several entities, and consumable drinks, renames flavor field to 'flavors'
* changes call ordering in flavorprofile, adds flavor to ignored components server-side
flavor is really just a popup message, and those are all processed server-side
* fixes where food tried to get the flavor of the user instead of the food
* single flavors will now get the localized string
* getting the flavor message now ensures that flavors are deduplicated
* makes flavor processing more strictly unique bu making everything hashsets
* yeah, that could just not have distinctby now
* adds flavorprofile directly to food base instead for generic food taste
* FlavorProfileModificationEvent now passes a hashset of strings and not flavorprototypes
* flavorprofilesystem now broadcasts the flavor profile modification event
* adds more flavors to the flavor profile loc file
* skips a flavor, if the flavor string is null/empty
* adds some more flavors, adds generic medicine flavor to medicinal chemicals
* more food flavors, adds flavors to swallowing
* adds some cocktails to the set of flavor profiles
* regenerates flavor prototypes
* adds flavor type to all flavors, adds whitespace between variants
* adds more flavors, adds flavors to several chemicals and food items
this is the part that took the longest
* changes backup flavor message
* spelling mistake
* more flavors, and flavors on food
* readds all the type fields, whoops
* fixes localization strings for forcefeeding food/drink
* fixes multiple flavor profile
* adds flavor limit for flavors
* makes that fetch the cvardef instead
2022-09-08 16:14:49 -07:00
_popupSystem . PopupEntity (
2022-12-19 10:41:47 +13:00
Loc . GetString ( "drink-component-try-use-drink-success-slurp" ) , args . User , Filter . PvsExcept ( args . User ) , true ) ;
2022-12-02 19:19:44 -06:00
// log successful voluntary drinking
_adminLogger . Add ( LogType . Ingestion , LogImpact . Low , $"{ToPrettyString(args.User):target} drank {ToPrettyString(args.Drink.Owner):drink}" ) ;
2022-02-07 00:37:38 +11:00
}
2021-11-29 16:27:15 +13:00
2023-01-10 06:59:43 -05:00
_audio . PlayPvs ( _audio . GetSound ( args . Drink . UseSound ) , uid , AudioParams . Default . WithVolume ( - 2f ) ) ;
2021-11-29 16:27:15 +13:00
drained . DoEntityReaction ( uid , ReactionMethod . Ingestion ) ;
2022-02-07 00:37:38 +11:00
_stomachSystem . TryTransferSolution ( firstStomach . Value . Comp . Owner , drained , firstStomach . Value . Comp ) ;
2021-11-29 16:27:15 +13:00
}
2022-02-07 00:37:38 +11:00
private static void OnDrinkCancelled ( DrinkCancelledEvent args )
2021-11-29 16:27:15 +13:00
{
2021-12-07 19:19:26 +13:00
args . Drink . CancelToken = null ;
2021-11-29 16:27:15 +13:00
}
2022-04-23 19:38:21 -04:00
private void AddDrinkVerb ( EntityUid uid , DrinkComponent component , GetVerbsEvent < AlternativeVerb > ev )
{
if ( component . CancelToken ! = null )
return ;
if ( uid = = ev . User | |
! ev . CanInteract | |
! ev . CanAccess | |
2022-10-23 00:46:28 +02:00
! EntityManager . TryGetComponent ( ev . User , out BodyComponent ? body ) | |
! _bodySystem . TryGetBodyOrganComponents < StomachComponent > ( ev . User , out var stomachs , body ) )
2022-04-23 19:38:21 -04:00
return ;
2022-12-19 19:25:35 -08:00
if ( EntityManager . TryGetComponent < MobStateComponent > ( uid , out var mobState ) & & _mobStateSystem . IsAlive ( uid , mobState ) )
2022-04-23 19:38:21 -04:00
return ;
AlternativeVerb verb = new ( )
{
Act = ( ) = >
{
TryDrink ( ev . User , ev . User , component ) ;
} ,
IconTexture = "/Textures/Interface/VerbIcons/drink.svg.192dpi.png" ,
Text = Loc . GetString ( "drink-system-verb-drink" ) ,
Priority = - 1
} ;
ev . Verbs . Add ( verb ) ;
}
2022-06-21 22:02:24 -04:00
// some see half empty, and others see half full
private string HalfEmptyOrHalfFull ( ExaminedEvent args )
{
string remainingString = "drink-component-on-examine-is-half-full" ;
if ( TryComp < MetaDataComponent > ( args . Examiner , out var examiner ) & & examiner . EntityName . Length > 0
& & string . Compare ( examiner . EntityName . Substring ( 0 , 1 ) , "m" , StringComparison . InvariantCultureIgnoreCase ) > 0 )
remainingString = "drink-component-on-examine-is-half-empty" ;
return remainingString ;
}
2021-09-06 15:49:44 +02:00
}
}