@@ -1,5 +1,6 @@
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Nutrition.Prototypes;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -26,6 +27,13 @@ public sealed partial class MessyDrinkerComponent : Component
|
||||
[DataField, AutoNetworkedField]
|
||||
public List<ProtoId<EdiblePrototype>> SpillableTypes = new List<ProtoId<EdiblePrototype>> { "Drink" };
|
||||
|
||||
/// <summary>
|
||||
/// Tag given to drinks that are immune to messy drinker.
|
||||
/// For example, a spill-immune bottle.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public ProtoId<TagPrototype> SpillImmuneTag = "MessyDrinkerImmune";
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public LocId? SpillMessagePopup;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Fluids;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -13,6 +14,7 @@ public sealed class MessyDrinkerSystem : EntitySystem
|
||||
[Dependency] private readonly SharedPuddleSystem _puddle = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -23,7 +25,11 @@ public sealed class MessyDrinkerSystem : EntitySystem
|
||||
|
||||
private void OnIngested(Entity<MessyDrinkerComponent> ent, ref IngestingEvent ev)
|
||||
{
|
||||
if (ev.Split.Volume <= ent.Comp.SpillAmount)
|
||||
if (_tag.HasTag(ev.Food, ent.Comp.SpillImmuneTag))
|
||||
return;
|
||||
|
||||
// Cannot spill if you're being forced to drink.
|
||||
if (ev.ForceFed)
|
||||
return;
|
||||
|
||||
var proto = _ingestion.GetEdibleType(ev.Food);
|
||||
@@ -31,10 +37,6 @@ public sealed class MessyDrinkerSystem : EntitySystem
|
||||
if (proto == null || !ent.Comp.SpillableTypes.Contains(proto.Value))
|
||||
return;
|
||||
|
||||
// Cannot spill if you're being forced to drink.
|
||||
if (ev.ForceFed)
|
||||
return;
|
||||
|
||||
// TODO: Replace with RandomPredicted once the engine PR is merged
|
||||
var seed = SharedRandomExtensions.HashCodeCombine(new() { (int)_timing.CurTick.Value, GetNetEntity(ent).Id });
|
||||
var rand = new System.Random(seed);
|
||||
|
||||
@@ -931,6 +931,9 @@
|
||||
- type: Tag
|
||||
id: Medkit
|
||||
|
||||
- type: Tag
|
||||
id: MessyDrinkerImmune
|
||||
|
||||
- type: Tag
|
||||
id: Metal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user