-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ЦК v2 #928
ЦК v2 #928
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Content.Server.Backmen.Arrivals.CentComm; | ||
|
||
public enum CentComEventId : int | ||
{ | ||
Noop = 0, | ||
AddWorker, | ||
AddOperator, | ||
AddSecurity, | ||
AddCargo | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Content.Server.Backmen.Arrivals.CentComm; | ||
|
||
public sealed class CentCommEvent(EntityUid station,CentComEventId eventId) : HandledEntityEventArgs | ||
{ | ||
public EntityUid Station { get; } = station; | ||
public CentComEventId EventId { get; } = eventId; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Content.Server.Spawners.Components; | ||
using Content.Server.Station.Components; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.Backmen.Arrivals.CentComm; | ||
|
||
public sealed class CentCommSpawnSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<StationCentCommDirectorComponent, CentCommEvent>(OnCentCommEvent); | ||
} | ||
|
||
private void OnCentCommEvent(Entity<StationCentCommDirectorComponent> ent, ref CentCommEvent args) | ||
{ | ||
if(args.Handled) | ||
return; | ||
|
||
switch (args.EventId) | ||
{ | ||
case CentComEventId.AddWorker: | ||
args.Handled = true; | ||
|
||
AddWorker(args.Station); | ||
break; | ||
case CentComEventId.AddOperator: | ||
args.Handled = true; | ||
|
||
AddOperator(args.Station); | ||
break; | ||
case CentComEventId.AddSecurity: | ||
args.Handled = true; | ||
|
||
AddSecurity(args.Station); | ||
break; | ||
case CentComEventId.AddCargo: | ||
args.Handled = true; | ||
|
||
AddCargo(args.Station); | ||
break; | ||
default: | ||
return; | ||
} | ||
} | ||
|
||
private void SpawnEntity(EntityUid station, string protoId) | ||
{ | ||
var point = FindSpawnPoint(station); | ||
if (point == null) | ||
{ | ||
Log.Warning($"Can't find spawn point for {station}"); | ||
return; | ||
} | ||
Spawn(protoId, point.Value); | ||
} | ||
|
||
[ValidatePrototypeId<EntityPrototype>] | ||
private const string WorkerProto = "SpawnPointCMBKCCAssistant"; | ||
private void AddWorker(EntityUid station) => SpawnEntity(station, WorkerProto); | ||
|
||
[ValidatePrototypeId<EntityPrototype>] | ||
private const string OperatorProto = "SpawnPointCMBKCCOperator"; | ||
private void AddOperator(EntityUid station) => SpawnEntity(station, OperatorProto); | ||
|
||
[ValidatePrototypeId<EntityPrototype>] | ||
private const string SecurityProto = "SpawnPointCMBKCCSecOfficer"; | ||
private void AddSecurity(EntityUid station) => SpawnEntity(station, SecurityProto); | ||
|
||
[ValidatePrototypeId<EntityPrototype>] | ||
private const string CargoProto = "SpawnPointCMBKCCCargo"; | ||
private void AddCargo(EntityUid station) => SpawnEntity(station, CargoProto); | ||
|
||
private EntityCoordinates? FindSpawnPoint(EntityUid station) | ||
{ | ||
var stationData = CompOrNull<StationDataComponent>(station); | ||
if (stationData == null) | ||
return null; | ||
|
||
var stationGrids = stationData.Grids; | ||
|
||
var result = new List<EntityCoordinates>(); | ||
|
||
var q = EntityQueryEnumerator<SpawnPointComponent,TransformComponent>(); | ||
while (q.MoveNext(out var uid, out var spawnPoint, out var transform)) | ||
{ | ||
if(spawnPoint.SpawnType != SpawnPointType.LateJoin || transform.GridUid == null) | ||
continue; | ||
if(!stationGrids.Contains(transform.GridUid.Value)) | ||
continue; | ||
|
||
result.Add(transform.Coordinates); | ||
} | ||
|
||
return result.Count == 0 ? null : _random.Pick(result); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Content.Server.Shuttles.Components; | ||
|
||
namespace Content.Server.Backmen.Arrivals.CentComm; | ||
|
||
public sealed class FtlCentComAnnounce : EntityEventArgs | ||
{ | ||
public Entity<ShuttleComponent> Source { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,21 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
namespace Content.Server.Backmen.Arrivals.CentComm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
[RegisterComponent] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
public sealed partial class StationCentCommDirectorComponent : Component | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// Keeps track of the internal event scheduler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
[ViewVariables] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
[DataField("nextEventTick", customTypeSerializer: typeof(TimeOffsetSerializer))] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
public TimeSpan NextEventTick; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+8
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding validation and proper initialization for NextEventTick. The property could benefit from additional safeguards:
Here's a suggested improvement: [ViewVariables]
[DataField("nextEventTick", customTypeSerializer: typeof(TimeOffsetSerializer))]
-public TimeSpan NextEventTick;
+public TimeSpan NextEventTick { get; internal set; } = TimeSpan.FromMinutes(5); // Or another appropriate default
+
+internal void SetNextEventTick(TimeSpan time)
+{
+ if (time < TimeSpan.Zero)
+ throw new ArgumentException("Event tick cannot be in the past", nameof(time));
+ NextEventTick = time;
+} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// The schedule of events to occur. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
/// </summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
[ViewVariables] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
[DataField("eventSchedule")] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
public List<(TimeSpan timeOffset, CentComEventId eventId)> EventSchedule = new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+15
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance EventSchedule safety and documentation. The current implementation has several potential improvements:
Here's a suggested improvement: /// <summary>
/// The schedule of events to occur.
+/// </summary>
+/// <remarks>
+/// Each tuple contains:
+/// - timeOffset: The time delay before the event should occur
+/// - eventId: The specific type of event to trigger
/// </remarks>
[ViewVariables]
[DataField("eventSchedule")]
-public List<(TimeSpan timeOffset, CentComEventId eventId)> EventSchedule = new();
+public IReadOnlyList<(TimeSpan timeOffset, CentComEventId eventId)> EventSchedule => _eventSchedule;
+private readonly List<(TimeSpan timeOffset, CentComEventId eventId)> _eventSchedule = new();
+
+public void AddEvent(TimeSpan timeOffset, CentComEventId eventId)
+{
+ if (timeOffset < TimeSpan.Zero)
+ throw new ArgumentException("Time offset cannot be negative", nameof(timeOffset));
+
+ _eventSchedule.Add((timeOffset, eventId));
+} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- type: entity | ||
id: SpawnPointCMBKCCAssistant | ||
name: Ассистент ЦК | ||
suffix: Спавнер, Директор Событий | ||
parent: MarkerBase | ||
components: | ||
- type: GhostRole | ||
allowMovement: true | ||
allowSpeech: true | ||
makeSentient: true | ||
name: Ассистент ЦК | ||
description: Разнорабочий призванный для поддержки экипажа ЦК и для поддержки самой станции цк в текущем секторе. | ||
rules: Вы обязаны выполнять поручения экипажа станции цк, опеспечивать станцию цк в рабочем состоянии, также запрещено покидать станцию цк! | ||
raffle: | ||
settings: short | ||
requirements: | ||
- !type:DepartmentTimeRequirement | ||
department: Engineering | ||
time: 108000 | ||
- !type:DepartmentTimeRequirement | ||
department: Medical | ||
time: 108000 | ||
- !type:DepartmentTimeRequirement | ||
department: Civilian | ||
time: 108000 | ||
job: BKCCAssistant | ||
- type: GhostRoleMobSpawner | ||
prototype: MobHumanCMBKCCAssistant | ||
- type: Sprite | ||
sprite: Markers/jobs.rsi | ||
layers: | ||
- state: green | ||
- sprite: Mobs/Animals/regalrat.rsi | ||
state: icon | ||
Comment on lines
+33
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inappropriate sprite configuration The spawner is using |
||
|
||
|
||
- type: entity | ||
name: Ассистент ЦК | ||
suffix: Спавнер, Директор Событий | ||
parent: MobHumanCombine | ||
id: MobHumanCMBKCCAssistant | ||
components: | ||
- type: Icon | ||
sprite: Markers/jobs.rsi | ||
state: ai | ||
- type: AutoImplant | ||
implants: | ||
- MindShieldImplant | ||
- FreedomImplant | ||
- type: SpecForce | ||
actionBssActionName: ActionCentcomFtlAction | ||
- type: NpcFactionMember | ||
factions: | ||
- CentralCommand | ||
- type: Loadout | ||
prototypes: [CentComInternGear] | ||
- type: RandomHumanoidAppearance | ||
randomizeName: true | ||
- type: AntagImmune |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
- type: entity | ||
id: SpawnPointCMBKCCCargo | ||
name: Карго ЦК | ||
suffix: Спавнер, Директор Событий | ||
parent: MarkerBase | ||
components: | ||
- type: GhostRole | ||
allowMovement: true | ||
allowSpeech: true | ||
makeSentient: true | ||
name: Карго ЦК | ||
description: A Central Command Cargo Officer responsible for managing cargo operations. | ||
rules: | | ||
- Maintain Central Command cargo protocols | ||
- Coordinate with station cargo department | ||
- Follow Central Command chain of command | ||
raffle: | ||
settings: short | ||
requirements: | ||
- !type:DepartmentTimeRequirement | ||
department: Cargo | ||
time: 126000 | ||
- !type:RoleTimeRequirement | ||
role: JobCentralCommandAssistant | ||
time: 21600 | ||
- !type:DepartmentTimeRequirement | ||
department: CentCom | ||
time: 43200 | ||
Comment on lines
+20
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Based on the search results, I can now provide a comprehensive analysis of the time requirements across the codebase. Let me generate the final response: Time requirements for CentComm Cargo role are significantly higher than other similar roles The current time requirements for CentComm Cargo (35h Cargo, 6h CC Assistant, 12h CentCom) are disproportionate compared to other CentComm roles:
Recommend adjusting the time requirements to be more in line with other CentComm roles:
🔗 Analysis chainVerify the time requirements for role eligibility The current time requirements seem exceptionally high:
These high requirements might severely limit the pool of eligible players. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for similar ghost role time requirements across the codebase
rg -U "DepartmentTimeRequirement|RoleTimeRequirement" -A 2 | grep -E "time:|department:|role:"
Length of output: 34960 |
||
job: BKCCCargo | ||
- type: GhostRoleMobSpawner | ||
prototype: MobHumanCMBKCCCargo | ||
- type: Sprite | ||
sprite: Markers/jobs.rsi | ||
layers: | ||
- state: green | ||
- sprite: Mobs/Animals/regalrat.rsi | ||
state: icon | ||
|
||
- type: entity | ||
name: Карго ЦК | ||
suffix: Директор Событий | ||
parent: MobHumanCombine | ||
id: MobHumanCMBKCCCargo | ||
components: | ||
- type: Icon | ||
sprite: Markers/jobs.rsi | ||
state: ai | ||
- type: AutoImplant | ||
implants: | ||
- MindShieldImplant | ||
- FreedomImplant | ||
- type: SpecForce | ||
actionBssActionName: ActionCentcomFtlAction | ||
- type: NpcFactionMember | ||
factions: | ||
- CentralCommand | ||
- type: Loadout | ||
prototypes: [CCCargo] | ||
- type: RandomHumanoidAppearance | ||
randomizeName: true | ||
- type: AntagImmune |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider improving event handling robustness and readability.
A few suggestions to enhance this section:
args.Station
args.Handled = true
Here's a suggested improvement:
📝 Committable suggestion