Skip to content

Commit

Permalink
Merge branch 'master' into bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup authored Mar 17, 2024
2 parents c51be64 + 8beb38c commit cc4308b
Show file tree
Hide file tree
Showing 199 changed files with 19,315 additions and 283,020 deletions.
3 changes: 3 additions & 0 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot
// note that every insertion requires reshuffling & remapping all the existing layers.
sprite.AddBlankLayer(index);
sprite.LayerMapSet(key, index);

if (layerData.Color != null)
sprite.LayerSetColor(key, layerData.Color.Value);
}
else
index = sprite.LayerMapReserveBlank(key);
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Launcher/LauncherConnecting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private set
public event Action<Page>? PageChanged;
public event Action<string?>? ConnectFailReasonChanged;
public event Action<ClientConnectionState>? ConnectionStateChanged;
public event Action<NetConnectFailArgs>? ConnectFailed;

protected override void Startup()
{
Expand Down Expand Up @@ -85,6 +86,7 @@ private void OnConnectFailed(object? _, NetConnectFailArgs args)
}
ConnectFailReason = args.Reason;
CurrentPage = Page.ConnectFailed;
ConnectFailed?.Invoke(args);
}

private void OnConnectStateChanged(ClientConnectionState state)
Expand Down
4 changes: 0 additions & 4 deletions Content.Client/Launcher/LauncherConnectingGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
<Button Name="ReconnectButton" Text="{Loc 'connecting-reconnect'}"
HorizontalAlignment="Center"
VerticalExpand="True" VerticalAlignment="Bottom" />
<Button Name="RedialButton" Text="{Loc 'connecting-redial'}"
Disabled="True"
HorizontalAlignment="Center"
VerticalExpand="True" VerticalAlignment="Bottom" />
</BoxContainer>
</Control>
<Label Name="ConnectingAddress" StyleClasses="LabelSubText" HorizontalAlignment="Center" />
Expand Down
82 changes: 62 additions & 20 deletions Content.Client/Launcher/LauncherConnectingGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Robust.Shared.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
using Robust.Shared.Localization;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -21,12 +20,15 @@ public sealed partial class LauncherConnectingGui : Control
{
private const float RedialWaitTimeSeconds = 15f;
private readonly LauncherConnecting _state;
private float _waitTime;

// Pressing reconnect will redial instead of simply reconnecting.
private bool _redial;

private readonly IRobustRandom _random;
private readonly IPrototypeManager _prototype;
private readonly IConfigurationManager _cfg;

private float _redialWaitTime = RedialWaitTimeSeconds;

public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
IPrototypeManager prototype, IConfigurationManager config)
{
Expand All @@ -42,14 +44,8 @@ public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;

ChangeLoginTip();
ReconnectButton.OnPressed += _ => _state.RetryConnect();
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
RedialButton.OnPressed += _ =>
{
if (!_state.Redial())
_state.RetryConnect();
};
RetryButton.OnPressed += _ => _state.RetryConnect();
ReconnectButton.OnPressed += ReconnectButtonPressed;
RetryButton.OnPressed += ReconnectButtonPressed;
ExitButton.OnPressed += _ => _state.Exit();

var addr = state.Address;
Expand All @@ -59,6 +55,7 @@ public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
state.PageChanged += OnPageChanged;
state.ConnectFailReasonChanged += ConnectFailReasonChanged;
state.ConnectionStateChanged += ConnectionStateChanged;
state.ConnectFailed += HandleDisconnectReason;

ConnectionStateChanged(state.ConnectionState);

Expand All @@ -68,6 +65,19 @@ public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs);
}

// Just button, there's only one at once anyways :)
private void ReconnectButtonPressed(BaseButton.ButtonEventArgs args)
{
if (_redial)
{
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
if (_state.Redial())
return;
}

_state.RetryConnect();
}

