Revert 'Revert 'Solution Entities'' (#23168)

This commit is contained in:
TemporalOroboros
2023-12-29 04:47:43 -08:00
committed by GitHub
parent 93e1af2f8d
commit d23c8d5c19
180 changed files with 3541 additions and 2956 deletions

View File

@@ -1,9 +1,9 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Explosion.Components;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components;
@@ -11,7 +11,6 @@ using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Rejuvenate;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
@@ -42,7 +41,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (EntityManager.TryGetComponent(uid, out FoodComponent? foodComp))
{
if (_solutions.TryGetSolution(uid, foodComp.Solution, out var solution))
if (_solutions.TryGetSolution(uid, foodComp.Solution, out _, out var solution))
{
_puddle.TrySpillAt(uid, solution, out _, false);
}
@@ -56,9 +55,9 @@ namespace Content.Server.Nutrition.EntitySystems
EntityManager.QueueDeleteEntity(uid);
}
private void OnInteractUsing(EntityUid uid, CreamPieComponent component, InteractUsingEvent args)
private void OnInteractUsing(Entity<CreamPieComponent> entity, ref InteractUsingEvent args)
{
ActivatePayload(uid);
ActivatePayload(entity);
}
private void ActivatePayload(EntityUid uid)
@@ -89,12 +88,12 @@ namespace Content.Server.Nutrition.EntitySystems
{
otherPlayers.RemovePlayer(actor.PlayerSession);
}
_popup.PopupEntity(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", uid),("thrower", args.Thrown)), uid, otherPlayers, false);
_popup.PopupEntity(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", uid), ("thrower", args.Thrown)), uid, otherPlayers, false);
}
private void OnRejuvenate(EntityUid uid, CreamPiedComponent component, RejuvenateEvent args)
private void OnRejuvenate(Entity<CreamPiedComponent> entity, ref RejuvenateEvent args)
{
SetCreamPied(uid, component, false);
SetCreamPied(entity, entity.Comp, false);
}
}
}

View File

