HolidayPrototype.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Content.Server.Holiday.Greet;
  2. using Content.Server.Holiday.Interfaces;
  3. using Content.Server.Holiday.ShouldCelebrate;
  4. using Robust.Shared.Prototypes;
  5. namespace Content.Server.Holiday
  6. {
  7. [Prototype]
  8. public sealed partial class HolidayPrototype : IPrototype
  9. {
  10. [DataField("name")] public string Name { get; private set; } = string.Empty;
  11. [ViewVariables]
  12. [IdDataField]
  13. public string ID { get; private set; } = default!;
  14. [DataField("beginDay")]
  15. public byte BeginDay { get; set; } = 1;
  16. [DataField("beginMonth")]
  17. public Month BeginMonth { get; set; } = Month.Invalid;
  18. /// <summary>
  19. /// Day this holiday will end. Zero means it lasts a single day.
  20. /// </summary>
  21. [DataField("endDay")]
  22. public byte EndDay { get; set; }
  23. /// <summary>
  24. /// Month this holiday will end in. Invalid means it lasts a single month.
  25. /// </summary>
  26. [DataField("endMonth")]
  27. public Month EndMonth { get; set; } = Month.Invalid;
  28. [DataField("shouldCelebrate")]
  29. private IHolidayShouldCelebrate _shouldCelebrate = new DefaultHolidayShouldCelebrate();
  30. [DataField("greet")]
  31. private IHolidayGreet _greet = new DefaultHolidayGreet();
  32. [DataField("celebrate")]
  33. private IHolidayCelebrate? _celebrate = null;
  34. public bool ShouldCelebrate(DateTime date)
  35. {
  36. return _shouldCelebrate.ShouldCelebrate(date, this);
  37. }
  38. public string Greet()
  39. {
  40. return _greet.Greet(this);
  41. }
  42. /// <summary>
  43. /// Called before the round starts to set up any festive shenanigans.
  44. /// </summary>
  45. public void Celebrate()
  46. {
  47. _celebrate?.Celebrate(this);
  48. }
  49. }
  50. }