* Revert "Hot revert (#403)"

This reverts commit 65283e1c44.

* hotfix
This commit is contained in:
ThereDrD0
2024-07-01 14:36:20 +03:00
committed by GitHub
parent 7e260940e0
commit d3413b9a40
15 changed files with 195 additions and 33 deletions

View File

@@ -0,0 +1,71 @@
using System.Globalization;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.Radio.EntitySystems;
using Content.Shared._White.Announcement;
using Content.Shared.Radio;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;
namespace Content.Server._White.Announcement;
public sealed class ArrivalNotificationSystem : EntitySystem
{
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeAllEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawn);
}
private void OnPlayerSpawn(PlayerSpawnCompleteEvent args)
{
if (args.JobId == null)
return;
if (!_prototypeManager.TryIndex<JobPrototype>(args.JobId, out var jobPrototype))
return;
if (jobPrototype.AnnouncementPrototype == null)
return;
if (!_prototypeManager.TryIndex<ArrivalNotificationPrototype>(jobPrototype.AnnouncementPrototype, out var notification))
return;
var message = GetMessage(args.Mob,
jobPrototype,
notification.UseGlobalAnnouncement ? notification.GlobalMessage : notification.Message);
var senderName = Loc.GetString("head-arrived-sender");
var source = args.Station;
if (notification.UseGlobalAnnouncement)
_chatSystem.DispatchGlobalAnnouncement(message, senderName, colorOverride: Color.Gold);
else
_chatSystem.DispatchStationAnnouncement(source, message, senderName, false);
message = GetMessage(args.Mob, jobPrototype, notification.Message); // Changing message type for radio notification
foreach (var channel in notification.RadioChannelsPrototypes)
{
if (!_prototypeManager.TryIndex<RadioChannelPrototype>(channel, out _))
continue;
_radioSystem.SendRadioMessage(source, message, channel, args.Mob);
}
}
private string GetMessage(EntityUid mob, JobPrototype jobPrototype, string type)
{
var message = Loc.GetString(type,
("character", MetaData(mob).EntityName),
("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Loc.GetString(jobPrototype.Name))));
return message;
}
}

View File

@@ -19,16 +19,16 @@ namespace Content.Shared.Roles
[IdDataField]
public string ID { get; private set; } = default!;
[DataField("playTimeTracker", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<PlayTimeTrackerPrototype>))]
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<PlayTimeTrackerPrototype>))]
public string PlayTimeTracker { get; private set; } = string.Empty;
[DataField("supervisors")]
[DataField]
public string Supervisors { get; private set; } = "nobody";
/// <summary>
/// The name of this job as displayed to players.
/// </summary>
[DataField("name")]
[DataField]
public string Name { get; private set; } = string.Empty;
[ViewVariables(VVAccess.ReadOnly)]
@@ -37,22 +37,25 @@ namespace Content.Shared.Roles
/// <summary>
/// The name of this job as displayed to players.
/// </summary>
[DataField("description")]
[DataField]
public string? Description { get; private set; }
[ViewVariables(VVAccess.ReadOnly)]
public string? LocalizedDescription => Description is null ? null : Loc.GetString(Description);
[DataField("requirements")]
[DataField]
public HashSet<JobRequirement>? Requirements;
[DataField("joinNotifyCrew")]
[DataField]
public bool JoinNotifyCrew { get; private set; } = false;
[DataField("requireAdminNotify")]
[DataField]
public string? AnnouncementPrototype;
[DataField]
public bool RequireAdminNotify { get; private set; } = false;
[DataField("setPreference")]
[DataField]
public bool SetPreference { get; private set; } = true;
/// <summary>
@@ -62,14 +65,14 @@ namespace Content.Shared.Roles
[DataField]
public bool? OverrideConsoleVisibility { get; private set; } = null;
[DataField("canBeAntag")]
[DataField]
public bool CanBeAntag { get; private set; } = true;
/// <summary>
/// Whether this job is a head.
/// The job system will try to pick heads before other jobs on the same priority level.
/// </summary>
[DataField("weight")]
[DataField]
public int Weight { get; private set; }
/// <summary>
@@ -86,10 +89,10 @@ namespace Content.Shared.Roles
/// A numerical score for how much easier this job is for antagonists.
/// For traitors, reduces starting TC by this amount. Other gamemodes can use it for whatever they find fitting.
/// </summary>
[DataField("antagAdvantage")]
[DataField]
public int AntagAdvantage = 0;
[DataField("startingGear", customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<StartingGearPrototype>))]
public string? StartingGear { get; private set; }
/// <summary>
@@ -97,28 +100,28 @@ namespace Content.Shared.Roles
/// Starting gear will be ignored.
/// If you want to just add special attributes to a humanoid, use AddComponentSpecial instead.
/// </summary>
[DataField("jobEntity", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? JobEntity = null;
[DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))]
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<StatusIconPrototype>))]
public string Icon { get; private set; } = "JobIconUnknown";
[DataField("special", serverOnly: true)]
[DataField(serverOnly: true)]
public JobSpecial[] Special { get; private set; } = Array.Empty<JobSpecial>();
[DataField("access")]
[DataField]
public IReadOnlyCollection<ProtoId<AccessLevelPrototype>> Access { get; private set; } = Array.Empty<ProtoId<AccessLevelPrototype>>();
[DataField("accessGroups")]
[DataField]
public IReadOnlyCollection<ProtoId<AccessGroupPrototype>> AccessGroups { get; private set; } = Array.Empty<ProtoId<AccessGroupPrototype>>();
[DataField("extendedAccess")]
[DataField]
public IReadOnlyCollection<ProtoId<AccessLevelPrototype>> ExtendedAccess { get; private set; } = Array.Empty<ProtoId<AccessLevelPrototype>>();
[DataField("extendedAccessGroups")]
[DataField]
public IReadOnlyCollection<ProtoId<AccessGroupPrototype>> ExtendedAccessGroups { get; private set; } = Array.Empty<ProtoId<AccessGroupPrototype>>();
[DataField("whitelistedSpecies")]
[DataField]
public IReadOnlyCollection<ProtoId<SpeciesPrototype>> WhitelistedSpecies { get; private set; } = Array.Empty<ProtoId<SpeciesPrototype>>();
}

