* Creates Content.Shared.Chemistry.Solutions Copies Solution class to new namespace Obsoletes old Solution class * Switches over to the Solutions.Solution Solution * Creates Content.Shared.Chemistry.Containers Copies relevant components/systems to the new namespace Obsoletes old versions * Switches over to the Containers.XYZ namespace * Creates SolutionSystem and obsoletes old SolutionContainerSystem methods * Start using SolutionSystem for Solution manipulation * EnumerateSolutions * Move TryGetMixableSolution * Move EnsureSolution to Server * Create Solution Entities * Stop using obsolete solution system methods * Fix prototype component tests * Add using ..Audio.Systems; back * Wrap solution container slots in ContainerSlots * Actually add the slot to the solution container map * Dirty SolutionContainerComponent when ensuring solutions * Revert namespace changes * Remerge SolutionSystem and SolutionContainerSystem * SolutionContainerManagerComponent refactor * Avoid wrapping necessary code in DebugTools.Assert as it is removed when compiling for release * Readd examine reagent sorting * Fix errors * Poke tests * Fix solution names not being applied * Fix WoolyComponent including statement * Fix merge skew * Fix compile errors * Make reactions use solntities * Reindent solution class namespace * Field attribute changes * AutoGenerateComponentState for SolutionContainerComponent * SolutionContainerComponent -> ContainedSolutionComponent * ref ReactionAttemptEvent * Denetwork preinit solutions * Misc 1 * Nullable TryGetSolution out vars * Cache associated solutions * Fix merge skew * Use explicit regions in SharedSolutionContainerSystem.Capabilities * Add debug assert * Use explicit regions in SharedSolutionContainerSystem.Relay + ref SolutionContainerChangedEvent * ContainedSolutionComponent.Name -> ContainedSolutionComponent.ContainerName * SolutionComponent doc comments * Implicit DataField names and property purge * ReagentEffect DataField names * Local variables for readability * Sort using statements + Entity<T> event handlers * Fix compile erros * Fix compile errors --------- Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
100 lines
4.0 KiB
C#
100 lines
4.0 KiB
C#
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.Containers.ItemSlots;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
using Content.Shared.Rejuvenate;
|
|
using Content.Shared.Throwing;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Nutrition.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed class CreamPieSystem : SharedCreamPieSystem
|
|
{
|
|
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
|
|
[Dependency] private readonly PuddleSystem _puddle = default!;
|
|
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
|
|
[Dependency] private readonly TriggerSystem _trigger = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly PopupSystem _popup = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<CreamPieComponent, InteractUsingEvent>(OnInteractUsing);
|
|
SubscribeLocalEvent<CreamPiedComponent, RejuvenateEvent>(OnRejuvenate);
|
|
}
|
|
|
|
protected override void SplattedCreamPie(EntityUid uid, CreamPieComponent creamPie)
|
|
{
|
|
_audio.PlayPvs(_audio.GetSound(creamPie.Sound), uid, AudioParams.Default.WithVariation(0.125f));
|
|
|
|
if (EntityManager.TryGetComponent(uid, out FoodComponent? foodComp))
|
|
{
|
|
if (_solutions.TryGetSolution(uid, foodComp.Solution, out _, out var solution))
|
|
{
|
|
_puddle.TrySpillAt(uid, solution, out _, false);
|
|
}
|
|
if (!string.IsNullOrEmpty(foodComp.Trash))
|
|
{
|
|
EntityManager.SpawnEntity(foodComp.Trash, Transform(uid).Coordinates);
|
|
}
|
|
}
|
|
ActivatePayload(uid);
|
|
|
|
EntityManager.QueueDeleteEntity(uid);
|
|
}
|
|
|
|
private void OnInteractUsing(Entity<CreamPieComponent> entity, ref InteractUsingEvent args)
|
|
{
|
|
ActivatePayload(entity);
|
|
}
|
|
|
|
private void ActivatePayload(EntityUid uid)
|
|
{
|
|
if (_itemSlots.TryGetSlot(uid, CreamPieComponent.PayloadSlotName, out var itemSlot))
|
|
{
|
|
if (_itemSlots.TryEject(uid, itemSlot, user: null, out var item))
|
|
{
|
|
if (TryComp<OnUseTimerTriggerComponent>(item.Value, out var timerTrigger))
|
|
{
|
|
_trigger.HandleTimerTrigger(
|
|
item.Value,
|
|
null,
|
|
timerTrigger.Delay,
|
|
timerTrigger.BeepInterval,
|
|
timerTrigger.InitialBeepDelay,
|
|
timerTrigger.BeepSound);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void CreamedEntity(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args)
|
|
{
|
|
_popup.PopupEntity(Loc.GetString("cream-pied-component-on-hit-by-message", ("thrower", args.Thrown)), uid, args.Target);
|
|
var otherPlayers = Filter.Empty().AddPlayersByPvs(uid);
|
|
if (TryComp<ActorComponent>(args.Target, out var actor))
|
|
{
|
|
otherPlayers.RemovePlayer(actor.PlayerSession);
|
|
}
|
|
_popup.PopupEntity(Loc.GetString("cream-pied-component-on-hit-by-message-others", ("owner", uid), ("thrower", args.Thrown)), uid, otherPlayers, false);
|
|
}
|
|
|
|
private void OnRejuvenate(Entity<CreamPiedComponent> entity, ref RejuvenateEvent args)
|
|
{
|
|
SetCreamPied(entity, entity.Comp, false);
|
|
}
|
|
}
|
|
}
|