1
0

HumanoidAppearanceSystem.Modifier.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Content.Server.Administration.Managers;
  2. using Content.Shared.Administration;
  3. using Content.Shared.Humanoid;
  4. using Content.Shared.Verbs;
  5. using Robust.Server.GameObjects;
  6. using Robust.Shared.Player;
  7. using Robust.Shared.Utility;
  8. namespace Content.Server.Humanoid;
  9. public sealed partial class HumanoidAppearanceSystem
  10. {
  11. [Dependency] private readonly IAdminManager _adminManager = default!;
  12. [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
  13. private void OnVerbsRequest(EntityUid uid, HumanoidAppearanceComponent component, GetVerbsEvent<Verb> args)
  14. {
  15. if (!TryComp<ActorComponent>(args.User, out var actor))
  16. {
  17. return;
  18. }
  19. if (!_adminManager.HasAdminFlag(actor.PlayerSession, AdminFlags.Fun))
  20. {
  21. return;
  22. }
  23. args.Verbs.Add(new Verb
  24. {
  25. Text = "Modify markings",
  26. Category = VerbCategory.Tricks,
  27. Icon = new SpriteSpecifier.Rsi(new("/Textures/Mobs/Customization/reptilian_parts.rsi"), "tail_smooth"),
  28. Act = () =>
  29. {
  30. _uiSystem.OpenUi(uid, HumanoidMarkingModifierKey.Key, actor.PlayerSession);
  31. _uiSystem.SetUiState(
  32. uid,
  33. HumanoidMarkingModifierKey.Key,
  34. new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
  35. component.Sex,
  36. component.SkinColor,
  37. component.CustomBaseLayers
  38. ));
  39. }
  40. });
  41. }
  42. private void OnBaseLayersSet(EntityUid uid, HumanoidAppearanceComponent component,
  43. HumanoidMarkingModifierBaseLayersSetMessage message)
  44. {
  45. if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
  46. {
  47. return;
  48. }
  49. if (message.Info == null)
  50. {
  51. component.CustomBaseLayers.Remove(message.Layer);
  52. }
  53. else
  54. {
  55. component.CustomBaseLayers[message.Layer] = message.Info.Value;
  56. }
  57. Dirty(uid, component);
  58. if (message.ResendState)
  59. {
  60. _uiSystem.SetUiState(
  61. uid,
  62. HumanoidMarkingModifierKey.Key,
  63. new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
  64. component.Sex,
  65. component.SkinColor,
  66. component.CustomBaseLayers
  67. ));
  68. }
  69. }
  70. private void OnMarkingsSet(EntityUid uid, HumanoidAppearanceComponent component,
  71. HumanoidMarkingModifierMarkingSetMessage message)
  72. {
  73. if (!_adminManager.HasAdminFlag(message.Actor, AdminFlags.Fun))
  74. {
  75. return;
  76. }
  77. component.MarkingSet = message.MarkingSet;
  78. Dirty(uid, component);
  79. if (message.ResendState)
  80. {
  81. _uiSystem.SetUiState(
  82. uid,
  83. HumanoidMarkingModifierKey.Key,
  84. new HumanoidMarkingModifierState(component.MarkingSet, component.Species,
  85. component.Sex,
  86. component.SkinColor,
  87. component.CustomBaseLayers
  88. ));
  89. }
  90. }
  91. }