-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
5,669 additions
and
4,347 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
Content.Server/_Sunrise/Shuttles/CodeEquipmentComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Server._Sunrise.Shuttles; | ||
|
||
[RegisterComponent] | ||
public sealed partial class CodeEquipmentComponent : Component | ||
{ | ||
public List<EntityUid> Shuttles = []; | ||
|
||
[DataField("shuttlePath")] | ||
public ResPath ShuttlePath = new("Maps/_Sunrise/Shuttles/gamma_armory.yml"); | ||
|
||
[DataField] | ||
public string TargetCode = "gamma"; | ||
|
||
[DataField] | ||
public string PriorityTag = "DockGamma"; | ||
} |
19 changes: 19 additions & 0 deletions
19
Content.Server/_Sunrise/Shuttles/CodeEquipmentShuttleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
||
namespace Content.Server._Sunrise.Shuttles; | ||
|
||
[RegisterComponent] | ||
public sealed partial class CodeEquipmentShuttleComponent : Component | ||
{ | ||
[DataField("station")] | ||
public EntityUid Station; | ||
|
||
[DataField] | ||
public string PriorityTag = "DockGamma"; | ||
|
||
[DataField] | ||
public bool EnableDockAnnouncement = true; | ||
|
||
[DataField] | ||
public string DockAnnounceMessage = "announcement-gamma-armory"; | ||
} |
106 changes: 106 additions & 0 deletions
106
Content.Server/_Sunrise/Shuttles/CodeEquipmentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using Content.Server._Sunrise.ImmortalGrid; | ||
using Content.Server.AlertLevel; | ||
using Content.Server.Chat.Managers; | ||
using Content.Server.Chat.Systems; | ||
using Content.Server.DeviceNetwork.Systems; | ||
using Content.Server.GameTicking; | ||
using Content.Server.Shuttles.Components; | ||
using Content.Server.Shuttles.Events; | ||
using Content.Server.Shuttles.Systems; | ||
using Content.Server.Station.Components; | ||
using Content.Server.Station.Events; | ||
using Content.Server.Station.Systems; | ||
using Content.Shared.Shuttles.Components; | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Console; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Random; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server._Sunrise.Shuttles; | ||
|
||
public sealed class CodeEquipmentSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
[Dependency] private readonly MapLoaderSystem _loader = default!; | ||
[Dependency] private readonly ShuttleSystem _shuttles = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
[Dependency] private readonly ChatSystem _chat = default!; | ||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<CodeEquipmentComponent, StationPostInitEvent>(OnStationPostInit); | ||
SubscribeLocalEvent<CodeEquipmentShuttleComponent, ComponentStartup>(OnComponentStartup); | ||
SubscribeLocalEvent<CodeEquipmentShuttleComponent, FTLTagEvent>(OnFTLShuttleTag); | ||
SubscribeLocalEvent<CodeEquipmentShuttleComponent, FTLStartedEvent>(OnFTLStartedEvent); | ||
SubscribeLocalEvent<CodeEquipmentShuttleComponent, FTLCompletedEvent>(OnFTLCompletedEvent); | ||
SubscribeLocalEvent<AlertLevelChangedEvent>(OnAlertLevelChanged); | ||
} | ||
|
||
private void OnStationPostInit(EntityUid uid, CodeEquipmentComponent comp, StationPostInitEvent ev) | ||
{ | ||
var map = _mapManager.CreateMap(); | ||
var loadOptions = new MapLoadOptions(); | ||
loadOptions.LoadMap = true; | ||
loadOptions.StoreMapUids = true; | ||
_loader.TryLoad(map, comp.ShuttlePath.ToString(), out var shuttleUids, loadOptions); | ||
if (shuttleUids is null) | ||
return; | ||
comp.Shuttles.Add(shuttleUids[0]); | ||
var gammaArmoryComp = EnsureComp<CodeEquipmentShuttleComponent>(shuttleUids[0]); | ||
gammaArmoryComp.Station = uid; | ||
EnsureComp<ImmortalGridComponent>(shuttleUids[0]); | ||
} | ||
|
||
private void OnFTLShuttleTag(EntityUid uid, CodeEquipmentShuttleComponent comp, ref FTLTagEvent ev) | ||
{ | ||
if (ev.Handled) | ||
return; | ||
|
||
ev.Handled = true; | ||
ev.Tag = comp.PriorityTag; | ||
} | ||
|
||
private void OnComponentStartup(EntityUid uid, CodeEquipmentShuttleComponent comp, ComponentStartup ev) | ||
{ | ||
EnsureComp<PreventPilotComponent>(uid); | ||
} | ||
|
||
private void OnFTLStartedEvent(EntityUid uid, CodeEquipmentShuttleComponent comp, ref FTLStartedEvent ev) | ||
{ | ||
|
||
} | ||
|
||
private void OnFTLCompletedEvent(EntityUid uid, CodeEquipmentShuttleComponent comp, ref FTLCompletedEvent ev) | ||
{ | ||
if (comp.EnableDockAnnouncement) | ||
{ | ||
_chat.DispatchGlobalAnnouncement( | ||
Loc.GetString(comp.DockAnnounceMessage), | ||
colorOverride: Color.PaleVioletRed, | ||
announceVoice: "Azir"); | ||
} | ||
} | ||
|
||
private void OnAlertLevelChanged(AlertLevelChangedEvent ev) | ||
{ | ||
if (!TryComp<CodeEquipmentComponent>(ev.Station, out var comp)) | ||
return; | ||
|
||
if (ev.AlertLevel != comp.TargetCode) | ||
return; | ||
|
||
var target = _station.GetLargestGrid(Comp<StationDataComponent>(ev.Station)); | ||
|
||
if (target == null) | ||
return; | ||
|
||
_shuttles.FTLToDock( | ||
comp.Shuttles[0], | ||
Comp<ShuttleComponent>(comp.Shuttles[0]), | ||
target.Value, | ||
priorityTag: comp.PriorityTag, | ||
ignored: true); | ||
} | ||
} |
Oops, something went wrong.