Glow.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using Content.Shared.EntityEffects;
  2. using Robust.Shared.Prototypes;
  3. using Robust.Shared.Random;
  4. namespace Content.Server.EntityEffects.Effects;
  5. /// <summary>
  6. /// Makes a mob glow.
  7. /// </summary>
  8. public sealed partial class Glow : EntityEffect
  9. {
  10. [DataField]
  11. public float Radius = 2f;
  12. [DataField]
  13. public Color Color = Color.Black;
  14. private static readonly List<Color> Colors = new()
  15. {
  16. Color.White,
  17. Color.Red,
  18. Color.Yellow,
  19. Color.Green,
  20. Color.Blue,
  21. Color.Purple,
  22. Color.Pink
  23. };
  24. public override void Effect(EntityEffectBaseArgs args)
  25. {
  26. if (Color == Color.Black)
  27. {
  28. var random = IoCManager.Resolve<IRobustRandom>();
  29. Color = random.Pick(Colors);
  30. }
  31. var lightSystem = args.EntityManager.System<SharedPointLightSystem>();
  32. var light = lightSystem.EnsureLight(args.TargetEntity);
  33. lightSystem.SetRadius(args.TargetEntity, Radius, light);
  34. lightSystem.SetColor(args.TargetEntity, Color, light);
  35. lightSystem.SetCastShadows(args.TargetEntity, false, light); // this is expensive, and botanists make lots of plants
  36. }
  37. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
  38. {
  39. return "TODO";
  40. }
  41. }