Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into 2024-01-14-CodeOwners
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Jan 22, 2024
2 parents 9b390f1 + 1906d07 commit 08edfd9
Show file tree
Hide file tree
Showing 242 changed files with 8,633 additions and 4,413 deletions.
4 changes: 0 additions & 4 deletions .github/mapchecker/whitelist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Metastable:
- SignSec
DartX:
- HighSecDoor
gourd:
- HoloprojectorSecurity
Praeda:
- ClothingEyesGlassesSecurity
- EncryptionKeyCommand
Expand All @@ -44,8 +42,6 @@ Pheonix:
Spectre:
- AirlockSecurity
- EncryptionKeyMedicalScience
Bazaar:
- AirlockSecurity
Anchor:
- AirlockSecurity
- IntercomCommand
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.NewFrontier.Latejoin;
using Content.Client._NF.Latejoin;
using Content.Client.Chat.Managers;
using Content.Client.GameTicking.Managers;
using Content.Client.LateJoin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:lateJoin="clr-namespace:Content.Client.NewFrontier.Latejoin"
xmlns:lateJoin="clr-namespace:Content.Client._NF.Latejoin"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="Join Game"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Client.NewFrontier.Latejoin;
namespace Content.Client._NF.Latejoin;

[GenerateTypedNameReferences]
public sealed partial class NFLateJoinGui : FancyWindow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Robust.Client.Utility;
using Robust.Shared.Prototypes;

namespace Content.Client.NewFrontier.Latejoin;
namespace Content.Client._NF.Latejoin;

[GenerateTypedNameReferences]
public sealed partial class NewFrontierLateJoinJobButton : Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Player;

namespace Content.Client.NewFrontier.Latejoin;
namespace Content.Client._NF.Latejoin;

[GenerateTypedNameReferences]
public sealed partial class VesselListControl : BoxContainer
Expand All @@ -24,6 +25,7 @@ public NetEntity? Selected
return (NetEntity) i.Metadata!;
}
}
private IReadOnlyDictionary<NetEntity, Dictionary<string, uint?>>? _lastJobState;

public VesselListControl()
{
Expand All @@ -34,6 +36,12 @@ public VesselListControl()
UpdateUi(_gameTicker.JobsAvailable);

Comparison = DefaultComparison;

FilterLineEdit.OnTextChanged += _ =>
{
if (_lastJobState != null)
UpdateUi(_lastJobState);
};
}

protected override void Dispose(bool disposing)
Expand All @@ -44,7 +52,8 @@ protected override void Dispose(bool disposing)

private int DefaultComparison(NetEntity x, NetEntity y)
{
return (int)(_gameTicker.JobsAvailable[x].Values.Sum(a => a ?? 0) - _gameTicker.JobsAvailable[y].Values.Sum(b => b ?? 0));
// Negated to enforce descending order
return -(int)(_gameTicker.JobsAvailable[x].Values.Sum(a => a ?? 0) - _gameTicker.JobsAvailable[y].Values.Sum(b => b ?? 0));
}

public void Sort()
Expand All @@ -55,27 +64,18 @@ public void Sort()

