* Shelve * 22 file diff * What if it was just better * Hold that thought * Near final Commit, then YAML hell * 95% done with cs * Working Commit * Final Commit (Before reviews tear it apart and kill me) * Add a really stupid comment. * KILL * EXPLODE TEST FAILS WITH MY MIND * I hate it here * TACTICAL NUCLEAR STRIKE * Wait what the fuck was I doing? * Comments * Me when I'm stupid * Food doesn't need solutions * API improvements with some API weirdness * Move non-API out of API * Better comment * Fixes and spelling mistakes * Final fixes * Final fixes for real... * Kill food and drink localization files because I hate them. * Water droplet fix * Utensil fixes * Fix verb priority (It should've been 2) * A few minor localization fixes * merge conflict and stuff * MERGE CONFLICT NUCLEAR WAR!!! * Cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
|
|
|
|
namespace Content.Server.Nutrition.EntitySystems;
|
|
|
|
public sealed class DrinkSystem : SharedDrinkSystem
|
|
{
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
// TODO add InteractNoHandEvent for entities like mice.
|
|
SubscribeLocalEvent<DrinkComponent, SolutionContainerChangedEvent>(OnSolutionChange);
|
|
SubscribeLocalEvent<DrinkComponent, ComponentInit>(OnDrinkInit);
|
|
// run before inventory so for bucket it always tries to drink before equipping (when empty)
|
|
// run after openable so its always open -> drink
|
|
}
|
|
|
|
private void OnDrinkInit(Entity<DrinkComponent> entity, ref ComponentInit args)
|
|
{
|
|
if (TryComp<DrainableSolutionComponent>(entity, out var existingDrainable))
|
|
{
|
|
// Beakers have Drink component but they should use the existing Drainable
|
|
entity.Comp.Solution = existingDrainable.Solution;
|
|
}
|
|
else
|
|
{
|
|
_solutionContainer.EnsureSolution(entity.Owner, entity.Comp.Solution, out _);
|
|
}
|
|
|
|
UpdateAppearance(entity, entity.Comp);
|
|
|
|
if (TryComp(entity, out RefillableSolutionComponent? refillComp))
|
|
refillComp.Solution = entity.Comp.Solution;
|
|
|
|
if (TryComp(entity, out DrainableSolutionComponent? drainComp))
|
|
drainComp.Solution = entity.Comp.Solution;
|
|
}
|
|
|
|
private void OnSolutionChange(Entity<DrinkComponent> entity, ref SolutionContainerChangedEvent args)
|
|
{
|
|
UpdateAppearance(entity, entity.Comp);
|
|
}
|
|
|
|
public void UpdateAppearance(EntityUid uid, DrinkComponent component)
|
|
{
|
|
if (!TryComp<AppearanceComponent>(uid, out var appearance) ||
|
|
!HasComp<SolutionContainerManagerComponent>(uid))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var drainAvailable = DrinkVolume(uid, component);
|
|
_appearance.SetData(uid, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
|
}
|
|
}
|