Files
Delta-v/Content.Shared/Chemistry/EntitySystems/RehydratableSystem.cs
T
84c0b3e895 snipe qol prs from upstream (#2614)
* Remove discard functionality from the ChemMaster

This duplicates other methods of discarding chemicals, including
the drain conventionally given to chemistry labs.

Any problems it solves are miniscule compared to the severe UI error
that is having a destructive action without confirmation attached
to a mode, the most common source of user error.

* Improve animal cube interactions (#31668)

* Working on dehydrate recipes to renew animal cubes

* Added remaining cube dehydration recipes

* Add OnExamine to RehydratableSystem.cs, need to add functionality to check total volume vs current volume to determine if 'soaked' text needs to be displayed

* Added logic to append text to the description when the wrong reagent has been added to a compressed animal cube

* Re-adding deleted summary

* Update default SolutionName to be correct

* Remove cube recipes to prevent infinite nutrient generation

* Add OnMicrowaved event to RehydratableSystem.cs in order to clear solution of cube when microwaved. CURRENT ERROR REQUIRES REFACTOR OF MICROWAVECOMPONENT

* Subscribe to microwave event

* Refactor of MicrowaveComponent.cs to be in shared folder, accessible to RehydratableSystem.cs. Updated imports

* Modify cube to only dehydrate in microwave when cooked for at least 5 seconds

* now using event to check access to fingerprint

* Tweak - Reflective vest and Energy Katana should reflect only in correct slots (#31902)

* ReflectComponentLogicFix
Added bool InRightPlace and updated relevant system

* Using SlotFlags

* prevent friendly fire for dragon/carp (#32231)

* add NoFriendlyFire

* make zombies use NoFriendlyFire

* no friendly fire for dragon

* let dragon kill naughty fish and validhunting syndies

* add button to print logprobe logs (#32255)

* add EntityName at the bottom of LogProbe

* add button to print logprobe logs

* Add camera mod to diagnostic hud (#32254)

* ai-glass

* weh to protect against bad grammar

* transmutation into diagnostic hud

* Apply forensics when loading with an ammo box

* inaprovaline metabolizes slower

* :trollface:

---------

Co-authored-by: Janet Blackquill <uhhadd@gmail.com>
Co-authored-by: Preston Smith <Blackfoot03@outlook.com>
Co-authored-by: YourUsername <you@example.com>
Co-authored-by: BIGZi0348 <svalker0348@gmail.com>
Co-authored-by: deltanedas <@deltanedas:kde.org>
Co-authored-by: ArZarLordOfMango <arzarchannel@gmail.com>
Co-authored-by: themias <themias5@gmail.com>
Co-authored-by: Alzore <blackern5000@gmail.com>
2025-01-05 03:55:34 +00:00

85 lines
3.3 KiB
C#

using Content.Shared.Administration.Logs;
using Content.Shared.Chemistry.Components;
using Content.Shared.Database;
using Content.Shared.FixedPoint;
using Content.Shared.Popups;
using Robust.Shared.Network;
using Robust.Shared.Random;
using Content.Shared.Examine;
using Content.Shared.Kitchen.Components;
namespace Content.Shared.Chemistry.EntitySystems;
public sealed class RehydratableSystem : EntitySystem
{
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutions = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RehydratableComponent, SolutionContainerChangedEvent>(OnSolutionChange);
SubscribeLocalEvent<RehydratableComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<RehydratableComponent, BeingMicrowavedEvent>(OnMicrowaved);
}
private void OnSolutionChange(Entity<RehydratableComponent> ent, ref SolutionContainerChangedEvent args)
{
var quantity = _solutions.GetTotalPrototypeQuantity(ent, ent.Comp.CatalystPrototype);
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(ent.Owner)} was hydrated, now contains a solution of: {SharedSolutionContainerSystem.ToPrettyString(args.Solution)}.");
if (quantity != FixedPoint2.Zero && quantity >= ent.Comp.CatalystMinimum)
{
Expand(ent);
}
}
private void OnMicrowaved(EntityUid uid, RehydratableComponent component, BeingMicrowavedEvent args)
{
if(args.Time <= 0)
return;
if (!_solutions.TryGetSolution(uid, component.SolutionName, out _, out var solution))
return;
solution.RemoveAllSolution();
}
private void OnExamine(EntityUid uid, RehydratableComponent component, ExaminedEvent args)
{
if (!_solutions.TryGetSolution(uid, component.SolutionName, out _, out var solution))
return;
// This will only be true if an incorrect reagent has been added to the cube
if (solution.Volume == solution.MaxVolume)
{
args.PushMarkup(Loc.GetString("rehydratable-component-soaked-message"));
}
}
// Try not to make this public if you can help it.
private void Expand(Entity<RehydratableComponent> ent)
{
if (_net.IsClient)
return;
var (uid, comp) = ent;
var randomMob = _random.Pick(comp.PossibleSpawns);
var target = Spawn(randomMob, Transform(uid).Coordinates);
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(ent.Owner)} has been hydrated correctly and spawned: {ToPrettyString(target)}.");
_popup.PopupEntity(Loc.GetString("rehydratable-component-expands-message", ("owner", uid)), target);
_xform.AttachToGridOrMap(target);
var ev = new GotRehydratedEvent(target);
RaiseLocalEvent(uid, ref ev);
// prevent double hydration while queued
RemComp<RehydratableComponent>(uid);
QueueDel(uid);
}
}