Skip to content

Commit

Permalink
Merge pull request #524 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Mar 18, 2024
2 parents 5af079f + 78a06c8 commit 4b144d2
Show file tree
Hide file tree
Showing 305 changed files with 9,635 additions and 5,143 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
4 changes: 2 additions & 2 deletions Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public sealed class EntryPoint : GameClient
[Dependency] private readonly IResourceManager _resourceManager = default!;
[Dependency] private readonly IReplayLoadManager _replayLoad = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly ContentReplayPlaybackManager _replayMan = default!;


// start-backmen: ioc
Expand Down Expand Up @@ -109,12 +110,10 @@ public override void Init()
_prototypeManager.RegisterIgnore("seed"); // Seeds prototypes are server-only.
_prototypeManager.RegisterIgnore("objective");
_prototypeManager.RegisterIgnore("holiday");
_prototypeManager.RegisterIgnore("aiFaction");
_prototypeManager.RegisterIgnore("htnCompound");
_prototypeManager.RegisterIgnore("htnPrimitive");
_prototypeManager.RegisterIgnore("gameMap");
_prototypeManager.RegisterIgnore("gameMapPool");
_prototypeManager.RegisterIgnore("npcFaction");
_prototypeManager.RegisterIgnore("lobbyBackground");
_prototypeManager.RegisterIgnore("advertisementsPack");
_prototypeManager.RegisterIgnore("gamePreset");
Expand Down Expand Up @@ -216,6 +215,7 @@ private void SwitchToDefaultState(bool disconnected = false)
_resourceManager,
ReplayConstants.ReplayZipFolder.ToRootedPath());

_replayMan.LastLoad = (null, ReplayConstants.ReplayZipFolder.ToRootedPath());
_replayLoad.LoadAndStartReplay(reader);
}
else if (_gameController.LaunchState.FromLauncher)
Expand Down
25 changes: 16 additions & 9 deletions Content.Client/Overlays/ShowHealthIconsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Atmos.Rotting;
using Content.Shared.Damage;
using Content.Shared.Inventory.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Overlays;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
Expand All @@ -17,9 +19,6 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo

public HashSet<string> DamageContainers = new();

[ValidatePrototypeId<StatusIconPrototype>]
private const string HealthIconFine = "HealthIconFine";

public override void Initialize()
{
base.Initialize();
Expand All @@ -45,18 +44,20 @@ protected override void DeactivateInternal()
DamageContainers.Clear();
}

private void OnGetStatusIconsEvent(EntityUid uid, DamageableComponent damageableComponent, ref GetStatusIconsEvent args)
private void OnGetStatusIconsEvent(Entity<DamageableComponent> entity, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
return;

var healthIcons = DecideHealthIcons(damageableComponent);
var healthIcons = DecideHealthIcons(entity);

args.StatusIcons.AddRange(healthIcons);
}

