Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into bocadillo-ship
Browse files Browse the repository at this point in the history
  • Loading branch information
kennedytcooper committed Aug 10, 2023
2 parents 9e89f6f + 61d70d7 commit 6631627
Show file tree
Hide file tree
Showing 269 changed files with 71,280 additions and 9,755 deletions.
56 changes: 56 additions & 0 deletions Content.Client/_NF/M_Emp/UI/M_EmpBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared._NF.M_Emp;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client._NF.M_Emp.UI
{
[UsedImplicitly]
public sealed class M_EmpBoundUserInterface : BoundUserInterface
{
private M_EmpWindow? _window;

public M_EmpBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();

_window = new M_EmpWindow(this);
_window.OnClose += Close;
_window.OpenCentered();
}

/// <summary>
/// Update the ui each time new state data is sent from the server.
/// </summary>
/// <param name="state">
/// Data of the <see cref="SharedReagentDispenserComponent"/> that this ui represents.
/// Sent from the server.
/// </param>
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

// var castState = (M_EmpBoundUserInterfaceState) state;
// _window?.UpdateState(castState); //Update window state
}

public void ButtonPressed(UiButton button)
{
SendMessage(new UiButtonPressedMessage(button));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (disposing)
{
_window?.Dispose();
}
}
}
}

37 changes: 37 additions & 0 deletions Content.Client/_NF/M_Emp/UI/M_EmpWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<DefaultWindow
xmlns="https://spacestation14.io"
Title="{Loc 'm_emp-console-menu-title'}"
SetSize="280 220"
MinSize="280 220"
HorizontalExpand="False"
>
<BoxContainer Orientation="Vertical" HorizontalExpand="False">
<BoxContainer HorizontalExpand="False">
<Label Text="{Loc 'm_emp-menu-note1'}" />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Button Name="RequestButton"
Text="{Loc 'm_emp-request-button'}"
StyleClasses="OpenBoth"
Disabled="False" />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Label Text=" " />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Label Text="{Loc 'm_emp-menu-note2'}" />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Label Text="{Loc 'm_emp-menu-note3'}" />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Label Text="{Loc 'm_emp-menu-note4'}" />
</BoxContainer>
<BoxContainer HorizontalExpand="False">
<Button Name="ActivateButton"
Text="{Loc 'm_emp-activate-button'}"
StyleClasses="OpenBoth"
Disabled="False" />
</BoxContainer>
</BoxContainer>
</DefaultWindow>
39 changes: 39 additions & 0 deletions Content.Client/_NF/M_Emp/UI/M_EmpWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Client.UserInterface;
using Content.Shared._NF.M_Emp;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._NF.M_Emp.UI
{
[GenerateTypedNameReferences]
public sealed partial class M_EmpWindow : DefaultWindow
{
public M_EmpWindow(M_EmpBoundUserInterface ui)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

RequestButton.OnPressed += _ => ui.ButtonPressed(UiButton.Request);
ActivateButton.OnPressed += _ => ui.ButtonPressed(UiButton.Activate);
}

/// <summary>
/// Update the UI state when new state data is received from the server.
/// </summary>
/// <param name="state">State data sent by the server.</param>
public void UpdateState(BoundUserInterfaceState state)
{
var castState = (M_EmpBoundUserInterfaceState) state;

// Disable all buttons if not powered
if (Contents.Children != null)
{
ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower);
}

//CoreCount.Text = $"{castState.CoreCount}";
//InjectionAmount.Text = $"{castState.InjectionAmount}";
}
}
}
7 changes: 7 additions & 0 deletions Content.Server/Emp/EmpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Emp;
using Content.Shared.Examine;
using Robust.Shared.Map;
using static Content.Server.Shuttles.Systems.ThrusterSystem;

namespace Content.Server.Emp;

Expand All @@ -26,6 +27,7 @@ public override void Initialize()
SubscribeLocalEvent<EmpDisabledComponent, RadioReceiveAttemptEvent>(OnRadioReceiveAttempt);
SubscribeLocalEvent<EmpDisabledComponent, ApcToggleMainBreakerAttemptEvent>(OnApcToggleMainBreaker);
SubscribeLocalEvent<EmpDisabledComponent, SurveillanceCameraSetActiveAttemptEvent>(OnCameraSetActive);
SubscribeLocalEvent<EmpDisabledComponent, ThrusterToggleAttemptEvent>(OnThrusterToggle);
}

public void EmpPulse(MapCoordinates coordinates, float range, float energyConsumption, float duration)
Expand Down Expand Up @@ -99,6 +101,11 @@ private void OnCameraSetActive(EntityUid uid, EmpDisabledComponent component, re
{
args.Cancelled = true;
}

private void OnThrusterToggle(EntityUid uid, EmpDisabledComponent component, ref ThrusterToggleAttemptEvent args)
{
args.Cancelled = true;
}
}

[ByRefEvent]
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Fax/FaxMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public sealed class FaxMachineComponent : Component
[DataField("name")]
public string FaxName { get; set; } = "Unknown";

/// <summary>
/// If true, will sync fax name with a station name.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("useStationName")]
public bool UseStationName { get; set; }

/// <summary>
/// Device address of fax in network to which data will be send
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Fax/FaxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ private void OnInteractUsing(EntityUid uid, FaxMachineComponent component, Inter
component.FaxName = newName;
_popupSystem.PopupEntity(Loc.GetString("fax-machine-popup-name-set"), uid);
UpdateUserInterface(uid, component);
// if we changed our fax name manually
// it will loose sync with station name
component.UseStationName = false;
});