private void UpdateUi(IReadOnlyDictionary<NetEntity, Dictionary<string, uint?>> obj)
{
var itemsToRemove = new List<ItemList.Item>();
foreach (var (key, item) in VesselItemList.Select(x => ((NetEntity)x.Metadata!, x)))
{
if (!_gameTicker.StationNames.ContainsKey(key))
itemsToRemove.Add(item);
}

foreach (var item in itemsToRemove)
{
VesselItemList.Remove(item);
}
VesselItemList.Clear();

foreach (var (key, name) in _gameTicker.StationNames)
{
if (VesselItemList.Any(x => ((NetEntity)x.Metadata!) == key))
continue;

var jobsAvailable = _gameTicker.JobsAvailable[key].Values.Sum(a => a ?? 0).ToString();
var item = new ItemList.Item(VesselItemList)
{
Metadata = key,
Text = name
Text = name + $" ({jobsAvailable})"
};

if (!string.IsNullOrEmpty(FilterLineEdit.Text) &&
Expand All @@ -88,5 +88,7 @@ private void UpdateUi(IReadOnlyDictionary<NetEntity, Dictionary<string, uint?>>
}

Sort();

_lastJobState = obj;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Content.Server.Item.PseudoItem;

/// <summary>
/// Signifies that pseudo-item creatures can sleep inside the container to which this component was added.
/// </summary>
[RegisterComponent]
public sealed partial class AllowsSleepInsideComponent : Component
{
}
23 changes: 23 additions & 0 deletions Content.Server/Nyanotrasen/Item/PseudoItem/PseudoItemSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Content.Server.Actions;
using Content.Server.Bed.Sleep;
using Content.Server.DoAfter;
using Content.Server.Popups;
using Content.Server.Storage.EntitySystems;
using Content.Shared.Bed.Sleep;
using Content.Shared.DoAfter;
using Content.Shared.Hands;
using Content.Shared.IdentityManagement;
Expand All @@ -18,6 +22,8 @@ public sealed class PseudoItemSystem : EntitySystem
[Dependency] private readonly ItemSystem _itemSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly ActionsSystem _actions = default!; // Frontier
[Dependency] private readonly PopupSystem _popup = default!; // Frontier

[ValidatePrototypeId<TagPrototype>]
private const string PreventTag = "PreventLabel";
Expand All @@ -32,6 +38,7 @@ public override void Initialize()
SubscribeLocalEvent<PseudoItemComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<PseudoItemComponent, PseudoItemInsertDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<PseudoItemComponent, ContainerGettingInsertedAttemptEvent>(OnInsertAttempt);
SubscribeLocalEvent<PseudoItemComponent, TryingToSleepEvent>(OnTrySleeping); // Frontier
}

private void AddInsertVerb(EntityUid uid, PseudoItemComponent component, GetVerbsEvent<InnateVerb> args)
Expand Down Expand Up @@ -96,6 +103,10 @@ private void OnEntRemoved(EntityUid uid, PseudoItemComponent component, EntGotRe

RemComp<ItemComponent>(uid);
component.Active = false;

// Frontier
if (component.SleepAction is { Valid: true })
_actions.RemoveAction(uid, component.SleepAction);
}

private void OnGettingPickedUpAttempt(EntityUid uid, PseudoItemComponent component,
Expand Down Expand Up @@ -142,6 +153,10 @@ public bool TryInsert(EntityUid storageUid, EntityUid toInsert, PseudoItemCompon
return false;
}

// Frontier
if (HasComp<AllowsSleepInsideComponent>(storageUid))
_actions.AddAction(toInsert, ref component.SleepAction, SleepingSystem.SleepActionId, toInsert);

component.Active = true;
return true;
}
Expand Down Expand Up @@ -171,4 +186,12 @@ private void OnInsertAttempt(EntityUid uid, PseudoItemComponent component,
// This hopefully shouldn't trigger, but this is a failsafe just in case so we dont bluespace them cats
args.Cancel();
}

// Frontier - show a popup when a pseudo-item falls asleep inside a bag.
private void OnTrySleeping(EntityUid uid, PseudoItemComponent component, TryingToSleepEvent args)
{
var parent = Transform(uid).ParentUid;
if (!HasComp<SleepingComponent>(uid) && parent is { Valid: true } && HasComp<AllowsSleepInsideComponent>(parent))
_popup.PopupEntity(Loc.GetString("popup-sleep-in-bag", ("entity", uid)), uid);
}
}
61 changes: 52 additions & 9 deletions Content.Server/_NF/PublicTransit/PublicTransitSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Content.Server._NF.PublicTransit.Components;
using Content.Server.Chat.Systems;
using Content.Server.GameTicking;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Events;
using Content.Server.Shuttles.Systems;
using Content.Shared.GameTicking;
using Content.Shared.NF14.CCVar;
using Content.Shared.Shuttles.Components;
using Content.Shared.Tiles;
Expand All @@ -25,6 +27,7 @@ public sealed class PublicTransitSystem : EntitySystem
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly MapLoaderSystem _loader = default!;
[Dependency] private readonly ShuttleSystem _shuttles = default!;
[Dependency] private readonly ChatSystem _chat = default!;

/// <summary>
/// If enabled then spawns the bus and sets up the bus line.
Expand All @@ -42,7 +45,9 @@ public override void Initialize()
SubscribeLocalEvent<StationTransitComponent, ComponentShutdown>(OnStationShutdown);
SubscribeLocalEvent<TransitShuttleComponent, ComponentStartup>(OnShuttleStartup);
SubscribeLocalEvent<TransitShuttleComponent, EntityUnpausedEvent>(OnShuttleUnpaused);
SubscribeLocalEvent<TransitShuttleComponent, FTLCompletedEvent>(OnShuttleArrival);
SubscribeLocalEvent<TransitShuttleComponent, FTLTagEvent>(OnShuttleTag);
SubscribeLocalEvent<RoundStartedEvent>(OnRoundStart);

Enabled = _cfgManager.GetCVar(NF14CVars.PublicTransit);
FlyTime = _cfgManager.GetCVar(NF14CVars.PublicTransitFlyTime);
Expand All @@ -52,6 +57,21 @@ public override void Initialize()
_cfgManager.OnValueChanged(NF14CVars.PublicTransitFlyTime, SetFly);
}