private void ConnectFailReasonChanged(string? reason)
{
ConnectFailReason.SetMessage(reason == null
Expand All @@ -77,9 +87,30 @@ private void ConnectFailReasonChanged(string? reason)

private void LastNetDisconnectedArgsChanged(NetDisconnectedArgs? args)
{
var redialFlag = args?.RedialFlag ?? false;
RedialButton.Visible = redialFlag;
ReconnectButton.Visible = !redialFlag;
HandleDisconnectReason(args);
}

private void HandleDisconnectReason(INetStructuredReason? reason)
{
if (reason == null)
{
_waitTime = 0;
_redial = false;
}
else
{
_redial = reason.RedialFlag;

if (reason.Message.Int32Of("delay") is { } delay)
{
_waitTime = delay;
}
else if (_redial)
{
_waitTime = RedialWaitTimeSeconds;
}

}
}

private void ChangeLoginTip()
Expand Down Expand Up @@ -108,16 +139,27 @@ private void ChangeLoginTip()
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
_redialWaitTime -= args.DeltaSeconds;
if (_redialWaitTime <= 0)

var button = _state.CurrentPage == LauncherConnecting.Page.ConnectFailed
? RetryButton
: ReconnectButton;

_waitTime -= args.DeltaSeconds;
if (_waitTime <= 0)
{
RedialButton.Disabled = false;
RedialButton.Text = Loc.GetString("connecting-redial");
button.Disabled = false;
var key = _redial
? "connecting-redial"
: _state.CurrentPage == LauncherConnecting.Page.ConnectFailed
? "connecting-reconnect"
: "connecting-retry";

button.Text = Loc.GetString(key);
}
else
{
RedialButton.Disabled = true;
RedialButton.Text = Loc.GetString("connecting-redial-wait", ("time", _redialWaitTime.ToString("00.000")));
button.Disabled = true;
button.Text = Loc.GetString("connecting-redial-wait", ("time", _waitTime.ToString("00.000")));
}
}

Expand Down
27 changes: 24 additions & 3 deletions Content.Client/Sprite/RandomSpriteSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Content.Client.Clothing;
using Content.Shared.Clothing.Components;
using Content.Shared.Sprite;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;
Expand All @@ -8,6 +10,7 @@ namespace Content.Client.Sprite;
public sealed class RandomSpriteSystem : SharedRandomSpriteSystem
{
[Dependency] private readonly IReflectionManager _reflection = default!;
[Dependency] private readonly ClientClothingSystem _clothing = default!;

public override void Initialize()
{
Expand All @@ -31,10 +34,29 @@ private void OnHandleState(EntityUid uid, RandomSpriteComponent component, ref C
component.Selected.Add(layer.Key, layer.Value);
}

UpdateAppearance(uid, component);
UpdateSpriteComponentAppearance(uid, component);
UpdateClothingComponentAppearance(uid, component);
}

private void UpdateAppearance(EntityUid uid, RandomSpriteComponent component, SpriteComponent? sprite = null)
private void UpdateClothingComponentAppearance(EntityUid uid, RandomSpriteComponent component, ClothingComponent? clothing = null)
{
if (!Resolve(uid, ref clothing, false))
return;

if (clothing.ClothingVisuals == null)
return;

foreach (var slotPair in clothing.ClothingVisuals)
{
foreach (var keyColorPair in component.Selected)
{
_clothing.SetLayerColor(clothing, slotPair.Key, keyColorPair.Key, keyColorPair.Value.Color);
_clothing.SetLayerState(clothing, slotPair.Key, keyColorPair.Key, keyColorPair.Value.State);
}
}
}

private void UpdateSpriteComponentAppearance(EntityUid uid, RandomSpriteComponent component, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref sprite, false))
return;
Expand All @@ -55,7 +77,6 @@ private void UpdateAppearance(EntityUid uid, RandomSpriteComponent component, Sp
continue;
}
}

