Spray Paint (Review Ready) (#23003)
* Spray Paint (Draft) * paint colors, paints in maints loot, cargo crate of paints. * fix * remove paint (sort of) * moved paintcleaner into own system * Moved paint to server (had to unfortunately) * doafter now breaks when moving away. * cant paint mobstatecomp * loads of fixes * fixes * fixes * nopaintshadercomp * fixes * fix * use locale for paint remove string * remove nopaintshadercomponent and use blacklist * remove enabled.true from visualizer * paint doafter event. * add verbs for paint and remove paint and icon for paint verb. * fixes * no longer replaces shader when shader exists. * replace forloop with foreach, check shader before adding and removing. * paint doafter now separate so no copy paste code * Entities in sprayed targets item slots are also now correctly sprayed. * fix * fix * fix airlock psray painter now removes painted before painting door. * spray paints now use openablecomponent. * fix * fix damn accesstypes. * fix * fix
This commit is contained in:
96
Content.Shared/Paint/PaintRemoverSystem.cs
Normal file
96
Content.Shared/Paint/PaintRemoverSystem.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Sprite;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.Paint;
|
||||
|
||||
/// <summary>
|
||||
/// Removes paint from an entity.
|
||||
/// </summary>
|
||||
public sealed class PaintRemoverSystem : SharedPaintSystem
|
||||
{
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PaintRemoverComponent, AfterInteractEvent>(OnInteract);
|
||||
SubscribeLocalEvent<PaintRemoverComponent, PaintRemoverDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<PaintRemoverComponent, GetVerbsEvent<UtilityVerb>>(OnPaintRemoveVerb);
|
||||
}
|
||||
|
||||
// When entity is painted, remove paint from that entity.
|
||||
private void OnInteract(EntityUid uid, PaintRemoverComponent component, AfterInteractEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (!args.CanReach || args.Target is not { Valid: true } target || !HasComp<PaintedComponent>(target))
|
||||
return;
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.CleanDelay, new PaintRemoverDoAfterEvent(), uid, args.Target, uid)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnTargetMove = true,
|
||||
MovementThreshold = 1.0f,
|
||||
});
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, PaintRemoverComponent component, DoAfterEvent args)
|
||||
{
|
||||
if (args.Cancelled || args.Handled || args.Args.Target == null)
|
||||
return;
|
||||
|
||||
if (args.Target is not { Valid: true } target)
|
||||
return;
|
||||
|
||||
if (!TryComp(target, out PaintedComponent? paint))
|
||||
return;
|
||||
|
||||
paint.Enabled = false;
|
||||
_audio.PlayPredicted(component.Sound, target, args.User);
|
||||
_popup.PopupClient(Loc.GetString("paint-removed", ("target", target)), args.User, args.User, PopupType.Medium);
|
||||
_appearanceSystem.SetData(target, PaintVisuals.Painted, false);
|
||||
RemComp<PaintedComponent>(target);
|
||||
Dirty(target, paint);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnPaintRemoveVerb(EntityUid uid, PaintRemoverComponent component, GetVerbsEvent<UtilityVerb> args)
|
||||
{
|
||||
if (!args.CanInteract || !args.CanAccess)
|
||||
return;
|
||||
|
||||
var paintremovalText = Loc.GetString("paint-remove-verb");
|
||||
|
||||
var verb = new UtilityVerb()
|
||||
{
|
||||
Act = () => {
|
||||
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.CleanDelay, new PaintRemoverDoAfterEvent(), uid, args.Target, uid)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnTargetMove = true,
|
||||
MovementThreshold = 1.0f,
|
||||
});
|
||||
},
|
||||
|
||||
Text = paintremovalText
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user