public void OnRoundStart(RoundStartedEvent args)
{
Counter = 0;
if (Enabled)
SetupPublicTransit();
}

public override void Shutdown()
{
base.Shutdown();
_cfgManager.UnsubValueChanged(NF14CVars.PublicTransitFlyTime, SetFly);
_cfgManager.UnsubValueChanged(NF14CVars.PublicTransit, SetTransit);
}


/// <summary>
/// Hardcoded snippit to intercept FTL events. It catches the transit shuttle and ensures its looking for the "DockTransit" priority dock.
/// </summary>
Expand All @@ -65,13 +85,6 @@ private void OnShuttleTag(EntityUid uid, TransitShuttleComponent component, ref
args.Tag = "DockTransit";
}

public override void Shutdown()
{
base.Shutdown();
_cfgManager.UnsubValueChanged(NF14CVars.PublicTransitFlyTime, SetFly);
_cfgManager.UnsubValueChanged(NF14CVars.PublicTransit, SetTransit);
}

/// <summary>
/// Checks to make sure the grid is on the appropriate playfield, i.e., not in mapping space being worked on.
/// If so, adds the grid to the list of bus stops, but only if its not already there
Expand All @@ -82,8 +95,6 @@ private void OnStationStartup(EntityUid uid, StationTransitComponent component,
{
if (!StationList.Contains(uid)) //if the grid isnt already in
StationList.Add(uid); //add it to the list
if (Enabled) //and just in case this has been added dynamically mid-round, lets do a setup check
SetupPublicTransit();
}
}

Expand Down Expand Up @@ -114,6 +125,24 @@ private void OnShuttleUnpaused(EntityUid uid, TransitShuttleComponent component,
component.NextTransfer += args.PausedTime;
}

private void OnShuttleArrival(EntityUid uid, TransitShuttleComponent comp, ref FTLCompletedEvent args)
{
var consoleQuery = EntityQueryEnumerator<ShuttleConsoleComponent>();

while (consoleQuery.MoveNext(out var consoleUid, out _))
{
if (Transform(consoleUid).GridUid == uid)
{
var destinationString = MetaData(comp.NextStation).EntityName;

_chat.TrySendInGameICMessage(consoleUid, Loc.GetString("public-transit-arrival",
("destination", destinationString), ("waittime", _cfgManager.GetCVar(NF14CVars.PublicTransitWaitTime))),
InGameICChatType.Speak, ChatTransmitRange.HideChat, hideLog: true, checkRadioPrefix: false,
ignoreActionBlocker: true);
}
}
}

/// <summary>
/// Here is our bus stop list handler. Theres probably a better way...
/// First, sets our output to null just in case
Expand Down Expand Up @@ -158,6 +187,20 @@ public override void Update(float frameTime)
if (comp.NextTransfer > curTime)
continue;

var consoleQuery = EntityQueryEnumerator<ShuttleConsoleComponent>();

while (consoleQuery.MoveNext(out var consoleUid, out _))
{
if (Transform(consoleUid).GridUid == uid)
{
var destinationString = MetaData(comp.NextStation).EntityName;

_chat.TrySendInGameICMessage(consoleUid, Loc.GetString("public-transit-departure",
("destination", destinationString), ("flytime", FlyTime)),
InGameICChatType.Speak, ChatTransmitRange.HideChat, hideLog: true, checkRadioPrefix: false,
ignoreActionBlocker: true);
}
}
_shuttles.FTLTravel(uid, shuttle, comp.NextStation, hyperspaceTime: FlyTime, dock: true);

if (TryGetNextStation(out var nextStation) && nextStation is {Valid : true} destination)
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Access/Components/IdCardConsoleComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public sealed partial class IdCardConsoleComponent : Component
"Maintenance",
"Medical",
"Mercenary", // Frontier
"Pilot", // Frontier
"Quartermaster",
"Research",
"ResearchDirector",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ public sealed partial class PseudoItemComponent : Component, ITransferredByCloni
public int Size = 120;

public bool Active = false;

[DataField]
public EntityUid? SleepAction;
}
Loading

0 comments on commit 08edfd9

Please sign in to comment.