Skip to content

Commit

Permalink
Merge branch 'master' into SSS-Omakase
Browse files Browse the repository at this point in the history
  • Loading branch information
ErhardSteinhauer authored Oct 22, 2024
2 parents 5dafb35 + 33258e8 commit cd18d53
Show file tree
Hide file tree
Showing 273 changed files with 5,834 additions and 2,961 deletions.
2 changes: 2 additions & 0 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Replays;
using Robust.Shared.Timing;
using Content.Client._NF.Emp.Overlays; // Frontier

namespace Content.Client.Entry
{
Expand Down Expand Up @@ -154,6 +155,7 @@ public override void PostInit()

_overlayManager.AddOverlay(new SingularityOverlay());
_overlayManager.AddOverlay(new RadiationPulseOverlay());
_overlayManager.AddOverlay(new EmpBlastOverlay()); // Frontier
_chatManager.Initialize();
_clientPreferencesManager.Initialize();
_euiManager.Initialize();
Expand Down
9 changes: 0 additions & 9 deletions Content.Client/GPS/Components/HandheldGPSComponent.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Content.Client/GPS/Systems/HandheldGpsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.GPS.UI;
using Content.Client.Items;

Expand Down
15 changes: 11 additions & 4 deletions Content.Client/GPS/UI/HandheldGpsStatusControl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.GPS.Components;
using Content.Shared.GPS.Components;
using Content.Client.Message;
using Content.Client.Stylesheets;
using Robust.Client.GameObjects;
Expand Down Expand Up @@ -30,6 +30,13 @@ protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

// don't display the label if the gps component is being removed
if (_parent.Comp.LifeStage > ComponentLifeStage.Running)
{
_label.Visible = false;
return;
}

_updateDif += args.DeltaSeconds;
if (_updateDif < _parent.Comp.UpdateRate)
return;
Expand All @@ -44,9 +51,9 @@ private void UpdateGpsDetails()
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int) pos.X;
var y = (int) pos.Y;
var pos = _transform.GetMapCoordinates(_parent.Owner, xform: transComp);
var x = (int)pos.X;
var y = (int)pos.Y;
posText = $"({x}, {y})";
}
_label.SetMarkup(Loc.GetString("handheld-gps-coordinates-title", ("coordinates", posText)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private void Populate(List<string> availablePrototypes, List<string> unavailable
_menu.PopulateProducts(availablePrototypes, unavailablePrototypes, freeListings, validId);
_menu.PopulateCategories(availablePrototypes, unavailablePrototypes);
_menu.PopulateClasses(availablePrototypes, unavailablePrototypes);
_menu.PopulateEngines(availablePrototypes, unavailablePrototypes);
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
7 changes: 5 additions & 2 deletions Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="600 500"
MinSize="600 300">
SetSize="640 500"
MinSize="640 300">
<BoxContainer Orientation="Vertical" Margin="5 0 5 0">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
Expand Down Expand Up @@ -32,6 +32,9 @@
<OptionButton Name="Classes"
Prefix="{Loc 'shipyard-console-menu-class-label'}"
HorizontalExpand="True" />
<OptionButton Name="Engines"
Prefix="{Loc 'shipyard-console-menu-engine-label'}"
HorizontalExpand="True" />
</BoxContainer>
<ScrollContainer HorizontalExpand="True"
VerticalExpand="True"
Expand Down
61 changes: 61 additions & 0 deletions Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow
private readonly ShipyardConsoleBoundUserInterface _menu;
private readonly List<VesselSize> _categoryStrings = new();
private readonly List<VesselClass> _classStrings = new();
private readonly List<VesselEngine> _engineStrings = new();
private VesselSize? _category;
private VesselClass? _class;
private VesselEngine? _engine;

private List<string> _lastAvailableProtos = new();
private List<string> _lastUnavailableProtos = new();
Expand All @@ -39,6 +41,7 @@ public ShipyardConsoleMenu(ShipyardConsoleBoundUserInterface owner)
SearchBar.OnTextChanged += OnSearchBarTextChanged;
Categories.OnItemSelected += OnCategoryItemSelected;
Classes.OnItemSelected += OnClassItemSelected;
Engines.OnItemSelected += OnEngineItemSelected;
SellShipButton.OnPressed += (args) => { OnSellShip?.Invoke(args); };
}

Expand All @@ -55,6 +58,12 @@ private void OnClassItemSelected(OptionButton.ItemSelectedEventArgs args)
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
}

private void OnEngineItemSelected(OptionButton.ItemSelectedEventArgs args)
{
SetEngineText(args.Id);
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
}

private void OnSearchBarTextChanged(LineEdit.LineEditEventArgs args)
{
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
Expand All @@ -70,6 +79,11 @@ private void SetClassText(int id)
_class = id == 0 ? null : _classStrings[id];
Classes.SelectId(id);
}
private void SetEngineText(int id)
{
_engine = id == 0 ? null : _engineStrings[id];
Engines.SelectId(id);
}
/// <summary>
/// Populates the list of products that will actually be shown, using the current filters.
/// </summary>
Expand Down Expand Up @@ -115,6 +129,8 @@ private void AddVesselsToControls(IEnumerable<VesselPrototype?> vessels, string
continue;
if (_class != null && !prototype!.Classes.Contains(_class.Value))
continue;
if (_engine != null && !prototype!.Engines.Contains(_engine.Value))
continue;
if (search.Length > 0 && !prototype!.Name.ToLowerInvariant().Contains(search))
continue;

Expand Down Expand Up @@ -176,6 +192,9 @@ private void AddCategoriesFromPrototypes(IEnumerable<string> prototypes)
}
}