@@ -1,6 +1,6 @@
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Chemistry.ReagentEffects;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Forensics;
@@ -61,7 +61,7 @@ public sealed class DrinkSystem : EntitySystem
base.Initialize();
// TODO add InteractNoHandEvent for entities like mice.
SubscribeLocalEvent<DrinkComponent, SolutionChangedEvent>(OnSolutionChange);
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
@@ -80,7 +80,7 @@ public sealed class DrinkSystem : EntitySystem
if (!Resolve(uid, ref component))
return FixedPoint2.Zero;
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out var sol))
if (!_solutionContainer.TryGetSolution(uid, component.Solution, out _, out var sol))
return FixedPoint2.Zero;
return sol.Volume;
@@ -102,7 +102,7 @@ public sealed class DrinkSystem : EntitySystem
if (!Resolve(uid, ref comp))
return 0f;
if (!_solutionContainer.TryGetSolution(uid, comp.Solution, out var solution))
if (!_solutionContainer.TryGetSolution(uid, comp.Solution, out _, out var solution))
return 0f;
var total = 0f;
@@ -128,31 +128,31 @@ public sealed class DrinkSystem : EntitySystem
return total;
}
private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
private void OnExamined(Entity<DrinkComponent> entity, ref ExaminedEvent args)
{
var hasOpenable = TryComp<OpenableComponent>(uid, out var openable);
if (_openable.IsClosed(uid, null, openable) || !args.IsInDetailsRange || !component.Examinable)
var hasOpenable = TryComp<OpenableComponent>(entity, out var openable);
if (_openable.IsClosed(entity.Owner, null, openable) || !args.IsInDetailsRange || !entity.Comp.Examinable)
return;
// put Empty / Xu after Opened, or start a new line
args.Message.AddMarkup(hasOpenable ? " - " : "\n");
var empty = IsEmpty(uid, component);
var empty = IsEmpty(entity, entity.Comp);
if (empty)
{
args.Message.AddMarkup(Loc.GetString("drink-component-on-examine-is-empty"));
return;
}
if (TryComp<ExaminableSolutionComponent>(uid, out var comp))
if (TryComp<ExaminableSolutionComponent>(entity, out var comp))
{
//provide exact measurement for beakers
args.Message.AddMarkup(Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(uid, component))));
args.Message.AddMarkup(Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(entity, entity.Comp))));
}
else
{
//general approximation
var remainingString = (int) _solutionContainer.PercentFull(uid) switch
var remainingString = (int) _solutionContainer.PercentFull(entity) switch
{
100 => "drink-component-on-examine-is-full",
> 66 => "drink-component-on-examine-is-mostly-full",
@@ -163,65 +163,65 @@ public sealed class DrinkSystem : EntitySystem
}
}
private void AfterInteract(EntityUid uid, DrinkComponent component, AfterInteractEvent args)
private void AfterInteract(Entity<DrinkComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled || args.Target == null || !args.CanReach)
return;
args.Handled = TryDrink(args.User, args.Target.Value, component, uid);
args.Handled = TryDrink(args.User, args.Target.Value, entity.Comp, entity);
}
private void OnUse(EntityUid uid, DrinkComponent component, UseInHandEvent args)
private void OnUse(Entity<DrinkComponent> entity, ref UseInHandEvent args)
{
if (args.Handled)
return;
args.Handled = TryDrink(args.User, args.User, component, uid);
args.Handled = TryDrink(args.User, args.User, entity.Comp, entity);
}
private void OnPressurizedDrinkLand(EntityUid uid, PressurizedDrinkComponent comp, ref LandEvent args)
private void OnPressurizedDrinkLand(Entity<PressurizedDrinkComponent> entity, ref LandEvent args)
{
if (!TryComp<DrinkComponent>(uid, out var drink) || !TryComp<OpenableComponent>(uid, out var openable))
if (!TryComp<DrinkComponent>(entity, out var drink) || !TryComp<OpenableComponent>(entity, out var openable))
return;
if (!openable.Opened &&
_random.Prob(comp.BurstChance) &&
_solutionContainer.TryGetSolution(uid, drink.Solution, out var interactions))
_random.Prob(entity.Comp.BurstChance) &&
_solutionContainer.TryGetSolution(entity.Owner, drink.Solution, out var soln, out var interactions))
{
// using SetOpen instead of TryOpen to not play 2 sounds
_openable.SetOpen(uid, true, openable);
_openable.SetOpen(entity, true, openable);
var solution = _solutionContainer.SplitSolution(uid, interactions, interactions.Volume);
_puddle.TrySpillAt(uid, solution, out _);
var solution = _solutionContainer.SplitSolution(soln.Value, interactions.Volume);
_puddle.TrySpillAt(entity, solution, out _);
_audio.PlayPvs(comp.BurstSound, uid);
_audio.PlayPvs(entity.Comp.BurstSound, entity);
}
}
private void OnDrinkInit(EntityUid uid, DrinkComponent component, ComponentInit args)
private void OnDrinkInit(Entity<DrinkComponent> entity, ref ComponentInit args)
{
if (TryComp<DrainableSolutionComponent>(uid, out var existingDrainable))
if (TryComp<DrainableSolutionComponent>(entity, out var existingDrainable))
{
// Beakers have Drink component but they should use the existing Drainable
component.Solution = existingDrainable.Solution;
entity.Comp.Solution = existingDrainable.Solution;
}
else
{
_solutionContainer.EnsureSolution(uid, component.Solution);
_solutionContainer.EnsureSolution(entity.Owner, entity.Comp.Solution);
}
UpdateAppearance(uid, component);
UpdateAppearance(entity, entity.Comp);
if (TryComp(uid, out RefillableSolutionComponent? refillComp))
refillComp.Solution = component.Solution;
if (TryComp(entity, out RefillableSolutionComponent? refillComp))
refillComp.Solution = entity.Comp.Solution;
if (TryComp(uid, out DrainableSolutionComponent? drainComp))
drainComp.Solution = component.Solution;
if (TryComp(entity, out DrainableSolutionComponent? drainComp))
drainComp.Solution = entity.Comp.Solution;
}
private void OnSolutionChange(EntityUid uid, DrinkComponent component, SolutionChangedEvent args)
private void OnSolutionChange(Entity<DrinkComponent> entity, ref SolutionContainerChangedEvent args)
{
UpdateAppearance(uid, component);
UpdateAppearance(entity, entity.Comp);
}
public void UpdateAppearance(EntityUid uid, DrinkComponent component)
@@ -244,8 +244,7 @@ public sealed class DrinkSystem : EntitySystem
if (_openable.IsClosed(item, user))
return true;
if (!_solutionContainer.TryGetSolution(item, drink.Solution, out var drinkSolution) ||
drinkSolution.Volume <= 0)
if (!_solutionContainer.TryGetSolution(item, drink.Solution, out _, out var drinkSolution) || drinkSolution.Volume <= 0)
{
if (drink.IgnoreEmpty)
return false;
@@ -254,9 +253,6 @@ public sealed class DrinkSystem : EntitySystem
return true;
}
if (drinkSolution.Name == null)
return false;
if (_food.IsMouthBlocked(target, user))
return true;
@@ -285,7 +281,7 @@ public sealed class DrinkSystem : EntitySystem
var doAfterEventArgs = new DoAfterArgs(EntityManager,
user,
forceDrink ? drink.ForceFeedDelay : drink.Delay,
new ConsumeDoAfterEvent(drinkSolution.Name, flavors),
new ConsumeDoAfterEvent(drink.Solution, flavors),
eventTarget: item,
target: target,
used: item)
@@ -307,15 +303,15 @@ public sealed class DrinkSystem : EntitySystem
/// <summary>
/// Raised directed at a victim when someone has force fed them a drink.
/// </summary>
private void OnDoAfter(EntityUid uid, DrinkComponent component, ConsumeDoAfterEvent args)
private void OnDoAfter(Entity<DrinkComponent> entity, ref ConsumeDoAfterEvent args)
{
if (args.Handled || args.Cancelled || component.Deleted)
if (args.Handled || args.Cancelled || entity.Comp.Deleted)
return;
if (!TryComp<BodyComponent>(args.Target, out var body))
return;
if (!_solutionContainer.TryGetSolution(args.Used, args.Solution, out var solution))
if (args.Used is null || !_solutionContainer.TryGetSolution(args.Used.Value, args.Solution, out var soln, out var solution))
return;
// TODO this should really be checked every tick.
@@ -326,8 +322,8 @@ public sealed class DrinkSystem : EntitySystem
if (!_interaction.InRangeUnobstructed(args.User, args.Target.Value))
return;
var transferAmount = FixedPoint2.Min(component.TransferAmount, solution.Volume);
var drained = _solutionContainer.SplitSolution(uid, solution, transferAmount);
var transferAmount = FixedPoint2.Min(entity.Comp.TransferAmount, solution.Volume);
var drained = _solutionContainer.SplitSolution(soln.Value, transferAmount);
var forceDrink = args.User != args.Target;
args.Handled = true;
@@ -344,11 +340,11 @@ public sealed class DrinkSystem : EntitySystem
return;
}
_solutionContainer.Refill(args.Target.Value, solution, drained);
_solutionContainer.Refill(args.Target.Value, soln.Value, drained);
return;
}
var firstStomach = stomachs.FirstOrNull(stomach => _stomach.CanTransferSolution(stomach.Comp.Owner, drained));
var firstStomach = stomachs.FirstOrNull(stomach => _stomach.CanTransferSolution(stomach.Comp.Owner, drained, stomach.Comp));
//All stomachs are full or can't handle whatever solution we have.
if (firstStomach == null)
@@ -361,7 +357,7 @@ public sealed class DrinkSystem : EntitySystem
_puddle.TrySpillAt(args.Target.Value, drained, out _);
}
else
_solutionContainer.TryAddSolution(uid, solution, drained);
_solutionContainer.TryAddSolution(soln.Value, drained);
return;
}
@@ -380,7 +376,7 @@ public sealed class DrinkSystem : EntitySystem
args.User, args.User);
// log successful forced drinking
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(uid):user} forced {ToPrettyString(args.User):target} to drink {ToPrettyString(uid):drink}");
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(entity.Owner):user} forced {ToPrettyString(args.User):target} to drink {ToPrettyString(entity.Owner):drink}");
}
else
{
@@ -391,24 +387,24 @@ public sealed class DrinkSystem : EntitySystem
Loc.GetString("drink-component-try-use-drink-success-slurp"), args.User, Filter.PvsExcept(args.User), true);
// log successful voluntary drinking
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} drank {ToPrettyString(uid):drink}");
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} drank {ToPrettyString(entity.Owner):drink}");
}
_audio.PlayPvs(component.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-2f));
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-2f));
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
//TODO: Grab the stomach UIDs somehow without using Owner
_stomach.TryTransferSolution(firstStomach.Value.Comp.Owner, drained, firstStomach.Value.Comp);
_forensics.TransferDna(uid, args.Target.Value);
_forensics.TransferDna(entity, args.Target.Value);
if (!forceDrink && solution.Volume > 0)
args.Repeat = true;
}
private void AddDrinkVerb(EntityUid uid, DrinkComponent component, GetVerbsEvent<AlternativeVerb> ev)
private void AddDrinkVerb(Entity<DrinkComponent> entity, ref GetVerbsEvent<AlternativeVerb> ev)
{
if (uid == ev.User ||
if (entity.Owner == ev.User ||
!ev.CanInteract ||
!ev.CanAccess ||
!TryComp<BodyComponent>(ev.User, out var body) ||
@@ -416,16 +412,17 @@ public sealed class DrinkSystem : EntitySystem
return;
// no drinking from living drinks, have to kill them first.
if (_mobState.IsAlive(uid))
if (_mobState.IsAlive(entity))
return;
var user = ev.User;
AlternativeVerb verb = new()
{
Act = () =>
{
TryDrink(ev.User, ev.User, component, uid);
TryDrink(user, user, entity.Comp, entity);
},
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/drink.svg.192dpi.png")),
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/drink.svg.192dpi.png")),
Text = Loc.GetString("drink-system-verb-drink"),
Priority = 2
};

View File

@@ -1,13 +1,10 @@
using System.Linq;
using System.Text;
using Content.Server.Nutrition.Components;
using Content.Shared.CCVar;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Nutrition;
using Microsoft.VisualBasic;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using System.Linq;
namespace Content.Server.Nutrition.EntitySystems;

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Inventory;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
@@ -9,7 +9,6 @@ using Content.Shared.Administration.Logs;
using Content.Shared.Body.Components;
using Content.Shared.Body.Organ;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Database;
using Content.Shared.DoAfter;
@@ -27,11 +26,9 @@ using Content.Shared.Stacks;
using Content.Shared.Storage;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using Content.Shared.Tag;
using Content.Shared.Storage;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Server.Nutrition.EntitySystems;
@@ -75,24 +72,24 @@ public sealed class FoodSystem : EntitySystem
/// <summary>
/// Eat item
/// </summary>
private void OnUseFoodInHand(EntityUid uid, FoodComponent foodComponent, UseInHandEvent ev)
private void OnUseFoodInHand(Entity<FoodComponent> entity, ref UseInHandEvent ev)
{
if (ev.Handled)
return;
var result = TryFeed(ev.User, ev.User, uid, foodComponent);
var result = TryFeed(ev.User, ev.User, entity, entity.Comp);
ev.Handled = result.Handled;
}
/// <summary>
/// Feed someone else
/// </summary>
private void OnFeedFood(EntityUid uid, FoodComponent foodComponent, AfterInteractEvent args)
private void OnFeedFood(Entity<FoodComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled || args.Target == null || !args.CanReach)
return;
var result = TryFeed(args.User, args.Target.Value, uid, foodComponent);
var result = TryFeed(args.User, args.Target.Value, entity, entity.Comp);
args.Handled = result.Handled;
}
@@ -112,7 +109,7 @@ public sealed class FoodSystem : EntitySystem
if (_openable.IsClosed(food, user))
return (false, true);
if (!_solutionContainer.TryGetSolution(food, foodComp.Solution, out var foodSolution) || foodSolution.Name == null)
if (!_solutionContainer.TryGetSolution(food, foodComp.Solution, out _, out var foodSolution))
return (false, false);
if (!_body.TryGetBodyOrganComponents<StomachComponent>(target, out var stomachs, body))
@@ -177,7 +174,7 @@ public sealed class FoodSystem : EntitySystem
var doAfterArgs = new DoAfterArgs(EntityManager,
user,
forceFeed ? foodComp.ForceFeedDelay : foodComp.Delay,
new ConsumeDoAfterEvent(foodSolution.Name, flavors),
new ConsumeDoAfterEvent(foodComp.Solution, flavors),
eventTarget: food,
target: target,
used: food)
@@ -196,9 +193,9 @@ public sealed class FoodSystem : EntitySystem
return (true, true);
}
private void OnDoAfter(EntityUid uid, FoodComponent component, ConsumeDoAfterEvent args)
private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent args)
{
if (args.Cancelled || args.Handled || component.Deleted || args.Target == null)
if (args.Cancelled || args.Handled || entity.Comp.Deleted || args.Target == null)
return;
if (!TryComp<BodyComponent>(args.Target.Value, out var body))
@@ -207,10 +204,10 @@ public sealed class FoodSystem : EntitySystem
if (!_body.TryGetBodyOrganComponents<StomachComponent>(args.Target.Value, out var stomachs, body))
return;
if (!_solutionContainer.TryGetSolution(args.Used, args.Solution, out var solution))
if (args.Used is null || !_solutionContainer.TryGetSolution(args.Used.Value, args.Solution, out var soln, out var solution))
return;
if (!TryGetRequiredUtensils(args.User, component, out var utensils))
if (!TryGetRequiredUtensils(args.User, entity.Comp, out var utensils))
return;
// TODO this should really be checked every tick.
@@ -224,9 +221,9 @@ public sealed class FoodSystem : EntitySystem
var forceFeed = args.User != args.Target;
args.Handled = true;
var transferAmount = component.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) component.TransferAmount, solution.Volume) : solution.Volume;
var transferAmount = entity.Comp.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) entity.Comp.TransferAmount, solution.Volume) : solution.Volume;
var split = _solutionContainer.SplitSolution(uid, solution, transferAmount);
var split = _solutionContainer.SplitSolution(soln.Value, transferAmount);
//TODO: Get the stomach UID somehow without nabbing owner
// Get the stomach with the highest available solution volume
@@ -235,11 +232,10 @@ public sealed class FoodSystem : EntitySystem
foreach (var (stomach, _) in stomachs)
{
var owner = stomach.Owner;
if (!_stomach.CanTransferSolution(owner, split))
if (!_stomach.CanTransferSolution(owner, split, stomach))
continue;
if (!_solutionContainer.TryGetSolution(owner, StomachSystem.DefaultSolutionName,
out var stomachSol))
if (!_solutionContainer.ResolveSolution(owner, StomachSystem.DefaultSolutionName, ref stomach.Solution, out var stomachSol))
continue;
if (stomachSol.AvailableVolume <= highestAvailable)
@@ -252,7 +248,7 @@ public sealed class FoodSystem : EntitySystem
// No stomach so just popup a message that they can't eat.
if (stomachToUse == null)
{
_solutionContainer.TryAddSolution(uid, solution, split);
_solutionContainer.TryAddSolution(soln.Value, split);
_popup.PopupEntity(forceFeed ? Loc.GetString("food-system-you-cannot-eat-any-more-other") : Loc.GetString("food-system-you-cannot-eat-any-more"), args.Target.Value, args.User);
return;
}
@@ -266,23 +262,22 @@ public sealed class FoodSystem : EntitySystem
{
var targetName = Identity.Entity(args.Target.Value, EntityManager);
var userName = Identity.Entity(args.User, EntityManager);
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)),
uid, uid);
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)), entity.Owner, entity.Owner);
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success-user", ("target", targetName)), args.User, args.User);
// log successful force feed
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(uid):user} forced {ToPrettyString(args.User):target} to eat {ToPrettyString(uid):food}");
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(entity.Owner):user} forced {ToPrettyString(args.User):target} to eat {ToPrettyString(entity.Owner):food}");
}
else
{
_popup.PopupEntity(Loc.GetString(component.EatMessage, ("food", uid), ("flavors", flavors)), args.User, args.User);
_popup.PopupEntity(Loc.GetString(entity.Comp.EatMessage, ("food", entity.Owner), ("flavors", flavors)), args.User, args.User);
// log successful voluntary eating
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} ate {ToPrettyString(uid):food}");
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} ate {ToPrettyString(entity.Owner):food}");
}
_audio.PlayPvs(component.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-1f));
_audio.PlayPvs(entity.Comp.UseSound, args.Target.Value, AudioParams.Default.WithVolume(-1f));
// Try to break all used utensils
foreach (var utensil in utensils)
@@ -292,24 +287,24 @@ public sealed class FoodSystem : EntitySystem
args.Repeat = !forceFeed;
if (TryComp<StackComponent>(uid, out var stack))
if (TryComp<StackComponent>(entity, out var stack))
{
//Not deleting whole stack piece will make troubles with grinding object
if (stack.Count > 1)
{
_stack.SetCount(uid, stack.Count - 1);
_solutionContainer.TryAddSolution(uid, solution, split);
_stack.SetCount(entity.Owner, stack.Count - 1);
_solutionContainer.TryAddSolution(soln.Value, split);
return;
}
}
else if (GetUsesRemaining(uid, component) > 0)
else if (GetUsesRemaining(entity.Owner, entity.Comp) > 0)
{
return;
}
// don't try to repeat if its being deleted
args.Repeat = false;
DeleteAndSpawnTrash(component, uid, args.User);
DeleteAndSpawnTrash(entity.Comp, entity.Owner, args.User);
}
public void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityUid user)
@@ -345,9 +340,9 @@ public sealed class FoodSystem : EntitySystem
QueueDel(food);
}
private void AddEatVerb(EntityUid uid, FoodComponent component, GetVerbsEvent<AlternativeVerb> ev)
private void AddEatVerb(Entity<FoodComponent> entity, ref GetVerbsEvent<AlternativeVerb> ev)
{
if (uid == ev.User ||
if (entity.Owner == ev.User ||
!ev.CanInteract ||
!ev.CanAccess ||
!TryComp<BodyComponent>(ev.User, out var body) ||
@@ -355,20 +350,21 @@ public sealed class FoodSystem : EntitySystem
return;
// have to kill mouse before eating it
if (_mobState.IsAlive(uid) && component.RequireDead)
if (_mobState.IsAlive(entity) && entity.Comp.RequireDead)
return;
// only give moths eat verb for clothes since it would just fail otherwise
if (!IsDigestibleBy(uid, component, stomachs))
if (!IsDigestibleBy(entity, entity.Comp, stomachs))
return;
var user = ev.User;
AlternativeVerb verb = new()
{
Act = () =>
{
TryFeed(ev.User, ev.User, uid, component);
TryFeed(user, user, entity, entity.Comp);
},
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/cutlery.svg.192dpi.png")),
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/cutlery.svg.192dpi.png")),
Text = Loc.GetString("food-system-verb-eat"),
Priority = -1
};
@@ -416,7 +412,7 @@ public sealed class FoodSystem : EntitySystem
}
if (component.RequiresSpecialDigestion)
return false;
return false;
return digestible;
}
@@ -462,14 +458,14 @@ public sealed class FoodSystem : EntitySystem
/// <summary>
/// Block ingestion attempts based on the equipped mask or head-wear
/// </summary>
private void OnInventoryIngestAttempt(EntityUid uid, InventoryComponent component, IngestionAttemptEvent args)
private void OnInventoryIngestAttempt(Entity<InventoryComponent> entity, ref IngestionAttemptEvent args)
{
if (args.Cancelled)
return;
IngestionBlockerComponent? blocker;
if (_inventory.TryGetSlotEntity(uid, "mask", out var maskUid) &&
if (_inventory.TryGetSlotEntity(entity.Owner, "mask", out var maskUid) &&
TryComp(maskUid, out blocker) &&
blocker.Enabled)
{
@@ -478,7 +474,7 @@ public sealed class FoodSystem : EntitySystem
return;
}
if (_inventory.TryGetSlotEntity(uid, "head", out var headUid) &&
if (_inventory.TryGetSlotEntity(entity.Owner, "head", out var headUid) &&
TryComp(headUid, out blocker) &&
blocker.Enabled)
{
@@ -516,7 +512,7 @@ public sealed class FoodSystem : EntitySystem
if (!Resolve(uid, ref comp))
return 0;
if (!_solutionContainer.TryGetSolution(uid, comp.Solution, out var solution) || solution.Volume == 0)
if (!_solutionContainer.TryGetSolution(uid, comp.Solution, out _, out var solution) || solution.Volume == 0)
return 0;
// eat all in 1 go, so non empty is 1 bite

View File

@@ -1,7 +1,6 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Examine;
using Content.Shared.FixedPoint;
using Content.Shared.Hands.EntitySystems;
@@ -9,7 +8,6 @@ using Content.Shared.Interaction;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -29,12 +27,12 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<SliceableFoodComponent, ComponentStartup>(OnComponentStartup);
}
private void OnInteractUsing(EntityUid uid, SliceableFoodComponent component, InteractUsingEvent args)
private void OnInteractUsing(Entity<SliceableFoodComponent> entity, ref InteractUsingEvent args)
{
if (args.Handled)
return;
if (TrySliceFood(uid, args.User, args.Used, component))
if (TrySliceFood(entity, args.User, args.Used, entity.Comp))
args.Handled = true;
}
@@ -47,7 +45,7 @@ namespace Content.Server.Nutrition.EntitySystems
return false;
}
if (!_solutionContainerSystem.TryGetSolution(uid, food.Solution, out var solution))
if (!_solutionContainerSystem.TryGetSolution(uid, food.Solution, out var soln, out var solution))
{
return false;
}
@@ -59,8 +57,7 @@ namespace Content.Server.Nutrition.EntitySystems
var sliceUid = Slice(uid, user, component, transform);
var lostSolution = _solutionContainerSystem.SplitSolution(uid, solution,
solution.Volume / FixedPoint2.New(component.Count));
var lostSolution = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume / FixedPoint2.New(component.Count));
// Fill new slice
FillSlice(sliceUid, lostSolution);
@@ -137,27 +134,26 @@ namespace Content.Server.Nutrition.EntitySystems
{
// Replace all reagents on prototype not just copying poisons (example: slices of eaten pizza should have less nutrition)
if (TryComp<FoodComponent>(sliceUid, out var sliceFoodComp) &&
_solutionContainerSystem.TryGetSolution(sliceUid, sliceFoodComp.Solution, out var itsSolution))
_solutionContainerSystem.TryGetSolution(sliceUid, sliceFoodComp.Solution, out var itsSoln, out var itsSolution))
{
_solutionContainerSystem.RemoveAllSolution(sliceUid, itsSolution);
_solutionContainerSystem.RemoveAllSolution(itsSoln.Value);
var lostSolutionPart = solution.SplitSolution(itsSolution.AvailableVolume);
_solutionContainerSystem.TryAddSolution(sliceUid, itsSolution, lostSolutionPart);
_solutionContainerSystem.TryAddSolution(itsSoln.Value, lostSolutionPart);
}
}
private void OnComponentStartup(EntityUid uid, SliceableFoodComponent component, ComponentStartup args)
private void OnComponentStartup(Entity<SliceableFoodComponent> entity, ref ComponentStartup args)
{
component.Count = component.TotalCount;
var foodComp = EnsureComp<FoodComponent>(uid);
entity.Comp.Count = entity.Comp.TotalCount;
EnsureComp<SolutionContainerManagerComponent>(uid);
_solutionContainerSystem.EnsureSolution(uid, foodComp.Solution);
var foodComp = EnsureComp<FoodComponent>(entity);
_solutionContainerSystem.EnsureSolution(entity.Owner, foodComp.Solution);
}
private void OnExamined(EntityUid uid, SliceableFoodComponent component, ExaminedEvent args)
private void OnExamined(Entity<SliceableFoodComponent> entity, ref ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("sliceable-food-component-on-examine-remaining-slices-text", ("remainingCount", component.Count)));
args.PushMarkup(Loc.GetString("sliceable-food-component-on-examine-remaining-slices-text", ("remainingCount", entity.Comp.Count)));
}
}
}