args.Handled = true;
Expand Down
2 changes: 2 additions & 0 deletions Content.Server/GameTicking/GameTicker.RoundFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public void StartRound(bool force = false)
UpdateLateJoinStatus();
AnnounceRound();
UpdateInfoText();
RaiseLocalEvent(new RoundStartedEvent(RoundId));

#if EXCEPTION_TOLERANCE
}
Expand Down Expand Up @@ -359,6 +360,7 @@ public void ShowRoundEndScoreboard(string text = "")
RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong,
new SoundCollectionSpecifier("RoundEnd").GetSound()));
RaiseLocalEvent(new RoundEndedEvent(RoundId, roundDuration));
}

public void RestartRound()
Expand Down
13 changes: 13 additions & 0 deletions Content.Server/Nyanotrasen/GameTicking/RoundEndedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Content.Shared.GameTicking;

public sealed class RoundEndedEvent : EntityEventArgs
{
public int RoundId { get; }
public TimeSpan RoundDuration { get; }

public RoundEndedEvent(int roundId, TimeSpan roundDuration)
{
RoundId = roundId;
RoundDuration = roundDuration;
}
}
4 changes: 4 additions & 0 deletions Content.Server/Nyanotrasen/Mail/Components/MailComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public sealed class MailComponent : SharedMailComponent
[DataField("recipientJob")]
public string RecipientJob = "None";

[ViewVariables(VVAccess.ReadWrite)]
[DataField("recipientStation")]
public string RecipientStation = "None";

// Why do we not use LockComponent?
// Because this can't be locked again,
// and we have special conditions for unlocking,
Expand Down
35 changes: 30 additions & 5 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
using Content.Server.Nutrition.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationRecords.Systems;
using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Content.Shared.Coordinates;
using Content.Shared.Damage;
using Content.Shared.Emag.Components;
using Content.Shared.Destructible;
Expand Down Expand Up @@ -60,6 +63,7 @@ public sealed class MailSystem : EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly StationRecordsSystem _recordsSystem = default!;

private ISawmill _sawmill = default!;

Expand Down Expand Up @@ -214,7 +218,7 @@ private void OnExamined(EntityUid uid, MailComponent component, ExaminedEvent ar
return;
}

args.PushMarkup(Loc.GetString("mail-desc-close", ("name", component.Recipient), ("job", component.RecipientJob)));
args.PushMarkup(Loc.GetString("mail-desc-close", ("name", component.Recipient), ("job", component.RecipientJob), ("station", component.RecipientStation)));

if (component.IsFragile)
args.PushMarkup(Loc.GetString("mail-desc-fragile"));
Expand Down Expand Up @@ -444,7 +448,7 @@ public void SetupMail(EntityUid uid, MailTeleporterComponent component, MailReci

mailComp.RecipientJob = recipient.Job;
mailComp.Recipient = recipient.Name;

mailComp.RecipientStation = recipient.Ship;
if (mailComp.IsFragile)
{
mailComp.Bounty += component.FragileBonus;
Expand Down Expand Up @@ -536,6 +540,20 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
HashSet<String> accessTags = access.Tags;

var mayReceivePriorityMail = true;
var stationUid = _stationSystem.GetOwningStation(receiver.Owner);
var stationName = string.Empty;
if (stationUid is EntityUid station
&& TryComp<StationDataComponent>(station, out var stationData)
&& _stationSystem.GetLargestGrid(stationData) is EntityUid stationGrid
&& TryName(stationGrid, out var gridName)
&& gridName != null)
{
stationName = gridName;
}
else
{
stationName = "Unknown";
}

if (TryComp<MindContainerComponent>(receiver.Owner, out MindContainerComponent? mind)
&& mind.Mind?.Session == null)
Expand All @@ -546,7 +564,8 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
recipient = new MailRecipient(idCard.FullName,
idCard.JobTitle,
accessTags,
mayReceivePriorityMail);
mayReceivePriorityMail,
stationName);

return true;
}
Expand All @@ -561,12 +580,16 @@ public bool TryGetMailRecipientForReceiver(MailReceiverComponent receiver, [NotN
public List<MailRecipient> GetMailRecipientCandidates(EntityUid uid)
{
List<MailRecipient> candidateList = new();

var mailLocation = Transform(uid);
foreach (var receiver in EntityQuery<MailReceiverComponent>())
{
// mail is mapwide now, dont need to check if they are on the same station
//if (_stationSystem.GetOwningStation(receiver.Owner) != _stationSystem.GetOwningStation(uid))
// continue;
var location = Transform(receiver.Owner);

if (location.MapID != mailLocation.MapID)
continue;

if (TryGetMailRecipientForReceiver(receiver, out MailRecipient? recipient))
candidateList.Add(recipient.Value);
Expand Down Expand Up @@ -700,13 +723,15 @@ public struct MailRecipient
public string Job;
public HashSet<String> AccessTags;
public bool MayReceivePriorityMail;
public string Ship;

public MailRecipient(string name, string job, HashSet<String> accessTags, bool mayReceivePriorityMail)
public MailRecipient(string name, string job, HashSet<String> accessTags, bool mayReceivePriorityMail, string ship)
{
Name = name;
Job = job;
AccessTags = accessTags;
MayReceivePriorityMail = mayReceivePriorityMail;
Ship = ship;
}
}
}
Loading

0 comments on commit 6631627

Please sign in to comment.