/// <summary>
/// Populates the list classes that will actually be shown, using the current filters.
/// </summary>
public void PopulateClasses(List<string> availablePrototypes, List<string> unavailablePrototypes)
{
_classStrings.Clear();
Expand Down Expand Up @@ -215,6 +234,48 @@ private void AddClassesFromPrototypes(IEnumerable<string> prototypes)
}
}

/// <summary>
/// Populates the list engines that will actually be shown, using the current filters.
/// </summary>
public void PopulateEngines(List<string> availablePrototypes, List<string> unavailablePrototypes)
{
_engineStrings.Clear();
Engines.Clear();

AddEnginesFromPrototypes(availablePrototypes);
AddEnginesFromPrototypes(unavailablePrototypes);

_engineStrings.Sort();

// Add "All" category at the top of the list
_engineStrings.Insert(0, VesselEngine.All);

foreach (var str in _engineStrings)
{
Engines.AddItem(Loc.GetString($"shipyard-console-engine-{str}"));
}
}

/// <summary>
/// Adds all ship engine power type from a list of vessel prototypes to the current control's list if they are missing.
/// </summary>
private void AddEnginesFromPrototypes(IEnumerable<string> prototypes)
{
foreach (var protoId in prototypes)
{
if (!_protoManager.TryIndex<VesselPrototype>(protoId, out var prototype))
continue;

foreach (var cl in prototype.Engines)
{
if (!_engineStrings.Contains(cl) && cl != VesselEngine.All)
{
_engineStrings.Add(cl);
}
}
}
}