View File

@@ -1,6 +1,6 @@
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components;
using Content.Shared.Smoking;
using Content.Shared.Temperature;
@@ -16,27 +16,27 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<CigarComponent, AfterInteractEvent>(OnCigarAfterInteract);
}
private void OnCigarActivatedEvent(EntityUid uid, CigarComponent component, ActivateInWorldEvent args)
private void OnCigarActivatedEvent(Entity<CigarComponent> entity, ref ActivateInWorldEvent args)
{
if (args.Handled)
return;
if (!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable))
if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Lit)
return;
SetSmokableState(uid, SmokableState.Burnt, smokable);
SetSmokableState(entity, SmokableState.Burnt, smokable);
args.Handled = true;
}
private void OnCigarInteractUsingEvent(EntityUid uid, CigarComponent component, InteractUsingEvent args)
private void OnCigarInteractUsingEvent(Entity<CigarComponent> entity, ref InteractUsingEvent args)
{
if (args.Handled)
return;
if (!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable))
if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Unlit)
@@ -48,16 +48,16 @@ namespace Content.Server.Nutrition.EntitySystems
if (!isHotEvent.IsHot)
return;
SetSmokableState(uid, SmokableState.Lit, smokable);
SetSmokableState(entity, SmokableState.Lit, smokable);
args.Handled = true;
}
public void OnCigarAfterInteract(EntityUid uid, CigarComponent component, AfterInteractEvent args)
public void OnCigarAfterInteract(Entity<CigarComponent> entity, ref AfterInteractEvent args)
{
var targetEntity = args.Target;
if (targetEntity == null ||
!args.CanReach ||
!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable) ||
!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable) ||
smokable.State == SmokableState.Lit)
return;
@@ -67,13 +67,13 @@ namespace Content.Server.Nutrition.EntitySystems
if (!isHotEvent.IsHot)
return;
SetSmokableState(uid, SmokableState.Lit, smokable);
SetSmokableState(entity, SmokableState.Lit, smokable);
args.Handled = true;
}
private void OnCigarSolutionEmptyEvent(EntityUid uid, CigarComponent component, SmokableSolutionEmptyEvent args)
private void OnCigarSolutionEmptyEvent(Entity<CigarComponent> entity, ref SmokableSolutionEmptyEvent args)
{
SetSmokableState(uid, SmokableState.Burnt);
SetSmokableState(entity, SmokableState.Burnt);
}
}
}

