DeliveryVisualizerSystem.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using Content.Shared.Delivery;
  2. using Content.Shared.StatusIcon;
  3. using Robust.Client.GameObjects;
  4. using Robust.Shared.Prototypes;
  5. namespace Content.Client.Delivery;
  6. public sealed class DeliveryVisualizerSystem : VisualizerSystem<DeliveryComponent>
  7. {
  8. [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
  9. [Dependency] private readonly IPrototypeManager _prototype = default!;
  10. [Dependency] private readonly SpriteSystem _sprite = default!;
  11. private static readonly ProtoId<JobIconPrototype> UnknownIcon = "JobIconUnknown";
  12. protected override void OnAppearanceChange(EntityUid uid, DeliveryComponent component, ref AppearanceChangeEvent args)
  13. {
  14. if (args.Sprite == null)
  15. return;
  16. _appearance.TryGetData(uid, DeliveryVisuals.JobIcon, out string job, args.Component);
  17. if (string.IsNullOrEmpty(job))
  18. job = UnknownIcon;
  19. if (!_prototype.TryIndex<JobIconPrototype>(job, out var icon))
  20. {
  21. args.Sprite.LayerSetTexture(DeliveryVisualLayers.JobStamp, _sprite.Frame0(_prototype.Index("JobIconUnknown")));
  22. return;
  23. }
  24. args.Sprite.LayerSetTexture(DeliveryVisualLayers.JobStamp, _sprite.Frame0(icon.Icon));
  25. }
  26. }
  27. public enum DeliveryVisualLayers : byte
  28. {
  29. Icon,
  30. Lock,
  31. FragileStamp,
  32. JobStamp,
  33. PriorityTape,
  34. Breakage,
  35. Trash,
  36. }