private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent damageableComponent)
private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(Entity<DamageableComponent> entity)
{
var damageableComponent = entity.Comp;

if (damageableComponent.DamageContainerID == null ||
!DamageContainers.Contains(damageableComponent.DamageContainerID))
{
Expand All @@ -66,10 +67,16 @@ private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent
var result = new List<StatusIconPrototype>();

// Here you could check health status, diseases, mind status, etc. and pick a good icon, or multiple depending on whatever.
if (damageableComponent?.DamageContainerID == "Biological" &&
_prototypeMan.TryIndex<StatusIconPrototype>(HealthIconFine, out var healthyIcon))
if (damageableComponent?.DamageContainerID == "Biological")
{
result.Add(healthyIcon);
if (TryComp<MobStateComponent>(entity, out var state))
{
// Since there is no MobState for a rotting mob, we have to deal with this case first.
if (HasComp<RottingComponent>(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon))
result.Add(rottingIcon);
else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.TryIndex(value, out var icon))
result.Add(icon);
}
}

return result;
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
62 changes: 59 additions & 3 deletions Content.Client/Replay/ContentReplayPlaybackManager.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.IO.Compression;
using Content.Client.Administration.Managers;
using Content.Client.Launcher;
using Content.Client.MainMenu;
using Content.Client.Replay.Spectator;
using Content.Client.Replay.UI.Loading;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Systems.Chat;
using Content.Shared.Chat;
using Content.Shared.Effects;
Expand All @@ -24,7 +26,13 @@
using Robust.Client.State;
using Robust.Client.Timing;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Utility;

namespace Content.Client.Replay;

Expand All @@ -41,6 +49,8 @@ public sealed class ContentReplayPlaybackManager
[Dependency] private readonly IClientAdminManager _adminMan = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IResourceManager _resMan = default!;

/// <summary>
/// UI state to return to when stopping a replay or loading fails.
Expand All @@ -50,6 +60,13 @@ public sealed class ContentReplayPlaybackManager
public bool IsScreenshotMode = false;

private bool _initialized;

/// <summary>
/// Most recently loaded file, for re-attempting the load with error tolerance.
/// Required because the zip reader auto-disposes and I'm too lazy to change it so that
/// <see cref="ReplayFileReaderZip"/> can re-open it.
/// </summary>
public (ResPath? Zip, ResPath Folder)? LastLoad;

public void Initialize()
{
Expand All @@ -73,11 +90,50 @@ private void LoadOverride(IReplayFileReader fileReader)

private void OnFinishedLoading(Exception? exception)
{
if (exception != null)
if (exception == null)
{
LastLoad = null;
return;
}

ReturnToDefaultState();

// Show a popup window with the error message
var text = Loc.GetString("replay-loading-failed", ("reason", exception));
var box = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Vertical,
Children = {new Label {Text = text}}
};

var popup = new DefaultWindow { Title = "Error!" };
popup.Contents.AddChild(box);

// Add button for attempting to re-load the replay while ignoring some errors.
if (!_cfg.GetCVar(CVars.ReplayIgnoreErrors) && LastLoad is {} last)
{
ReturnToDefaultState();
_uiMan.Popup(Loc.GetString("replay-loading-failed", ("reason", exception)));
var button = new Button
{
Text = Loc.GetString("replay-loading-retry"),
StyleClasses = { StyleBase.ButtonCaution }
};

button.OnPressed += _ =>
{
_cfg.SetCVar(CVars.ReplayIgnoreErrors, true);
popup.Dispose();

IReplayFileReader reader = last.Zip == null
? new ReplayFileReaderResources(_resMan, last.Folder)
: new ReplayFileReaderZip(new(_resMan.UserData.OpenRead(last.Zip.Value)), last.Folder);

_loadMan.LoadAndStartReplay(reader);
};

box.AddChild(button);
}

popup.OpenCentered();
}

public void ReturnToDefaultState()
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/StatusIcon/StatusIconOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected override void Draw(in OverlayDrawArgs args)
accOffsetL += texture.Height;
countL++;
}
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) accOffsetL / EyeManager.PixelsPerMeter;
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) (accOffsetL - proto.Offset) / EyeManager.PixelsPerMeter;
xOffset = -(bounds.Width + sprite.Offset.X) / 2f;

}
Expand All @@ -106,7 +106,7 @@ protected override void Draw(in OverlayDrawArgs args)
accOffsetR += texture.Height;
countR++;
}
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) accOffsetR / EyeManager.PixelsPerMeter;
yOffset = (bounds.Height + sprite.Offset.Y) / 2f - (float) (accOffsetR - proto.Offset) / EyeManager.PixelsPerMeter;
xOffset = (bounds.Width + sprite.Offset.X) / 2f - (float) texture.Width / EyeManager.PixelsPerMeter;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,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
15 changes: 9 additions & 6 deletions Content.Replay/Menu/ReplayMainMenu.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO.Compression;
using System.Linq;
using Content.Client.Message;
using Content.Client.Replay;
using Content.Client.UserInterface.Systems.EscapeMenu;
using Robust.Client;
using Robust.Client.Replays.Loading;
Expand Down Expand Up @@ -31,6 +32,7 @@ public sealed class ReplayMainScreen : State
[Dependency] private readonly IGameController _controllerProxy = default!;
[Dependency] private readonly IClientRobustSerializer _serializer = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly ContentReplayPlaybackManager _replayMan = default!;

private ReplayMainMenuControl _mainMenuControl = default!;
private SelectReplayWindow? _selectWindow;
Expand Down Expand Up @@ -207,12 +209,13 @@ private void OnFolderPressed(BaseButton.ButtonEventArgs obj)

private void OnLoadPressed(BaseButton.ButtonEventArgs obj)
{
if (_selected.HasValue)
{
var fileReader = new ReplayFileReaderZip(
new ZipArchive(_resMan.UserData.OpenRead(_selected.Value)), ReplayZipFolder);
_loadMan.LoadAndStartReplay(fileReader);
}
if (!_selected.HasValue)
return;

_replayMan.LastLoad = (_selected.Value, ReplayZipFolder);
var fileReader = new ReplayFileReaderZip(
new ZipArchive(_resMan.UserData.OpenRead(_selected.Value)), ReplayZipFolder);
_loadMan.LoadAndStartReplay(fileReader);
}

private void RefreshReplays()
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 4b144d2

Please sign in to comment.