View File

@@ -1,8 +1,8 @@
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components;
using Content.Shared.Smoking;
using Content.Shared.Temperature;
@@ -20,17 +20,17 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<SmokingPipeComponent, ComponentInit>(OnComponentInit);
}
public void OnComponentInit(EntityUid uid, SmokingPipeComponent pipe, ComponentInit args)
public void OnComponentInit(Entity<SmokingPipeComponent> entity, ref ComponentInit args)
{
_itemSlotsSystem.AddItemSlot(uid, SmokingPipeComponent.BowlSlotId, pipe.BowlSlot);
_itemSlotsSystem.AddItemSlot(entity, SmokingPipeComponent.BowlSlotId, entity.Comp.BowlSlot);
}
private void OnPipeInteractUsingEvent(EntityUid uid, SmokingPipeComponent component, InteractUsingEvent args)
private void OnPipeInteractUsingEvent(Entity<SmokingPipeComponent> entity, ref InteractUsingEvent args)
{
if (args.Handled)
return;
if (!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable))
if (!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable))
return;
if (smokable.State != SmokableState.Unlit)
@@ -42,17 +42,17 @@ namespace Content.Server.Nutrition.EntitySystems
if (!isHotEvent.IsHot)
return;
if (TryTransferReagents(component, smokable))
SetSmokableState(uid, SmokableState.Lit, smokable);
if (TryTransferReagents(entity.Comp, smokable))
SetSmokableState(entity, SmokableState.Lit, smokable);
args.Handled = true;
}
public void OnPipeAfterInteract(EntityUid uid, SmokingPipeComponent component, AfterInteractEvent args)
public void OnPipeAfterInteract(Entity<SmokingPipeComponent> entity, ref AfterInteractEvent args)
{
var targetEntity = args.Target;
if (targetEntity == null ||
!args.CanReach ||
!EntityManager.TryGetComponent(uid, out SmokableComponent? smokable) ||
!EntityManager.TryGetComponent(entity, out SmokableComponent? smokable) ||
smokable.State == SmokableState.Lit)
return;
@@ -62,15 +62,15 @@ namespace Content.Server.Nutrition.EntitySystems
if (!isHotEvent.IsHot)
return;
if(TryTransferReagents(component, smokable))
SetSmokableState(uid, SmokableState.Lit, smokable);
if (TryTransferReagents(entity.Comp, smokable))
SetSmokableState(entity, SmokableState.Lit, smokable);
args.Handled = true;
}
private void OnPipeSolutionEmptyEvent(EntityUid uid, SmokingPipeComponent component, SmokableSolutionEmptyEvent args)
private void OnPipeSolutionEmptyEvent(Entity<SmokingPipeComponent> entity, ref SmokableSolutionEmptyEvent args)
{
_itemSlotsSystem.SetLock(component.Owner, component.BowlSlot, false);
SetSmokableState(uid, SmokableState.Unlit);
_itemSlotsSystem.SetLock(entity, entity.Comp.BowlSlot, false);
SetSmokableState(entity, SmokableState.Unlit);
}
// Convert smokable item into reagents to be smoked
@@ -82,12 +82,13 @@ namespace Content.Server.Nutrition.EntitySystems
EntityUid contents = component.BowlSlot.Item.Value;
if (!TryComp<SolutionContainerManagerComponent>(contents, out var reagents) ||
!_solutionContainerSystem.TryGetSolution(smokable.Owner, smokable.Solution, out var pipeSolution))
!_solutionContainerSystem.TryGetSolution(smokable.Owner, smokable.Solution, out var pipeSolution, out _))
return false;
foreach (var reagentSolution in reagents.Solutions)
foreach (var (_, soln) in _solutionContainerSystem.EnumerateSolutions((contents, reagents)))
{
_solutionContainerSystem.TryAddSolution(smokable.Owner, pipeSolution, reagentSolution.Value);
var reagentSolution = soln.Comp.Solution;
_solutionContainerSystem.TryAddSolution(pipeSolution.Value, reagentSolution);
}
EntityManager.DeleteEntity(contents);

