mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-05 13:57:29 +00:00
* Fix outdated component name in assaultbelt whitelist
RangedMagazine was replaced with BallisticAmmoProvider in the Gun
refactor (#8301)
* Move FlashOnTrigger, SmokeOnTrigger, Flash components to Shared
* Move LightReplacerComponent to Shared
* Move Utensil, Mousetrap components to Shared
* Move SprayPainterComponent to Shared
The PaintableAirlock tag has also been removed, as it was unused &
unnecessary, likely a vestige of spray painter development when the
PaintableAirlock component wasn't in Content.Shared.
* Add trivial Produce and Seed components to Client
This allows the plant bag and botanical belt whitelists to correctly
match produce and seeds on the client, fixing the extraneous "Can't
insert" message that previously appeared.
---------
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
(cherry picked from commit 9cd6e4dccd)
79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
using Content.Server.Nutrition.Components;
|
|
using Content.Shared.Nutrition.Components;
|
|
using Content.Shared.Nutrition.EntitySystems;
|
|
using Content.Server.Popups;
|
|
using Content.Shared.Interaction;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Nutrition.EntitySystems
|
|
{
|
|
/// <summary>
|
|
/// Handles usage of the utensils on the food items
|
|
/// </summary>
|
|
internal sealed class UtensilSystem : SharedUtensilSystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
[Dependency] private readonly FoodSystem _foodSystem = default!;
|
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<UtensilComponent, AfterInteractEvent>(OnAfterInteract);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Clicked with utensil
|
|
/// </summary>
|
|
private void OnAfterInteract(EntityUid uid, UtensilComponent component, AfterInteractEvent ev)
|
|
{
|
|
if (ev.Target == null || !ev.CanReach)
|
|
return;
|
|
|
|
var result = TryUseUtensil(ev.User, ev.Target.Value, component);
|
|
ev.Handled = result.Handled;
|
|
}
|
|
|
|
public (bool Success, bool Handled) TryUseUtensil(EntityUid user, EntityUid target, UtensilComponent component)
|
|
{
|
|
if (!EntityManager.TryGetComponent(target, out FoodComponent? food))
|
|
return (false, true);
|
|
|
|
//Prevents food usage with a wrong utensil
|
|
if ((food.Utensil & component.Types) == 0)
|
|
{
|
|
_popupSystem.PopupEntity(Loc.GetString("food-system-wrong-utensil", ("food", target), ("utensil", component.Owner)), user, user);
|
|
return (false, true);
|
|
}
|
|
|
|
if (!_interactionSystem.InRangeUnobstructed(user, target, popup: true))
|
|
return (false, true);
|
|
|
|
return _foodSystem.TryFeed(user, user, target, food);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Attempt to break the utensil after interaction.
|
|
/// </summary>
|
|
/// <param name="uid">Utensil.</param>
|
|
/// <param name="userUid">User of the utensil.</param>
|
|
public void TryBreak(EntityUid uid, EntityUid userUid, UtensilComponent? component = null)
|
|
{
|
|
if (!Resolve(uid, ref component))
|
|
return;
|
|
|
|
if (_robustRandom.Prob(component.BreakChance))
|
|
{
|
|
_audio.PlayPvs(component.BreakSound, userUid, AudioParams.Default.WithVolume(-2f));
|
|
EntityManager.DeleteEntity(uid);
|
|
}
|
|
}
|
|
}
|
|
}
|