Revert 'Revert 'Solution Entities'' (#23168)

This commit is contained in:
TemporalOroboros
2023-12-29 04:47:43 -08:00
committed by GitHub
parent 93e1af2f8d
commit d23c8d5c19
180 changed files with 3541 additions and 2956 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Database;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
@@ -28,7 +28,7 @@ public sealed class LubeSystem : EntitySystem
SubscribeLocalEvent<LubeComponent, AfterInteractEvent>(OnInteract, after: new[] { typeof(OpenableSystem) });
}
private void OnInteract(EntityUid uid, LubeComponent component, AfterInteractEvent args)
private void OnInteract(Entity<LubeComponent> entity, ref AfterInteractEvent args)
{
if (args.Handled)
return;
@@ -36,10 +36,10 @@ public sealed class LubeSystem : EntitySystem
if (!args.CanReach || args.Target is not { Valid: true } target)
return;
if (TryLube(uid, component, target, args.User))
if (TryLube(entity, target, args.User))
{
args.Handled = true;
_audio.PlayPvs(component.Squeeze, uid);
_audio.PlayPvs(entity.Comp.Squeeze, entity);
_popup.PopupEntity(Loc.GetString("lube-success", ("target", Identity.Entity(target, EntityManager))), args.User, args.User, PopupType.Medium);
}
else
@@ -48,22 +48,22 @@ public sealed class LubeSystem : EntitySystem
}
}
private bool TryLube(EntityUid uid, LubeComponent component, EntityUid target, EntityUid actor)
private bool TryLube(Entity<LubeComponent> lube, EntityUid target, EntityUid actor)
{
if (HasComp<LubedComponent>(target) || !HasComp<ItemComponent>(target))
{
return false;
}
if (HasComp<ItemComponent>(target) && _solutionContainer.TryGetSolution(uid, component.Solution, out var solution))
if (HasComp<ItemComponent>(target) && _solutionContainer.TryGetSolution(lube.Owner, lube.Comp.Solution, out _, out var solution))
{
var quantity = solution.RemoveReagent(component.Reagent, component.Consumption);
var quantity = solution.RemoveReagent(lube.Comp.Reagent, lube.Comp.Consumption);
if (quantity > 0)
{
var lubed = EnsureComp<LubedComponent>(target);
lubed.SlipsLeft = _random.Next(component.MinSlips * quantity.Int(), component.MaxSlips * quantity.Int());
lubed.SlipStrength = component.SlipStrength;
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(actor):actor} lubed {ToPrettyString(target):subject} with {ToPrettyString(uid):tool}");
lubed.SlipsLeft = _random.Next(lube.Comp.MinSlips * quantity.Int(), lube.Comp.MaxSlips * quantity.Int());
lubed.SlipStrength = lube.Comp.SlipStrength;
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(actor):actor} lubed {ToPrettyString(target):subject} with {ToPrettyString(lube.Owner):tool}");
return true;
}
}