View File

@@ -1,18 +1,18 @@
using Content.Server.Nutrition.Components;
using Content.Server.Body.Components;
using Content.Shared.Interaction;
using Content.Server.DoAfter;
using System.Threading;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Damage;
using Content.Server.Popups;
using Content.Shared.IdentityManagement;
using Content.Shared.DoAfter;
using Content.Shared.Emag.Systems;
using Content.Shared.Emag.Components;
using Content.Shared.Nutrition;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.DoAfter;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Emag.Components;
using Content.Shared.Emag.Systems;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Nutrition;
using System.Threading;
/// <summary>
/// System for vapes
@@ -35,16 +35,14 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<VapeComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnVapeInteraction(EntityUid uid, VapeComponent comp, AfterInteractEvent args)
private void OnVapeInteraction(Entity<VapeComponent> entity, ref AfterInteractEvent args)
{
_solutionContainerSystem.TryGetRefillableSolution(uid, out var solution);
var delay = comp.Delay;
var delay = entity.Comp.Delay;
var forced = true;
var exploded = false;
if (!args.CanReach
|| solution == null
|| !_solutionContainerSystem.TryGetRefillableSolution(entity.Owner, out _, out var solution)
|| !HasComp<BloodstreamComponent>(args.Target)
|| _foodSystem.IsMouthBlocked(args.Target.Value, args.User))
{
@@ -61,14 +59,14 @@ namespace Content.Server.Nutrition.EntitySystems
if (args.Target == args.User)
{
delay = comp.UserDelay;
delay = entity.Comp.UserDelay;
forced = false;
}
if (comp.ExplodeOnUse || HasComp<EmaggedComponent>(uid))
if (entity.Comp.ExplodeOnUse || HasComp<EmaggedComponent>(entity.Owner))
{
_explosionSystem.QueueExplosion(uid, "Default", comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
EntityManager.DeleteEntity(uid);
_explosionSystem.QueueExplosion(entity.Owner, "Default", entity.Comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
EntityManager.DeleteEntity(entity);
exploded = true;
}
else
@@ -80,11 +78,11 @@ namespace Content.Server.Nutrition.EntitySystems
// just re-use the existing RiggableSystem.
foreach (var name in solution.Contents)
{
if (name.Reagent.Prototype != comp.SolutionNeeded)
if (name.Reagent.Prototype != entity.Comp.SolutionNeeded)
{
exploded = true;
_explosionSystem.QueueExplosion(uid, "Default", comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
EntityManager.DeleteEntity(uid);
_explosionSystem.QueueExplosion(entity.Owner, "Default", entity.Comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
EntityManager.DeleteEntity(entity);
break;
}
}
@@ -113,7 +111,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (!exploded)
{
var vapeDoAfterEvent = new VapeDoAfterEvent(solution, forced);
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, delay, vapeDoAfterEvent, uid, target: args.Target, used: uid)
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, delay, vapeDoAfterEvent, entity.Owner, target: args.Target, used: entity.Owner)
{
BreakOnTargetMove = true,
BreakOnUserMove = false,
@@ -121,9 +119,9 @@ namespace Content.Server.Nutrition.EntitySystems
});
}
args.Handled = true;
}
}
private void OnVapeDoAfter(EntityUid uid, VapeComponent comp, VapeDoAfterEvent args)
private void OnVapeDoAfter(Entity<VapeComponent> entity, ref VapeDoAfterEvent args)
{
if (args.Handled
|| args.Args.Target == null)
@@ -136,10 +134,10 @@ namespace Content.Server.Nutrition.EntitySystems
}
//Smoking kills(your lungs, but there is no organ damage yet)
_damageableSystem.TryChangeDamage(args.Args.Target.Value, comp.Damage, true);
_damageableSystem.TryChangeDamage(args.Args.Target.Value, entity.Comp.Damage, true);
var merger = new GasMixture(1) { Temperature = args.Solution.Temperature};
merger.SetMoles(comp.GasType, args.Solution.Volume.Value / comp.ReductionFactor);
var merger = new GasMixture(1) { Temperature = args.Solution.Temperature };
merger.SetMoles(entity.Comp.GasType, args.Solution.Volume.Value / entity.Comp.ReductionFactor);
_atmosphereSystem.Merge(environment, merger);
@@ -165,9 +163,9 @@ namespace Content.Server.Nutrition.EntitySystems
args.Args.Target.Value);
}
}
private void OnEmagged(EntityUid uid, VapeComponent component, ref GotEmaggedEvent args)
private void OnEmagged(Entity<VapeComponent> entity, ref GotEmaggedEvent args)
{
args.Handled = true;
}
}
}
}

