From 2a523b73d341cc6afb1c863904dbc16db8e8c240 Mon Sep 17 00:00:00 2001 From: VigersRay Date: Wed, 2 Oct 2024 06:33:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D1=83=20=D0=B0=20=D1=87=D0=BE=20=D1=8F?= =?UTF-8?q?=3F=20=D0=AF=20=D0=BD=D0=B8=D1=87=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/Entry/EntryPoint.cs | 1 + .../Holiday/HolidayGiveawayItemPrototype.cs | 19 ++++++++++++ Content.Server/Holiday/HolidayPrototype.cs | 12 +++++++ Content.Server/Holiday/HolidaySystem.cs | 2 +- .../Station/Systems/StationSpawningSystem.cs | 21 +++++++++++++ .../_sunrise/holiday/greet/holiday-greet.ftl | 3 ++ Resources/Prototypes/_Sunrise/holidays.yml | 31 +++++++++++++++++++ 7 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 Content.Server/Holiday/HolidayGiveawayItemPrototype.cs create mode 100644 Resources/Locale/ru-RU/_strings/_sunrise/holiday/greet/holiday-greet.ftl create mode 100644 Resources/Prototypes/_Sunrise/holidays.yml diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index 1610f7b1bb..ecdeef8972 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -125,6 +125,7 @@ namespace Content.Client.Entry _prototypeManager.RegisterIgnore("nukeopsRole"); _prototypeManager.RegisterIgnore("stationGoal"); // Sunrise-StationGoal _prototypeManager.RegisterIgnore("sponsorLoadout"); // Sunrise-Sponsors + _prototypeManager.RegisterIgnore("holidayGiveawayItem"); // Sunrise-Edit _prototypeManager.RegisterIgnore("ghostRoleRaffleDecider"); _componentFactory.GenerateNetIds(); diff --git a/Content.Server/Holiday/HolidayGiveawayItemPrototype.cs b/Content.Server/Holiday/HolidayGiveawayItemPrototype.cs new file mode 100644 index 0000000000..716e69b07b --- /dev/null +++ b/Content.Server/Holiday/HolidayGiveawayItemPrototype.cs @@ -0,0 +1,19 @@ +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; + +namespace Content.Server.Holiday +{ + [Prototype("holidayGiveawayItem")] + public sealed partial class HolidayGiveawayItemPrototype : IPrototype + { + [ViewVariables] + [IdDataField] + public string ID { get; private set; } = default!; + + [DataField("holiday", customTypeSerializer:typeof(PrototypeIdSerializer))] + public string Holiday { get; private set; } = string.Empty; + + [DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer))] + public string Prototype { get; private set; } = string.Empty; + } +} diff --git a/Content.Server/Holiday/HolidayPrototype.cs b/Content.Server/Holiday/HolidayPrototype.cs index 749423402b..5a9e6323f6 100644 --- a/Content.Server/Holiday/HolidayPrototype.cs +++ b/Content.Server/Holiday/HolidayPrototype.cs @@ -38,6 +38,11 @@ namespace Content.Server.Holiday [DataField("greet")] private IHolidayGreet _greet = new DefaultHolidayGreet(); + // Sunrise-Start + [DataField("greetColor")] + private Color? _color; + // Sunrise-End + [DataField("celebrate")] private IHolidayCelebrate? _celebrate = null; @@ -51,6 +56,13 @@ namespace Content.Server.Holiday return _greet.Greet(this); } + // Sunrise-Start + public Color? GreetColor() + { + return _color; + } + // Sunrise-End + /// /// Called before the round starts to set up any festive shenanigans. /// diff --git a/Content.Server/Holiday/HolidaySystem.cs b/Content.Server/Holiday/HolidaySystem.cs index 001508593d..97c30a2371 100644 --- a/Content.Server/Holiday/HolidaySystem.cs +++ b/Content.Server/Holiday/HolidaySystem.cs @@ -55,7 +55,7 @@ namespace Content.Server.Holiday { foreach (var holiday in _currentHolidays) { - _chatManager.DispatchServerAnnouncement(holiday.Greet()); + _chatManager.DispatchServerAnnouncement(holiday.Greet(), holiday.GreetColor()); // Sunrise-Edit } } diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 0269c4f65a..08ea209f17 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -1,6 +1,7 @@ using System.Linq; using Content.Server.Access.Systems; using Content.Server.DetailExaminable; +using Content.Server.Holiday; using Content.Server.Humanoid; using Content.Server.IdentityManagement; using Content.Server.Mind.Commands; @@ -13,6 +14,7 @@ using Content.Shared.Access.Components; using Content.Shared.Access.Systems; using Content.Shared.CCVar; using Content.Shared.Clothing; +using Content.Shared.Hands.EntitySystems; using Content.Shared.Humanoid; using Content.Shared.Humanoid.Prototypes; using Content.Shared.PDA; @@ -226,6 +228,25 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem { jobSpecial.AfterEquip(entity); } + + // Sunrise-Start + foreach (var giveaway in _prototypeManager.EnumeratePrototypes()) + { + if (string.IsNullOrEmpty(giveaway.Holiday) || string.IsNullOrEmpty(giveaway.Prototype)) + return; + + var sysMan = IoCManager.Resolve(); + + if (!sysMan.GetEntitySystem().IsCurrentlyHoliday(giveaway.Holiday)) + return; + + var entMan = IoCManager.Resolve(); + + var ent = entMan.SpawnEntity(giveaway.Prototype, entMan.GetComponent(entity).Coordinates); + + sysMan.GetEntitySystem().PickupOrDrop(entity, ent); + } + // Sunrise-End } /// diff --git a/Resources/Locale/ru-RU/_strings/_sunrise/holiday/greet/holiday-greet.ftl b/Resources/Locale/ru-RU/_strings/_sunrise/holiday/greet/holiday-greet.ftl new file mode 100644 index 0000000000..fb6e9878e7 --- /dev/null +++ b/Resources/Locale/ru-RU/_strings/_sunrise/holiday/greet/holiday-greet.ftl @@ -0,0 +1,3 @@ +holiday-name-vigers-ray-birthday = дня рождения VigersRay +holiday-custom-vigers-ray-birthday = Сегодня день рождения у Великого и Ужасного VigersRay! +paper-text-vigers-ray-birthday = [color=red][head=3]VigersRay приглашает вас на свой день рождения![/head][/color] diff --git a/Resources/Prototypes/_Sunrise/holidays.yml b/Resources/Prototypes/_Sunrise/holidays.yml new file mode 100644 index 0000000000..a16f0ca016 --- /dev/null +++ b/Resources/Prototypes/_Sunrise/holidays.yml @@ -0,0 +1,31 @@ +- type: holiday + id: VigersRayBirthday + name: holiday-name-vigers-ray-birthday + beginDay: 2 + beginMonth: October + greet: + !type:Custom + text: holiday-custom-vigers-ray-birthday + greetColor: gold + + +- type: holidayGiveawayItem + id: VigersRayBirthdayGiveawayPresent + holiday: VigersRayBirthday + prototype: PresentRandomInsane + + +- type: holidayGiveawayItem + id: VigersRayBirthdayGiveawayInvitation + holiday: VigersRayBirthday + prototype: PaperVigersRayBirthdayInvitation + + +- type: entity + id: PaperVigersRayBirthdayInvitation + name: Приглашение на день рождения + description: Кто-то пригласил вас на праздник... + parent: Paper + components: + - type: Paper + content: paper-text-vigers-ray-birthday