public void UpdateState(ShipyardConsoleInterfaceState state)
{
BalanceLabel.Text = BankSystemExtensions.ToSpesoString(state.Balance);
Expand Down
145 changes: 145 additions & 0 deletions Content.Client/_NF/Emp/Overlays/EmpBlastOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using System.Numerics;
using Content.Shared._NF.Emp.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Graphics;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client._NF.Emp.Overlays
{
public sealed class EmpBlastOverlay : Overlay
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
private TransformSystem? _transform;

private const float PvsDist = 25.0f;

public override OverlaySpace Space => OverlaySpace.WorldSpace;
public override bool RequestScreenTexture => true;

private readonly ShaderInstance _baseShader;
private readonly Dictionary<EntityUid, (ShaderInstance shd, EmpShaderInstance instance)> _blasts = new();

public EmpBlastOverlay()
{
IoCManager.InjectDependencies(this);
_baseShader = _prototypeManager.Index<ShaderPrototype>("Emp").Instance().Duplicate();
}

protected override bool BeforeDraw(in OverlayDrawArgs args)
{
EmpQuery(args.Viewport.Eye);
return _blasts.Count > 0;
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
return;

var worldHandle = args.WorldHandle;
var viewport = args.Viewport;

foreach ((var shd, var instance) in _blasts.Values)
{
if (instance.CurrentMapCoords.MapId != args.MapId)
continue;

// To be clear, this needs to use "inside-viewport" pixels.
// In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
var tempCoords = viewport.WorldToLocal(instance.CurrentMapCoords.Position);
tempCoords.Y = viewport.Size.Y - tempCoords.Y;
shd?.SetParameter("renderScale", viewport.RenderScale);
shd?.SetParameter("positionInput", tempCoords);
shd?.SetParameter("range", instance.Range);
var life = (_gameTiming.RealTime - instance.Start).TotalSeconds / instance.Duration;
shd?.SetParameter("life", (float)life);

// There's probably a very good reason not to do this.
// Oh well!
shd?.SetParameter("SCREEN_TEXTURE", viewport.RenderTarget.Texture);

worldHandle.UseShader(shd);
worldHandle.DrawRect(Box2.CenteredAround(instance.CurrentMapCoords.Position, new Vector2(instance.Range, instance.Range) * 2f), Color.White);
}

worldHandle.UseShader(null);
}

//Queries all blasts on the map and either adds or removes them from the list of rendered blasts based on whether they should be drawn (in range? on the same z-level/map? blast entity still exists?)
private void EmpQuery(IEye? currentEye)
{
_transform ??= _entityManager.System<TransformSystem>();

if (currentEye == null)
{
_blasts.Clear();
return;
}

var currentEyeLoc = currentEye.Position;

var blasts = _entityManager.EntityQueryEnumerator<EmpBlastComponent>();
//Add all blasts that are not added yet but qualify
while (blasts.MoveNext(out var blastEntity, out var blast))
{
if (!_blasts.ContainsKey(blastEntity) && BlastQualifies(blastEntity, currentEyeLoc, blast))
{
_blasts.Add(
blastEntity,
(
_baseShader.Duplicate(),
new EmpShaderInstance(
_transform.GetMapCoordinates(blastEntity),
blast.VisualRange,
blast.StartTime,
blast.VisualDuration
)
)
);
}
}

var activeShaderIds = _blasts.Keys;
foreach (var blastEntity in activeShaderIds) //Remove all blasts that are added and no longer qualify
{
if (_entityManager.EntityExists(blastEntity) &&
_entityManager.TryGetComponent(blastEntity, out EmpBlastComponent? blast) &&
BlastQualifies(blastEntity, currentEyeLoc, blast))
{
var shaderInstance = _blasts[blastEntity];
shaderInstance.instance.CurrentMapCoords = _transform.GetMapCoordinates(blastEntity);
shaderInstance.instance.Range = blast.VisualRange;
}
else
{
_blasts[blastEntity].shd.Dispose();
_blasts.Remove(blastEntity);
}
}

}

private bool BlastQualifies(EntityUid blastEntity, MapCoordinates currentEyeLoc, EmpBlastComponent blast)
{
var transformComponent = _entityManager.GetComponent<TransformComponent>(blastEntity);
var transformSystem = _entityManager.System<SharedTransformSystem>();
return transformComponent.MapID == currentEyeLoc.MapId
&& transformSystem.InRange(transformComponent.Coordinates, transformSystem.ToCoordinates(transformComponent.ParentUid, currentEyeLoc), PvsDist + blast.VisualRange);
}

private sealed record EmpShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration)
{
public MapCoordinates CurrentMapCoords = CurrentMapCoords;
public float Range = Range;
public TimeSpan Start = Start;
public float Duration = Duration;
};
}
}

12 changes: 12 additions & 0 deletions Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public bool InstallProgram(EntityUid loaderUid, string prototype, bool deinstall

RaiseLocalEvent(installedProgram, new CartridgeAddedEvent(loaderUid));
UpdateUserInterfaceState(loaderUid, loader);

if (cartridge.Readonly) // Frontier: Block uninstall
cartridge.InstallationStatus = InstallationStatus.Readonly; // Frontier

if (cartridge.Disposable) // Frontier: Delete the cartridge after install if its disposable.
QueueDel(loader.CartridgeSlot.ContainerSlot!.ContainedEntity); // Frontier

return true;
}

Expand Down Expand Up @@ -343,6 +350,11 @@ protected override void OnItemInserted(EntityUid uid, CartridgeLoaderComponent l
if (TryComp(args.Entity, out CartridgeComponent? cartridge))
cartridge.LoaderUid = uid;

// Frontier: Try to auto install the program when inserted, QOL
if (cartridge != null && cartridge.AutoInstall)
InstallCartridge(uid, args.Entity, loader);
// End Frontier

RaiseLocalEvent(args.Entity, new CartridgeAddedEvent(uid));
base.OnItemInserted(uid, loader, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.GPS;

namespace Content.Server.CartridgeLoader.Cartridges;

[RegisterComponent]
public sealed partial class AstroNavCartridgeComponent : Component
{
}
Loading

0 comments on commit cd18d53

Please sign in to comment.