Revert 'Revert 'Solution Entities'' (#23168)
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user