View File

@@ -0,0 +1,33 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._White.Announcement;
[Prototype("arrivalNotification")]
public sealed partial class ArrivalNotificationPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// The message that the department will receive upon the player arrival
/// </summary>
[DataField(required: true)]
public string Message = default!;
/// <summary>
/// The message that the station will receive upon the player arrival
/// </summary>
[DataField]
public string GlobalMessage = default!;
/// <summary>
/// ID of the channel where the player arrival will be announced.
/// </summary>
[DataField(required: true)]
public HashSet<string> RadioChannelsPrototypes = default!;
/// <summary>
/// Determines whether the notification will be made to the entire station. If false, the notification will be on the department radio channel
/// </summary>
[DataField]
public bool UseGlobalAnnouncement;
}

View File

@@ -0,0 +1,3 @@
head-arrived-message = { $character }, { $job }, Глава отдела
head-arrived-message-global = { $job } { $character } на станции
head-arrived-sender = Автоматическая Система Оповещений

View File

@@ -32,12 +32,5 @@
icon:
sprite: Objects/Misc/stock_parts.rsi
state: capacitor
doAfter: 5
- tag: CapacitorStockPart
name: capacitor
icon:
sprite: Objects/Misc/stock_parts.rsi
state: capacitor
doAfter: 5
- node: medsecHud
entity: ClothingEyesHudMedSec

View File

@@ -65,10 +65,5 @@
icon:
sprite: Objects/Misc/stock_parts.rsi
state: capacitor
- tag: CapacitorStockPart
name: capacitor
icon:
sprite: Objects/Misc/stock_parts.rsi
state: capacitor
- node: potatoaichip
entity: PotatoAIChip
entity: PotatoAIChip

View File

@@ -15,6 +15,7 @@
weight: 10
startingGear: QuartermasterGear
icon: "JobIconQuarterMaster"
announcementPrototype: QuartermasterArrivalNotification
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human

View File

@@ -20,6 +20,7 @@
icon: "JobIconCaptain"
requireAdminNotify: true
joinNotifyCrew: true
announcementPrototype: CaptainArrivalNotification
supervisors: job-supervisors-centcom
whitelistedSpecies:
- Human

View File

@@ -19,6 +19,7 @@
startingGear: HoPGear
icon: "JobIconHeadOfPersonnel"
requireAdminNotify: true
announcementPrototype: HeadOfPersonnelArrivalNotification
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human

View File

@@ -16,6 +16,7 @@
startingGear: ChiefEngineerGear
icon: "JobIconChiefEngineer"
requireAdminNotify: true
announcementPrototype: ChiefEngineerArrivalNotification
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human

View File

@@ -14,6 +14,7 @@
time: 36000 #10 hrs
startingGear: InspectorGear
icon: "JobIconInspector"
announcementPrototype: InspectorArrivalNotification
supervisors: job-supervisors-captain
access:
- Service

View File

@@ -14,6 +14,7 @@
weight: 10
startingGear: CMOGear
icon: "JobIconChiefMedicalOfficer"
announcementPrototype: ChiefMedicalOfficerArrivalNotification
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:

View File

@@ -13,6 +13,7 @@
startingGear: ResearchDirectorGear
icon: "JobIconResearchDirector"
requireAdminNotify: true
announcementPrototype: ResearchDirectorArrivalNotification
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human

View File

@@ -16,6 +16,7 @@
startingGear: HoSGear
icon: "JobIconHeadOfSecurity"
requireAdminNotify: true
announcementPrototype: HeadOfSecurityArrivalNotification
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human

View File

@@ -0,0 +1,56 @@
- type: arrivalNotification
id: CaptainArrivalNotification
message: head-arrived-message
globalMessage: head-arrived-message-global
radioChannelsPrototypes:
- Command
useGlobalAnnouncement: True
- type: arrivalNotification
id: HeadOfPersonnelArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Service
- type: arrivalNotification
id: HeadOfSecurityArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Security
- type: arrivalNotification
id: ChiefMedicalOfficerArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Medical
- type: arrivalNotification
id: ChiefEngineerArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Engineering
- type: arrivalNotification
id: ResearchDirectorArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Science
- type: arrivalNotification
id: QuartermasterArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Cargo
- type: arrivalNotification
id: InspectorArrivalNotification
message: head-arrived-message
radioChannelsPrototypes:
- Command
- Security