Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream-sync
Browse files Browse the repository at this point in the history
# Conflicts:
#	Content.Server/Connection/ConnectionManager.cs
#	Resources/ServerInfo/Guidebook/Medical/Cryogenics.xml
  • Loading branch information
Morb0 committed Mar 17, 2024
2 parents 2b92df7 + 7d275a4 commit a751abc
Show file tree
Hide file tree
Showing 214 changed files with 2,656 additions and 1,264 deletions.
5 changes: 3 additions & 2 deletions Content.Client/CardboardBox/CardboardBoxSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Shared.CardboardBox;
using Content.Shared.CardboardBox.Components;
using Content.Shared.Examine;
Expand All @@ -11,6 +11,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -55,7 +56,7 @@ private void OnBoxEffect(PlayBoxEffectMessage msg)
foreach (var mob in mobMoverEntities)
{
var mapPos = _transform.GetMapCoordinates(mob);
if (!ExamineSystemShared.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
if (!_examine.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null))
continue;

var ent = Spawn(box.Effect, mapPos);
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,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
5 changes: 4 additions & 1 deletion Content.Client/Popups/PopupOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public sealed class PopupOverlay : Overlay
private readonly IUserInterfaceManager _uiManager;
private readonly PopupSystem _popup;
private readonly PopupUIController _controller;
private readonly ExamineSystemShared _examine;

private readonly ShaderInstance _shader;

Expand All @@ -33,12 +34,14 @@ public PopupOverlay(
IPrototypeManager protoManager,
IUserInterfaceManager uiManager,
PopupUIController controller,
ExamineSystemShared examine,
PopupSystem popup)
{
_configManager = configManager;
_entManager = entManager;
_playerMgr = playerMgr;
_uiManager = uiManager;
_examine = examine;
_popup = popup;
_controller = controller;

Expand Down Expand Up @@ -81,7 +84,7 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl
var distance = (mapPos.Position - args.WorldBounds.Center).Length();

// Should handle fade here too wyci.
if (!args.WorldBounds.Contains(mapPos.Position) || !ExamineSystemShared.InRangeUnOccluded(viewPos, mapPos, distance,
if (!args.WorldBounds.Contains(mapPos.Position) || !_examine.InRangeUnOccluded(viewPos, mapPos, distance,
e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager))
continue;

Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Content.Shared.Popups;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -26,6 +27,7 @@ public sealed class PopupSystem : SharedPopupSystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

public IReadOnlyList<WorldPopupLabel> WorldLabels => _aliveWorldLabels;
public IReadOnlyList<CursorPopupLabel> CursorLabels => _aliveCursorLabels;
Expand All @@ -51,6 +53,7 @@ public override void Initialize()
_prototype,
_uiManager,
_uiManager.GetUIController<PopupUIController>(),
_examine,
this));
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ private void UpdateQueuedSpeechBubbles(FrameEventArgs delta)

var otherPos = EntityManager.GetComponent<TransformComponent>(ent).MapPosition;

if (occluded && !ExamineSystemShared.InRangeUnOccluded(
if (occluded && !_examine.InRangeUnOccluded(
playerPos,
otherPos, 0f,
(ent, player), predicate))
Expand Down
8 changes: 4 additions & 4 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Content.Client.Verbs
public sealed class VerbSystem : SharedVerbSystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ExamineSystem _examineSystem = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
Expand Down Expand Up @@ -77,7 +77,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
bool Predicate(EntityUid e) => e == player || entitiesUnderMouse.Contains(e);

// first check the general location.
if (!_examineSystem.CanExamine(player.Value, targetPos, Predicate))
if (!_examine.CanExamine(player.Value, targetPos, Predicate))
return false;

TryComp(player.Value, out ExaminerComponent? examiner);
Expand All @@ -86,7 +86,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
entities = new();
foreach (var ent in _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize))
{
if (_examineSystem.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
entities.Add(ent);
}
}
Expand Down Expand Up @@ -147,7 +147,7 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
{
var entity = entities[i];

if (!ExamineSystemShared.InRangeUnOccluded(
if (!_examine.InRangeUnOccluded(
playerPos,
xformQuery.GetComponent(entity).MapPosition,
ExamineSystemShared.ExamineRange,
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
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
3 changes: 2 additions & 1 deletion Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StationSystem _stations = default!;
[Dependency] private readonly StationSpawningSystem _spawning = default!;
[Dependency] private readonly ExamineSystemShared _examine = default!;

private readonly Dictionary<ICommonSession, List<EditSolutionsEui>> _openSolutionUis = new();

Expand Down Expand Up @@ -416,7 +417,7 @@ private void AddDebugVerbs(GetVerbsEvent<Verb> args)
Act = () =>
{

var message = ExamineSystemShared.InRangeUnOccluded(args.User, args.Target)
var message = _examine.InRangeUnOccluded(args.User, args.Target)
? Loc.GetString("in-range-unoccluded-verb-on-activate-not-occluded")
: Loc.GetString("in-range-unoccluded-verb-on-activate-occluded");

Expand Down
Loading

0 comments on commit a751abc

Please sign in to comment.