sprite.LayerSetState(index, layer.Value.State);
sprite.LayerSetColor(index, layer.Value.Color ?? Color.White);
}
Expand Down
2 changes: 1 addition & 1 deletion Content.IntegrationTests/Tests/Buckle/BuckleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ await server.WaitAssertion(() =>
Assert.That(buckle.Buckled);

Assert.That(actionBlocker.CanMove(human), Is.False);
Assert.That(actionBlocker.CanChangeDirection(human), Is.False);
Assert.That(actionBlocker.CanChangeDirection(human));
Assert.That(standingState.Down(human), Is.False);
Assert.That(
(xformSystem.GetWorldPosition(human) - xformSystem.GetWorldPosition(chair)).LengthSquared,
Expand Down
3 changes: 1 addition & 2 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public sealed class PostMapInitTest
// Corvax-Start
"CorvaxAvrite",
"CorvaxDelta",
"CorvaxSpectrum",
//"CorvaxGate",
"CorvaxGate",
"CorvaxSilly",
"CorvaxOutpost",
"CorvaxAstra",
Expand Down
6 changes: 4 additions & 2 deletions Content.Server/Access/Systems/PresetIdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ private void OnMapInit(EntityUid uid, PresetIdCardComponent id, MapInitEvent arg

var station = _stationSystem.GetOwningStation(uid);
var extended = false;
if (station != null)
extended = Comp<StationJobsComponent>(station.Value).ExtendedAccess;

// Station not guaranteed to have jobs (e.g. nukie outpost).
if (TryComp(station, out StationJobsComponent? stationJobs))
extended = stationJobs.ExtendedAccess;

SetupIdAccess(uid, id, extended);
SetupIdName(uid, id);
Expand Down
9 changes: 8 additions & 1 deletion Content.Server/Backmen/JoinQueue/JoinQueueManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;
using Content.Server.Connection;
using Content.Server.GameTicking;
using Content.Shared.Backmen.JoinQueue;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Prometheus;
using Robust.Server.Player;
using Robust.Shared.Configuration;
Expand Down Expand Up @@ -88,7 +90,12 @@ private async void OnPlayerVerified(object? sender, ICommonSession session)
var isPrivileged = await _connectionManager.HavePrivilegedJoin(session.UserId);
var currentOnline = _playerManager.PlayerCount - 1; // Do not count current session in general online, because we are still deciding her fate
var haveFreeSlot = currentOnline < _cfg.GetCVar(CCVars.SoftMaxPlayers);
if (isPrivileged || haveFreeSlot)

var wasInGame = _entityManager.TrySystem<GameTicker>(out var ticker) &&
ticker.PlayerGameStatuses.TryGetValue(session.UserId, out var status) &&
status == PlayerGameStatus.JoinedGame;

if (isPrivileged || haveFreeSlot || wasInGame)
{
SendToGame(session);

Expand Down
21 changes: 20 additions & 1 deletion Content.Server/Cargo/Components/CargoPalletComponent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
namespace Content.Server.Cargo.Components;
using Content.Shared.Actions;
using Robust.Shared.Serialization.TypeSerializers.Implementations;

/// <summary>
/// Any entities intersecting when a shuttle is recalled will be sold.
/// </summary>

[Flags]
public enum BuySellType : byte
{
Buy = 1 << 0,
Sell = 1 << 1,
All = Buy | Sell
}


[RegisterComponent]
public sealed partial class CargoPalletComponent : Component {}
public sealed partial class CargoPalletComponent : Component
{
/// <summary>
/// Whether the pad is a buy pad, a sell pad, or all.
/// </summary>
[DataField]
public BuySellType PalletType;
}
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com
// Try to fulfill from any station where possible, if the pad is not occupied.
foreach (var trade in _listEnts)
{
var tradePads = GetCargoPallets(trade);
var tradePads = GetCargoPallets(trade, BuySellType.Buy);
_random.Shuffle(tradePads);

var freePads = GetFreeCargoPallets(trade, tradePads);
Expand Down
15 changes: 12 additions & 3 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,16 @@ private List<CargoOrderData> GetProjectedOrders(
/// </summary>
private int GetCargoSpace(EntityUid gridUid)
{
var space = GetCargoPallets(gridUid).Count;
var space = GetCargoPallets(gridUid, BuySellType.Buy).Count;
return space;
}

private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid gridUid)
/// GetCargoPallets(gridUid, BuySellType.Sell) to return only Sell pads
/// GetCargoPallets(gridUid, BuySellType.Buy) to return only Buy pads
private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid gridUid, BuySellType requestType = BuySellType.All)
{
_pads.Clear();

var query = AllEntityQuery<CargoPalletComponent, TransformComponent>();

while (query.MoveNext(out var uid, out var comp, out var compXform))
Expand All @@ -190,7 +193,13 @@ private int GetCargoSpace(EntityUid gridUid)
continue;
}

if ((requestType & comp.PalletType) == 0)
{
continue;
}

_pads.Add((uid, comp, compXform));

}

return _pads;
Expand Down Expand Up @@ -250,7 +259,7 @@ private void GetPalletGoods(EntityUid gridUid, out HashSet<EntityUid> toSell, ou
amount = 0;
toSell = new HashSet<EntityUid>();

foreach (var (palletUid, _, _) in GetCargoPallets(gridUid))
foreach (var (palletUid, _, _) in GetCargoPallets(gridUid, BuySellType.Sell))
{
// Containers should already get the sell price of their children so can skip those.
_setEnts.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,4 @@ public sealed partial class SolutionInjectOnCollideComponent : Component
/// </summary>
[DataField("blockSlots"), ViewVariables(VVAccess.ReadWrite)]
public SlotFlags BlockSlots = SlotFlags.MASK;

[DataField]
public string FixtureId = SharedProjectileSystem.ProjectileFixture;
}
Loading

0 comments on commit cc4308b

Please sign in to comment.