diff --git a/Content.Client/Paint/PaintVisualizerSystem.cs b/Content.Client/Paint/PaintVisualizerSystem.cs index 6c99b2d35f0633..8d037811faba89 100644 --- a/Content.Client/Paint/PaintVisualizerSystem.cs +++ b/Content.Client/Paint/PaintVisualizerSystem.cs @@ -7,112 +7,108 @@ using Robust.Client.Graphics; using Robust.Shared.Prototypes; -namespace Content.Client.Paint -{ - public sealed class PaintedVisualizerSystem : VisualizerSystem - { - /// - /// Visualizer for Paint which applies a shader and colors the entity. - /// +namespace Content.Client.Paint; - [Dependency] private readonly SharedAppearanceSystem _appearance = default!; - [Dependency] private readonly IPrototypeManager _protoMan = default!; +public sealed class PaintedVisualizerSystem : VisualizerSystem +{ + /// + /// Visualizer for Paint which applies a shader and colors the entity. + /// - public ShaderInstance? Shader; // in Robust.Client.Graphics so cannot move to shared component. + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly IPrototypeManager _protoMan = default!; - public override void Initialize() - { - base.Initialize(); + public override void Initialize() + { + base.Initialize(); - SubscribeLocalEvent(OnHeldVisualsUpdated); - SubscribeLocalEvent(OnShutdown); - SubscribeLocalEvent(OnEquipmentVisualsUpdated); - } + SubscribeLocalEvent(OnHeldVisualsUpdated); + SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnEquipmentVisualsUpdated); + } - protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args) - { - // ShaderPrototype sadly in Robust.Client, cannot move to shared component. - Shader = _protoMan.Index(component.ShaderName).Instance(); + protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args) + { + var shader = _protoMan.Index(component.ShaderName).Instance(); - if (args.Sprite == null) - return; + if (args.Sprite == null) + return; - if (!_appearance.TryGetData(uid, PaintVisuals.Painted, out bool isPainted)) - return; + // What is this even doing? It's not even checking what the value is. + if (!_appearance.TryGetData(uid, PaintVisuals.Painted, out bool isPainted)) + return; - var sprite = args.Sprite; + var sprite = args.Sprite; + foreach (var spriteLayer in sprite.AllLayers) + { + if (spriteLayer is not Layer layer) + continue; - foreach (var spriteLayer in sprite.AllLayers) + if (layer.Shader == null) // If shader isn't null we dont want to replace the original shader. { - if (spriteLayer is not Layer layer) - continue; - - if (layer.Shader == null) // If shader isn't null we dont want to replace the original shader. - { - layer.Shader = Shader; - layer.Color = component.Color; - } + layer.Shader = shader; + layer.Color = component.Color; } } + } - private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args) - { - if (args.RevealedLayers.Count == 0) - return; + private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args) + { + if (args.RevealedLayers.Count == 0) + return; - if (!TryComp(args.User, out SpriteComponent? sprite)) - return; + if (!TryComp(args.User, out SpriteComponent? sprite)) + return; - foreach (var revealed in args.RevealedLayers) - { - if (!sprite.LayerMapTryGet(revealed, out var layer) || sprite[layer] is not Layer notlayer) - continue; + foreach (var revealed in args.RevealedLayers) + { + if (!sprite.LayerMapTryGet(revealed, out var layer)) + continue; - sprite.LayerSetShader(layer, component.ShaderName); - sprite.LayerSetColor(layer, component.Color); - } + sprite.LayerSetShader(layer, component.ShaderName); + sprite.LayerSetColor(layer, component.Color); } + } - private void OnEquipmentVisualsUpdated(EntityUid uid, PaintedComponent component, EquipmentVisualsUpdatedEvent args) - { - if (args.RevealedLayers.Count == 0) - return; + private void OnEquipmentVisualsUpdated(EntityUid uid, PaintedComponent component, EquipmentVisualsUpdatedEvent args) + { + if (args.RevealedLayers.Count == 0) + return; - if (!TryComp(args.Equipee, out SpriteComponent? sprite)) - return; + if (!TryComp(args.Equipee, out SpriteComponent? sprite)) + return; - foreach (var revealed in args.RevealedLayers) - { - if (!sprite.LayerMapTryGet(revealed, out var layer) || sprite[layer] is not Layer notlayer) - continue; + foreach (var revealed in args.RevealedLayers) + { + if (!sprite.LayerMapTryGet(revealed, out var layer)) + continue; - sprite.LayerSetShader(layer, component.ShaderName); - sprite.LayerSetColor(layer, component.Color); - } + sprite.LayerSetShader(layer, component.ShaderName); + sprite.LayerSetColor(layer, component.Color); } + } - private void OnShutdown(EntityUid uid, PaintedComponent component, ref ComponentShutdown args) - { - if (!TryComp(uid, out SpriteComponent? sprite)) - return; + private void OnShutdown(EntityUid uid, PaintedComponent component, ref ComponentShutdown args) + { + if (!TryComp(uid, out SpriteComponent? sprite)) + return; - component.BeforeColor = sprite.Color; - Shader = _protoMan.Index(component.ShaderName).Instance(); + component.BeforeColor = sprite.Color; + var shader = _protoMan.Index(component.ShaderName).Instance(); - if (!Terminating(uid)) + if (!Terminating(uid)) + { + foreach (var spriteLayer in sprite.AllLayers) { - foreach (var spriteLayer in sprite.AllLayers) + if (spriteLayer is not Layer layer) + continue; + + if (layer.Shader == shader) // If shader isn't same as one in component we need to ignore it. { - if (spriteLayer is not Layer layer) - continue; - - if (layer.Shader == Shader) // If shader isn't same as one in component we need to ignore it. - { - layer.Shader = null; - if (layer.Color == component.Color) // If color isn't the same as one in component we don't want to change it. - layer.Color = component.BeforeColor; - } + layer.Shader = null; + if (layer.Color == component.Color) // If color isn't the same as one in component we don't want to change it. + layer.Color = component.BeforeColor; } } } diff --git a/Content.Server/Paint/PaintSystem.cs b/Content.Server/Paint/PaintSystem.cs index c6718aced68f9a..892f961d634ccd 100644 --- a/Content.Server/Paint/PaintSystem.cs +++ b/Content.Server/Paint/PaintSystem.cs @@ -72,15 +72,12 @@ private void PrepPaint(EntityUid uid, PaintComponent component, EntityUid target var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.Delay, new PaintDoAfterEvent(), uid, target: target, used: uid) { - BreakOnTargetMove = true, - BreakOnUserMove = true, - BreakOnDamage = true, + BreakOnMove = true, NeedHand = true, BreakOnHandChange = true }; - if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs)) - return; + _doAfterSystem.TryStartDoAfter(doAfterEventArgs); } private void OnPaint(Entity entity, ref PaintDoAfterEvent args) @@ -112,7 +109,6 @@ private void OnPaint(Entity entity, ref PaintDoAfterEvent args) return; } - if (TryPaint(entity, target)) { EnsureComp(target, out PaintedComponent? paint); @@ -131,12 +127,14 @@ private void OnPaint(Entity entity, ref PaintDoAfterEvent args) if (!_inventory.TryGetSlotEntity(target, slot.Name, out var slotEnt)) continue; - if (slotEnt == null) - return; - - if (HasComp(slotEnt.Value) || !entity.Comp.Blacklist?.IsValid(slotEnt.Value, EntityManager) != true - || HasComp(slotEnt.Value) || HasComp(slotEnt.Value)) - return; + if (HasComp(slotEnt.Value) || !entity.Comp.Blacklist?.IsValid(slotEnt.Value, + EntityManager) != true + || HasComp(slotEnt.Value) || + HasComp( + slotEnt.Value)) + { + continue; + } EnsureComp(slotEnt.Value, out PaintedComponent? slotpaint); EnsureComp(slotEnt.Value); diff --git a/Content.Shared/Paint/PaintRemoverSystem.cs b/Content.Shared/Paint/PaintRemoverSystem.cs index ac1cc624cfe9b8..efc1ded067782e 100644 --- a/Content.Shared/Paint/PaintRemoverSystem.cs +++ b/Content.Shared/Paint/PaintRemoverSystem.cs @@ -16,7 +16,6 @@ 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() @@ -39,9 +38,8 @@ private void OnInteract(EntityUid uid, PaintRemoverComponent component, AfterInt _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.CleanDelay, new PaintRemoverDoAfterEvent(), uid, args.Target, uid) { - BreakOnUserMove = true, + BreakOnMove = true, BreakOnDamage = true, - BreakOnTargetMove = true, MovementThreshold = 1.0f, }); args.Handled = true; @@ -77,13 +75,13 @@ private void OnPaintRemoveVerb(EntityUid uid, PaintRemoverComponent component, G var verb = new UtilityVerb() { - Act = () => { + Act = () => + { _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.CleanDelay, new PaintRemoverDoAfterEvent(), uid, args.Target, uid) { - BreakOnUserMove = true, + BreakOnMove = true, BreakOnDamage = true, - BreakOnTargetMove = true, MovementThreshold = 1.0f, }); },