using Content.Server.Atmos.Piping.Components; using Content.Server.Atmos.Piping.EntitySystems; using Content.Shared.DoAfter; using Content.Shared.Interaction; using Content.Shared.SprayPainter; using Content.Shared.SprayPainter.Components; namespace Content.Server.SprayPainter; /// /// Handles spraying pipes using a spray painter. /// Airlocks are handled in shared. /// public sealed class SprayPainterSystem : SharedSprayPainterSystem { [Dependency] private readonly AtmosPipeColorSystem _pipeColor = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnPipeDoAfter); SubscribeLocalEvent(OnPipeInteract); } private void OnPipeDoAfter(Entity ent, ref SprayPainterPipeDoAfterEvent args) { if (args.Handled || args.Cancelled) return; if (args.Args.Target is not {} target) return; if (!TryComp(target, out var color)) return; Audio.PlayPvs(ent.Comp.SpraySound, ent); _pipeColor.SetColor(target, color, args.Color); args.Handled = true; } private void OnPipeInteract(Entity ent, ref InteractUsingEvent args) { if (args.Handled) return; if (!TryComp(args.Used, out var painter) || painter.PickedColor is not {} colorName) return; if (!painter.ColorPalette.TryGetValue(colorName, out var color)) return; var doAfterEventArgs = new DoAfterArgs(EntityManager, args.User, painter.PipeSprayTime, new SprayPainterPipeDoAfterEvent(color), args.Used, target: ent, used: args.Used) { BreakOnMove = true, BreakOnDamage = true, // multiple pipes can be sprayed at once just not the same one DuplicateCondition = DuplicateConditions.SameTarget, NeedHand = true, }; args.Handled = DoAfter.TryStartDoAfter(doAfterEventArgs); } }