Allow solutions to store extra reagent data (#19323)

This commit is contained in:
Leon Friedrich
2023-09-05 09:55:10 +12:00
committed by GitHub
parent a6b81058d0
commit e4ca6f4fb9
52 changed files with 932 additions and 538 deletions

View File

@@ -4,6 +4,7 @@ using Content.Server.Explosion.EntitySystems;
using Content.Server.Kitchen.Components;
using Content.Server.Power.Components;
using Content.Server.Stunnable.Components;
using Content.Shared.Chemistry.Components;
using Content.Shared.Database;
using Content.Shared.Rejuvenate;
@@ -47,27 +48,19 @@ public sealed class RiggableSystem : EntitySystem
private void OnSolutionChanged(EntityUid uid, RiggableComponent component, SolutionChangedEvent args)
{
if (TryComp<BatteryComponent>(uid, out var battery))
{
IsRigged(uid, args);
}
if (args.SolutionId != component.Solution)
return;
if (component.IsRigged)
var wasRigged = component.IsRigged;
var quantity = args.Solution.GetReagentQuantity(component.RequiredQuantity.Reagent);
component.IsRigged = quantity >= component.RequiredQuantity.Quantity;
if (component.IsRigged && !wasRigged)
{
_adminLogger.Add(LogType.Explosion, LogImpact.Medium, $"{ToPrettyString(uid)} has been rigged up to explode when used.");
}
}
public void IsRigged(EntityUid uid, SolutionChangedEvent args)
{
if (TryComp<RiggableComponent>(uid, out var riggableComp))
{
riggableComp.IsRigged = _solutionsSystem.TryGetSolution(uid, RiggableComponent.SolutionName, out var solution)
&& solution.TryGetReagent("Plasma", out var plasma)
&& plasma >= 5;
}
}
public void Explode(EntityUid uid, BatteryComponent? battery = null, EntityUid? cause = null)
{
if (!Resolve(uid, ref battery))