Fix build (#26258)
* Fix build - Fixes a couple paint things that were broken. * wat
This commit is contained in:
@@ -7,112 +7,108 @@ using Content.Shared.Paint;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Paint
|
||||
namespace Content.Client.Paint;
|
||||
|
||||
public sealed class PaintedVisualizerSystem : VisualizerSystem<PaintedComponent>
|
||||
{
|
||||
public sealed class PaintedVisualizerSystem : VisualizerSystem<PaintedComponent>
|
||||
/// <summary>
|
||||
/// Visualizer for Paint which applies a shader and colors the entity.
|
||||
/// </summary>
|
||||
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
/// <summary>
|
||||
/// Visualizer for Paint which applies a shader and colors the entity.
|
||||
/// </summary>
|
||||
base.Initialize();
|
||||
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
SubscribeLocalEvent<PaintedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated);
|
||||
SubscribeLocalEvent<PaintedComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<PaintedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated);
|
||||
}
|
||||
|
||||
public ShaderInstance? Shader; // in Robust.Client.Graphics so cannot move to shared component.
|
||||
protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
var shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();
|
||||
|
||||
public override void Initialize()
|
||||
if (args.Sprite == null)
|
||||
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;
|
||||
|
||||
foreach (var spriteLayer in sprite.AllLayers)
|
||||
{
|
||||
base.Initialize();
|
||||
if (spriteLayer is not Layer layer)
|
||||
continue;
|
||||
|
||||
SubscribeLocalEvent<PaintedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated);
|
||||
SubscribeLocalEvent<PaintedComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<PaintedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated);
|
||||
if (layer.Shader == null) // If shader isn't null we dont want to replace the original shader.
|
||||
{
|
||||
layer.Shader = shader;
|
||||
layer.Color = component.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args)
|
||||
private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args)
|
||||
{
|
||||
if (args.RevealedLayers.Count == 0)
|
||||
return;
|
||||
|
||||
if (!TryComp(args.User, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
foreach (var revealed in args.RevealedLayers)
|
||||
{
|
||||
// ShaderPrototype sadly in Robust.Client, cannot move to shared component.
|
||||
Shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();
|
||||
if (!sprite.LayerMapTryGet(revealed, out var layer))
|
||||
continue;
|
||||
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
sprite.LayerSetShader(layer, component.ShaderName);
|
||||
sprite.LayerSetColor(layer, component.Color);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_appearance.TryGetData<bool>(uid, PaintVisuals.Painted, out bool isPainted))
|
||||
return;
|
||||
private void OnEquipmentVisualsUpdated(EntityUid uid, PaintedComponent component, EquipmentVisualsUpdatedEvent args)
|
||||
{
|
||||
if (args.RevealedLayers.Count == 0)
|
||||
return;
|
||||
|
||||
var sprite = args.Sprite;
|
||||
if (!TryComp(args.Equipee, out SpriteComponent? sprite))
|
||||
return;
|
||||
|
||||
foreach (var revealed in args.RevealedLayers)
|
||||
{
|
||||
if (!sprite.LayerMapTryGet(revealed, out var layer))
|
||||
continue;
|
||||
|
||||
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;
|
||||
|
||||
component.BeforeColor = sprite.Color;
|
||||
var shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();
|
||||
|
||||
if (!Terminating(uid))
|
||||
{
|
||||
foreach (var spriteLayer in sprite.AllLayers)
|
||||
{
|
||||
if (spriteLayer is not Layer layer)
|
||||
continue;
|
||||
|
||||
if (layer.Shader == null) // If shader isn't null we dont want to replace the original shader.
|
||||
if (layer.Shader == shader) // If shader isn't same as one in component we need to ignore it.
|
||||
{
|
||||
layer.Shader = Shader;
|
||||
layer.Color = component.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args)
|
||||
{
|
||||
if (args.RevealedLayers.Count == 0)
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
component.BeforeColor = sprite.Color;
|
||||
Shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();
|
||||
|
||||
if (!Terminating(uid))
|
||||
{
|
||||
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.
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,15 +72,12 @@ public sealed class PaintSystem : SharedPaintSystem
|
||||
|
||||
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<PaintComponent> entity, ref PaintDoAfterEvent args)
|
||||
@@ -112,7 +109,6 @@ public sealed class PaintSystem : SharedPaintSystem
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (TryPaint(entity, target))
|
||||
{
|
||||
EnsureComp<PaintedComponent>(target, out PaintedComponent? paint);
|
||||
@@ -131,12 +127,14 @@ public sealed class PaintSystem : SharedPaintSystem
|
||||
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var slotEnt))
|
||||
continue;
|
||||
|
||||
if (slotEnt == null)
|
||||
return;
|
||||
|
||||
if (HasComp<PaintedComponent>(slotEnt.Value) || !entity.Comp.Blacklist?.IsValid(slotEnt.Value, EntityManager) != true
|
||||
|| HasComp<RandomSpriteComponent>(slotEnt.Value) || HasComp<HumanoidAppearanceComponent>(slotEnt.Value))
|
||||
return;
|
||||
if (HasComp<PaintedComponent>(slotEnt.Value) || !entity.Comp.Blacklist?.IsValid(slotEnt.Value,
|
||||
EntityManager) != true
|
||||
|| HasComp<RandomSpriteComponent>(slotEnt.Value) ||
|
||||
HasComp<HumanoidAppearanceComponent>(
|
||||
slotEnt.Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
EnsureComp<PaintedComponent>(slotEnt.Value, out PaintedComponent? slotpaint);
|
||||
EnsureComp<AppearanceComponent>(slotEnt.Value);
|
||||
|
||||
@@ -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 @@ public sealed class PaintRemoverSystem : SharedPaintSystem
|
||||
|
||||
_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 @@ public sealed class PaintRemoverSystem : SharedPaintSystem
|
||||
|
||||
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,
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user