View File

@@ -1,22 +1,22 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Shared.Nutrition.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Forensics;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Clothing.Components;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
using Content.Shared.Nutrition.Components;
using Content.Shared.Smoking;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using System.Linq;
using Content.Shared.Inventory.Events;
using Content.Server.Forensics;
namespace Content.Server.Nutrition.EntitySystems
{
@@ -79,21 +79,21 @@ namespace Content.Server.Nutrition.EntitySystems
_active.Remove(uid);
}
private void OnSmokableIsHotEvent(EntityUid uid, SmokableComponent component, IsHotEvent args)
private void OnSmokableIsHotEvent(Entity<SmokableComponent> entity, ref IsHotEvent args)
{
args.IsHot = component.State == SmokableState.Lit;
args.IsHot = entity.Comp.State == SmokableState.Lit;
}
private void OnSmokableShutdownEvent(EntityUid uid, SmokableComponent component, ComponentShutdown args)
private void OnSmokableShutdownEvent(Entity<SmokableComponent> entity, ref ComponentShutdown args)
{
_active.Remove(uid);
_active.Remove(entity);
}
private void OnSmokeableEquipEvent(EntityUid uid, SmokableComponent component, GotEquippedEvent args)
private void OnSmokeableEquipEvent(Entity<SmokableComponent> entity, ref GotEquippedEvent args)
{
if (args.Slot == "mask")
{
_forensics.TransferDna(uid, args.Equipee, false);
_forensics.TransferDna(entity.Owner, args.Equipee, false);
}
}
@@ -113,7 +113,7 @@ namespace Content.Server.Nutrition.EntitySystems
continue;
}
if (!_solutionContainerSystem.TryGetSolution(uid, smokable.Solution, out var solution))
if (!_solutionContainerSystem.TryGetSolution(uid, smokable.Solution, out var soln, out var solution))
{
_active.Remove(uid);
continue;
@@ -123,14 +123,14 @@ namespace Content.Server.Nutrition.EntitySystems
{
var transform = Transform(uid);
if (transform.GridUid is {} gridUid)
if (transform.GridUid is { } gridUid)
{
var position = _transformSystem.GetGridOrMapTilePosition(uid, transform);
_atmos.HotspotExpose(gridUid, position, smokable.ExposeTemperature, smokable.ExposeVolume, uid, true);
}
}
var inhaledSolution = _solutionContainerSystem.SplitSolution(uid, solution, smokable.InhaleAmount * _timer);
var inhaledSolution = _solutionContainerSystem.SplitSolution(soln.Value, smokable.InhaleAmount * _timer);
if (solution.Volume == FixedPoint2.Zero)
{

View File

@@ -1,3 +1,4 @@
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
@@ -15,37 +16,37 @@ namespace Content.Server.Nutrition.EntitySystems
{
base.Initialize();
SubscribeLocalEvent<TrashOnSolutionEmptyComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<TrashOnSolutionEmptyComponent, SolutionChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<TrashOnSolutionEmptyComponent, SolutionContainerChangedEvent>(OnSolutionChange);
}
public void OnStartup(EntityUid uid, TrashOnSolutionEmptyComponent component, ComponentStartup args)
public void OnStartup(Entity<TrashOnSolutionEmptyComponent> entity, ref ComponentStartup args)
{
CheckSolutions(component);
CheckSolutions(entity);
}
public void OnSolutionChange(EntityUid uid, TrashOnSolutionEmptyComponent component, SolutionChangedEvent args)
public void OnSolutionChange(Entity<TrashOnSolutionEmptyComponent> entity, ref SolutionContainerChangedEvent args)
{
CheckSolutions(component);
CheckSolutions(entity);
}
public void CheckSolutions(TrashOnSolutionEmptyComponent component)
public void CheckSolutions(Entity<TrashOnSolutionEmptyComponent> entity)
{
if (!EntityManager.HasComponent<SolutionContainerManagerComponent>((component).Owner))
if (!EntityManager.HasComponent<SolutionContainerManagerComponent>(entity))
return;
if (_solutionContainerSystem.TryGetSolution(component.Owner, component.Solution, out var solution))
UpdateTags(component, solution);
if (_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var solution))
UpdateTags(entity, solution);
}
public void UpdateTags(TrashOnSolutionEmptyComponent component, Solution solution)
public void UpdateTags(Entity<TrashOnSolutionEmptyComponent> entity, Solution solution)
{
if (solution.Volume <= 0)
{
_tagSystem.AddTag(component.Owner, "Trash");
_tagSystem.AddTag(entity.Owner, "Trash");
return;
}
if (_tagSystem.HasTag(component.Owner, "Trash"))
_tagSystem.RemoveTag(component.Owner, "Trash");
if (_tagSystem.HasTag(entity.Owner, "Trash"))
_tagSystem.RemoveTag(entity.Owner, "Trash");
}
}
}