mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 08:07:28 +00:00
Reduce Triggers Boilerplate. (#41086)
* Push 1 * cleanup + master merge * launchontrigger * A crumb of cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
Vanessa
co-authored by
Princess Cheeseballs
parent
460bcebc2e
commit
e59a873ae6
@@ -1,31 +1,15 @@
|
||||
using Content.Shared.Trigger.Components.Effects;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
|
||||
namespace Content.Shared.Trigger.Systems;
|
||||
|
||||
public sealed class SolutionTriggerSystem : EntitySystem
|
||||
public sealed class SolutionTriggerSystem : XOnTriggerSystem<AddSolutionOnTriggerComponent>
|
||||
{
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
protected override void OnTrigger(Entity<AddSolutionOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AddSolutionOnTriggerComponent, TriggerEvent>(OnTriggered);
|
||||
}
|
||||
|
||||
private void OnTriggered(Entity<AddSolutionOnTriggerComponent> ent, ref TriggerEvent args)
|
||||
{
|
||||
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
|
||||
return;
|
||||
|
||||
var target = ent.Comp.TargetUser ? args.User : ent.Owner;
|
||||
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
if (!_solutionContainer.TryGetSolution(target.Value, ent.Comp.Solution, out var solutionRef, out _))
|
||||
if (!_solutionContainer.TryGetSolution(target, ent.Comp.Solution, out var solutionRef, out _))
|
||||
return;
|
||||
|
||||
_solutionContainer.AddSolution(solutionRef.Value, ent.Comp.AddedSolution);
|
||||
|
||||
Reference in New Issue
Block a user