Puddle drink fixes (#16661)
This commit is contained in:
@@ -42,6 +42,9 @@ namespace Content.Server.Nutrition.Components
|
|||||||
[DataField("delay")]
|
[DataField("delay")]
|
||||||
public float Delay = 1;
|
public float Delay = 1;
|
||||||
|
|
||||||
|
[DataField("examinable")]
|
||||||
|
public bool Examinable = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is how many seconds it takes to force feed someone this drink.
|
/// This is how many seconds it takes to force feed someone this drink.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -67,17 +67,28 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
SubscribeLocalEvent<DrinkComponent, ConsumeDoAfterEvent>(OnDoAfter);
|
SubscribeLocalEvent<DrinkComponent, ConsumeDoAfterEvent>(OnDoAfter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private FixedPoint2 DrinkVolume(EntityUid uid, DrinkComponent? component = null)
|
||||||
|
{
|
||||||
|
if(!Resolve(uid, ref component))
|
||||||
|
return FixedPoint2.Zero;
|
||||||
|
|
||||||
|
if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var sol))
|
||||||
|
return FixedPoint2.Zero;
|
||||||
|
|
||||||
|
return sol.Volume;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
|
public bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
|
||||||
{
|
{
|
||||||
if(!Resolve(uid, ref component))
|
if(!Resolve(uid, ref component))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return _solutionContainerSystem.DrainAvailable(uid) <= 0;
|
return DrinkVolume(uid, component) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
|
private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
if (!component.Opened || !args.IsInDetailsRange)
|
if (!component.Opened || !args.IsInDetailsRange || !component.Examinable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var color = IsEmpty(uid, component) ? "gray" : "yellow";
|
var color = IsEmpty(uid, component) ? "gray" : "yellow";
|
||||||
@@ -89,7 +100,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
if (TryComp<ExaminableSolutionComponent>(uid, out var comp))
|
if (TryComp<ExaminableSolutionComponent>(uid, out var comp))
|
||||||
{
|
{
|
||||||
//provide exact measurement for beakers
|
//provide exact measurement for beakers
|
||||||
args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", _solutionContainerSystem.DrainAvailable(uid)))}");
|
args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(uid, component)))}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -160,7 +171,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
component.Opened = true;
|
component.Opened = true;
|
||||||
UpdateAppearance(component);
|
UpdateAppearance(component);
|
||||||
|
|
||||||
var solution = _solutionContainerSystem.Drain(uid, interactions, interactions.Volume);
|
var solution = _solutionContainerSystem.SplitSolution(uid, interactions, interactions.Volume);
|
||||||
_puddleSystem.TrySpillAt(uid, solution, out _);
|
_puddleSystem.TrySpillAt(uid, solution, out _);
|
||||||
|
|
||||||
_audio.PlayPvs(_audio.GetSound(component.BurstSound), uid, AudioParams.Default.WithVolume(-4));
|
_audio.PlayPvs(_audio.GetSound(component.BurstSound), uid, AudioParams.Default.WithVolume(-4));
|
||||||
@@ -203,7 +214,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var drainAvailable = _solutionContainerSystem.DrainAvailable((component).Owner);
|
var drainAvailable = DrinkVolume((component.Owner), component);
|
||||||
_appearanceSystem.SetData(component.Owner, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
_appearanceSystem.SetData(component.Owner, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
||||||
_appearanceSystem.SetData(component.Owner, DrinkCanStateVisual.Opened, component.Opened, appearance);
|
_appearanceSystem.SetData(component.Owner, DrinkCanStateVisual.Opened, component.Opened, appearance);
|
||||||
}
|
}
|
||||||
@@ -311,7 +322,7 @@ namespace Content.Server.Nutrition.EntitySystems
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var transferAmount = FixedPoint2.Min(component.TransferAmount, solution.Volume);
|
var transferAmount = FixedPoint2.Min(component.TransferAmount, solution.Volume);
|
||||||
var drained = _solutionContainerSystem.Drain(uid, solution, transferAmount);
|
var drained = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount);
|
||||||
var forceDrink = args.User != args.Target;
|
var forceDrink = args.User != args.Target;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|||||||
@@ -121,3 +121,4 @@
|
|||||||
delay: 3
|
delay: 3
|
||||||
transferAmount: 1
|
transferAmount: 1
|
||||||
solution: puddle
|
solution: puddle
|
||||||
|
examinable: false
|
||||||
|
|||||||
Reference in New Issue
Block a user