Merge remote-tracking branch 'upstream/stable' into ed-25-08-2025-upstream-sync
# Conflicts: # .github/CODEOWNERS # Content.Client/UserInterface/Systems/Actions/Controls/ActionButton.cs # Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs # Content.Server/Chat/Systems/ChatSystem.cs # Content.Server/Explosion/EntitySystems/TriggerSystem.cs # Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs # Content.Shared/Lock/LockSystem.cs # Content.Shared/Nutrition/Components/FoodComponent.cs # Content.Shared/Speech/ListenEvent.cs # Resources/Prototypes/Entities/Effects/admin_triggers.yml
This commit is contained in:
@@ -22,6 +22,7 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedDestructibleSystem _destroy = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
@@ -64,35 +65,31 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
if (args.Cancelled || args.Handled || args.Args.Target == null)
|
||||
return;
|
||||
|
||||
if (TrySliceFood(entity, args.User, args.Used, entity.Comp))
|
||||
if (TrySliceFood(entity.Owner, args.User, args.Used))
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private bool TrySliceFood(EntityUid uid,
|
||||
private bool TrySliceFood(Entity<TransformComponent?, SliceableFoodComponent?, EdibleComponent?> entity,
|
||||
EntityUid user,
|
||||
EntityUid? usedItem,
|
||||
SliceableFoodComponent? component = null,
|
||||
FoodComponent? food = null,
|
||||
TransformComponent? transform = null)
|
||||
EntityUid? usedItem)
|
||||
{
|
||||
if (!Resolve(uid, ref component, ref food, ref transform) ||
|
||||
string.IsNullOrEmpty(component.Slice))
|
||||
if (!Resolve(entity, ref entity.Comp1, ref entity.Comp2, ref entity.Comp3) || string.IsNullOrEmpty(entity.Comp2.Slice))
|
||||
return false;
|
||||
|
||||
if (!_solutionContainer.TryGetSolution(uid, food.Solution, out var soln, out var solution))
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp3.Solution, out var soln, out var solution))
|
||||
return false;
|
||||
|
||||
if (!TryComp<UtensilComponent>(usedItem, out var utensil) || (utensil.Types & UtensilType.Knife) == 0)
|
||||
return false;
|
||||
|
||||
//CP14 transfer flavors
|
||||
TryComp<FlavorProfileComponent>(uid, out var flavorProfile);
|
||||
TryComp<FlavorProfileComponent>(entity, out var flavorProfile);
|
||||
//CP14 end
|
||||
|
||||
var sliceVolume = solution.Volume / FixedPoint2.New(component.TotalCount);
|
||||
for (int i = 0; i < component.TotalCount; i++)
|
||||
var sliceVolume = solution.Volume / FixedPoint2.New(entity.Comp2.TotalCount);
|
||||
for (int i = 0; i < entity.Comp2.TotalCount; i++)
|
||||
{
|
||||
var sliceUid = Slice(uid, user, component, transform);
|
||||
var sliceUid = Slice(entity, user);
|
||||
|
||||
var lostSolution =
|
||||
_solutionContainer.SplitSolution(soln.Value, sliceVolume);
|
||||
@@ -112,11 +109,11 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
FillSlice(sliceUid, lostSolution);
|
||||
}
|
||||
|
||||
_audio.PlayPvs(component.Sound, transform.Coordinates, AudioParams.Default.WithVolume(-2));
|
||||
_audio.PlayPvs(entity.Comp2.Sound, entity.Comp1.Coordinates, AudioParams.Default.WithVolume(-2));
|
||||
var ev = new SliceFoodEvent();
|
||||
RaiseLocalEvent(uid, ref ev);
|
||||
RaiseLocalEvent(entity, ref ev);
|
||||
|
||||
DeleteFood(uid, user, food);
|
||||
DeleteFood(entity, user);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,19 +121,16 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
/// Create a new slice in the world and returns its entity.
|
||||
/// The solutions must be set afterwards.
|
||||
/// </summary>
|
||||
public EntityUid Slice(EntityUid uid,
|
||||
EntityUid user,
|
||||
SliceableFoodComponent? comp = null,
|
||||
TransformComponent? transform = null)
|
||||
public EntityUid Slice(Entity<TransformComponent?, SliceableFoodComponent?> entity, EntityUid user)
|
||||
{
|
||||
if (!Resolve(uid, ref comp, ref transform))
|
||||
if (!Resolve(entity, ref entity.Comp1, ref entity.Comp2))
|
||||
return EntityUid.Invalid;
|
||||
|
||||
var sliceUid = Spawn(comp.Slice, _transform.GetMapCoordinates(uid));
|
||||
var sliceUid = Spawn(entity.Comp2.Slice, _transform.GetMapCoordinates((entity, entity.Comp1)));
|
||||
|
||||
// try putting the slice into the container if the food being sliced is in a container!
|
||||
// this lets you do things like slice a pizza up inside of a hot food cart without making a food-everywhere mess
|
||||
_transform.DropNextTo(sliceUid, (uid, transform));
|
||||
_transform.DropNextTo(sliceUid, entity);
|
||||
_transform.SetLocalRotation(sliceUid, 0);
|
||||
|
||||
if (!_container.IsEntityOrParentInContainer(sliceUid))
|
||||
@@ -149,7 +143,7 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
return sliceUid;
|
||||
}
|
||||
|
||||
private void DeleteFood(EntityUid uid, EntityUid user, FoodComponent foodComp)
|
||||
private void DeleteFood(EntityUid uid, EntityUid user)
|
||||
{
|
||||
var ev = new BeforeFullySlicedEvent
|
||||
{
|
||||
@@ -159,38 +153,32 @@ public sealed class SliceableFoodSystem : EntitySystem
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
var dev = new DestructionEventArgs();
|
||||
RaiseLocalEvent(uid, dev);
|
||||
|
||||
// Locate the sliced food and spawn its trash
|
||||
foreach (var trash in foodComp.Trash)
|
||||
{
|
||||
var trashUid = Spawn(trash, _transform.GetMapCoordinates(uid));
|
||||
|
||||
// try putting the trash in the food's container too, to be consistent with slice spawning?
|
||||
_transform.DropNextTo(trashUid, uid);
|
||||
_transform.SetLocalRotation(trashUid, 0);
|
||||
}
|
||||
|
||||
QueueDel(uid);
|
||||
_destroy.DestroyEntity(uid);
|
||||
}
|
||||
|
||||
private void FillSlice(EntityUid sliceUid, Solution solution)
|
||||
private void FillSlice(Entity<EdibleComponent?> slice, Solution solution)
|
||||
{
|
||||
// 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) &&
|
||||
_solutionContainer.TryGetSolution(sliceUid, sliceFoodComp.Solution, out var itsSoln, out var itsSolution))
|
||||
{
|
||||
_solutionContainer.RemoveAllSolution(itsSoln.Value);
|
||||
if (!Resolve(slice, ref slice.Comp, false))
|
||||
return;
|
||||
|
||||
var lostSolutionPart = solution.SplitSolution(itsSolution.AvailableVolume);
|
||||
_solutionContainer.TryAddSolution(itsSoln.Value, lostSolutionPart);
|
||||
}
|
||||
// Replace all reagents on prototype not just copying poisons (example: slices of eaten pizza should have less nutrition)
|
||||
if (!_solutionContainer.TryGetSolution(slice.Owner, slice.Comp.Solution, out var itsSoln, out var itsSolution))
|
||||
return;
|
||||
|
||||
_solutionContainer.RemoveAllSolution(itsSoln.Value);
|
||||
|
||||
var lostSolutionPart = solution.SplitSolution(itsSolution.AvailableVolume);
|
||||
_solutionContainer.TryAddSolution(itsSoln.Value, lostSolutionPart);
|
||||
}
|
||||
|
||||
private void OnComponentStartup(Entity<SliceableFoodComponent> entity, ref ComponentStartup args)
|
||||
{
|
||||
var foodComp = EnsureComp<FoodComponent>(entity);
|
||||
// TODO: When Food Component is fully kill delete this awful method
|
||||
// This exists just to make tests fail I guess, awesome!
|
||||
// If you're here because your test just failed, make sure that:
|
||||
// Your food has the edible component
|
||||
// The solution listed in the edible component exists
|
||||
var foodComp = EnsureComp<EdibleComponent>(entity);
|
||||
_solutionContainer.EnsureSolution(entity.Owner, foodComp.Solution, out _);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user