Skip to content

Commit

Permalink
Merge pull request #362 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Dec 1, 2023
2 parents e97faac + 0231d8a commit f606e39
Show file tree
Hide file tree
Showing 105 changed files with 547,710 additions and 533,004 deletions.
6 changes: 5 additions & 1 deletion Content.Client/Research/UI/MiniTechnologyCardControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Research.Prototypes;
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
Expand All @@ -12,6 +12,9 @@ namespace Content.Client.Research.UI;
[GenerateTypedNameReferences]
public sealed partial class MiniTechnologyCardControl : Control
{
/// The technology that this control represents
public readonly TechnologyPrototype Technology;

public MiniTechnologyCardControl(TechnologyPrototype technology, IPrototypeManager prototypeManager, SpriteSystem spriteSys, FormattedMessage description)
{
RobustXamlLoader.Load(this);
Expand All @@ -24,5 +27,6 @@ public MiniTechnologyCardControl(TechnologyPrototype technology, IPrototypeManag
var tooltip = new Tooltip();
tooltip.SetMessage(description);
Main.TooltipSupplier = _ => tooltip;
Technology = technology;
}
}
60 changes: 46 additions & 14 deletions Content.Client/Research/UI/ResearchConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Access.Components;
Expand Down Expand Up @@ -48,16 +49,10 @@ public ResearchConsoleMenu(EntityUid entity)

public void UpdatePanels(ResearchConsoleBoundInterfaceState state)
{
var allTech = _research.GetAvailableTechnologies(Entity);
AvailableCardsContainer.Children.Clear();
TechnologyCardsContainer.Children.Clear();
UnlockedCardsContainer.Children.Clear();

foreach (var tech in allTech)
{
var mini = new MiniTechnologyCardControl(tech, _prototype, _sprite, _research.GetTechnologyDescription(tech));
AvailableCardsContainer.AddChild(mini);
}
var availableTech = _research.GetAvailableTechnologies(Entity);
SyncTechnologyList(AvailableCardsContainer, availableTech);

if (_technologyDatabase == null)
return;
Expand All @@ -79,12 +74,8 @@ public void UpdatePanels(ResearchConsoleBoundInterfaceState state)
TechnologyCardsContainer.AddChild(cardControl);
}

foreach (var unlocked in _technologyDatabase.UnlockedTechnologies)
{
var tech = _prototype.Index<TechnologyPrototype>(unlocked);
var cardControl = new MiniTechnologyCardControl(tech, _prototype, _sprite, _research.GetTechnologyDescription(tech, false));
UnlockedCardsContainer.AddChild(cardControl);
}
var unlockedTech = _technologyDatabase.UnlockedTechnologies.Select(x => _prototype.Index<TechnologyPrototype>(x));
SyncTechnologyList(UnlockedCardsContainer, unlockedTech);
}

public void UpdateInformationPanel(ResearchConsoleBoundInterfaceState state)
Expand Down Expand Up @@ -146,5 +137,46 @@ public void UpdateInformationPanel(ResearchConsoleBoundInterfaceState state)
TierDisplayContainer.AddChild(control);
}
}

/// <summary>
/// Synchronize a container for technology cards with a list of technologies,
/// creating or removing UI cards as appropriate.
/// </summary>
/// <param name="container">The container which contains the UI cards</param>
/// <param name="technologies">The current set of technologies for which there should be cards</param>
private void SyncTechnologyList(BoxContainer container, IEnumerable<TechnologyPrototype> technologies)
{
// For the cards which already exist, build a map from technology prototype to the UI card
var currentTechControls = new Dictionary<TechnologyPrototype, Control>();
foreach (var child in container.Children)
{
if (child is MiniTechnologyCardControl)
{
currentTechControls.Add((child as MiniTechnologyCardControl)!.Technology, child);
}
}

foreach (var tech in technologies)
{
if (!currentTechControls.ContainsKey(tech))
{
// Create a card for any technology which doesn't already have one.
var mini = new MiniTechnologyCardControl(tech, _prototype, _sprite, _research.GetTechnologyDescription(tech));
container.AddChild(mini);
}
else
{
// The tech already exists in the UI; remove it from the set, so we won't revisit it below
currentTechControls.Remove(tech);
}
}

// Now, any items left in the dictionary are technologies which were previously
// available, but now are not. Remove them.
foreach (var (tech, techControl) in currentTechControls)
{
container.Children.Remove(techControl);
}
}
}

1 change: 0 additions & 1 deletion Content.IntegrationTests/PoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public static partial class PoolManager
options.BeforeStart += () =>
{
var entSysMan = IoCManager.Resolve<IEntitySystemManager>();
var compFactory = IoCManager.Resolve<IComponentFactory>();
entSysMan.LoadExtraSystemType<ResettingEntitySystemTests.TestRoundRestartCleanupEvent>();
entSysMan.LoadExtraSystemType<InteractionSystemTests.TestInteractionSystem>();
entSysMan.LoadExtraSystemType<DeviceNetworkTestSystem>();
Expand Down
24 changes: 19 additions & 5 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public async Task SpawnAndDeleteEntityCountTest()
{
var settings = new PoolSettings { Connected = true, Dirty = true };
await using var pair = await PoolManager.GetServerClient(settings);
var mapManager = pair.Server.ResolveDependency<IMapManager>();
var server = pair.Server;
var client = pair.Client;

Expand Down Expand Up @@ -251,8 +252,15 @@ public async Task SpawnAndDeleteEntityCountTest()
.Select(p => p.ID)
.ToList();

var mapId = await pair.CreateTestMap();
var coords = mapId.MapCoords;
protoIds.Sort();
var mapId = MapId.Nullspace;

await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
});

var coords = new MapCoordinates(Vector2.Zero, mapId);

await pair.RunTicksSync(3);

Expand Down Expand Up @@ -284,7 +292,9 @@ public async Task SpawnAndDeleteEntityCountTest()

if (client.EntMan.EntityCount != clientCount)
{
Assert.Fail($"Client prototype {protoId} failed on deleting itself");
Assert.Fail($"Client prototype {protoId} failed on deleting itself\n" +
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
$"Server was {count}.");
}
continue;
}
Expand All @@ -297,7 +307,9 @@ public async Task SpawnAndDeleteEntityCountTest()

if (client.EntMan.EntityCount <= clientCount)
{
Assert.Fail($"Client prototype {protoId} failed on spawning as entity count didn't increase");
Assert.Fail($"Client prototype {protoId} failed on spawning as entity count didn't increase" +
$"Expected at least {clientCount} and found {client.EntMan.EntityCount}. " +
$"Server was {count}");
}

await server.WaitPost(() => server.EntMan.DeleteEntity(uid));
Expand All @@ -311,7 +323,9 @@ public async Task SpawnAndDeleteEntityCountTest()

if (client.EntMan.EntityCount != clientCount)
{
Assert.Fail($"Client prototype {protoId} failed on deletion count didn't reset properly");
Assert.Fail($"Client prototype {protoId} failed on deletion count didn't reset properly:\n" +
$"Expected {clientCount} and found {client.EntMan.EntityCount}.\n" +
$"Server was {count}.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public abstract partial class InteractionTest
[SetUp]
public virtual async Task Setup()
{
Pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true });
Pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, Dirty = true});

// server dependencies
SEntMan = Server.ResolveDependency<IEntityManager>();
Expand Down
46 changes: 46 additions & 0 deletions Content.Server/Administration/Commands/PlayGlobalSoundCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.IO;
using System.Linq;
using Content.Server.Audio;
using Content.Shared.Administration;
using Robust.Server.Audio;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Console;
Expand All @@ -10,6 +12,50 @@

namespace Content.Server.Administration.Commands;

// This is for debugging nothing more.
[AdminCommand(AdminFlags.Debug)]
public sealed class PlayGlobalAudioCommand : IConsoleCommand
{
public string Command => "playaudio";
public string Description => "Plays audio globally for debugging";
public string Help => $"{Command}";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entManager = IoCManager.Resolve<IEntityManager>();
var protoManager = IoCManager.Resolve<IPrototypeManager>();
var resourceManager = IoCManager.Resolve<IResourceManager>();
var audioSystem = entManager.System<AudioSystem>();
var fileName = args[0];

shell.WriteLine($"Checking {fileName} global audio");

var audioLength = audioSystem.GetAudioLength(fileName);

shell.WriteLine($"Cached audio length is: {audioLength}");

// Copied code to get the actual length determination
// Check shipped metadata from packaging.
if (protoManager.TryIndex(fileName, out AudioMetadataPrototype? metadata))
{
shell.WriteLine($"Used prototype, length is: {metadata.Length}");
}
else if (!resourceManager.TryContentFileRead(fileName, out var stream))
{
throw new FileNotFoundException($"Unable to find metadata for audio file {fileName}");
}
else
{
shell.WriteLine("Looks like audio stream used and cached.");
}

var broadcastFilter = Filter.Broadcast();

shell.WriteLine($"Playing filter to {broadcastFilter.Count} players");

audioSystem.PlayGlobal(fileName, broadcastFilter, true);
}
}

[AdminCommand(AdminFlags.Fun)]
public sealed class PlayGlobalSoundCommand : IConsoleCommand
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public sealed partial class AdminVerbSystem
[Dependency] private readonly PiratesRuleSystem _piratesRule = default!;
[Dependency] private readonly RevolutionaryRuleSystem _revolutionaryRule = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;

// All antag verbs have names so invokeverb works.
private void AddAntagVerbs(GetVerbsEvent<Verb> args)
Expand Down
55 changes: 55 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using Content.Server.Disposal.Tube;
using Content.Server.Disposal.Tube.Components;
using Content.Server.EUI;
using Content.Server.GameTicking;
using Content.Server.Ghost.Roles;
using Content.Server.Mind;
using Content.Server.Mind.Commands;
using Content.Server.Prayer;
using Content.Server.Station.Systems;
using Content.Server.Xenoarchaeology.XenoArtifacts;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Content.Shared.Administration;
Expand Down Expand Up @@ -50,6 +52,7 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly AdminSystem _adminSystem = default!;
[Dependency] private readonly DisposalTubeSystem _disposalTubes = default!;
[Dependency] private readonly EuiManager _euiManager = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly GhostRoleSystem _ghostRoleSystem = default!;
[Dependency] private readonly ArtifactSystem _artifactSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
Expand All @@ -59,6 +62,8 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly ToolshedManager _toolshed = default!;
[Dependency] private readonly RejuvenateSystem _rejuvenate = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StationSystem _stations = default!;
[Dependency] private readonly StationSpawningSystem _spawning = default!;

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

Expand Down Expand Up @@ -169,6 +174,56 @@ private void AddAdminVerbs(GetVerbsEvent<Verb> args)
ConfirmationPopup = true,
// No logimpact as the command does it internally.
});

// Spawn - Like respawn but on the spot.
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("admin-player-actions-spawn"),
Category = VerbCategory.Admin,
Act = () =>
{
if (!_transformSystem.TryGetMapOrGridCoordinates(args.Target, out var coords))
{
_popup.PopupEntity(Loc.GetString("admin-player-spawn-failed"), args.User, args.User);
return;
}

var stationUid = _stations.GetOwningStation(args.Target);

var profile = _ticker.GetPlayerProfile(targetActor.PlayerSession);
var mobUid = _spawning.SpawnPlayerMob(coords.Value, null, profile, stationUid);
var targetMind = _mindSystem.GetMind(args.Target);

if (targetMind != null)
{
_mindSystem.TransferTo(targetMind.Value, mobUid);
}
},
ConfirmationPopup = true,
Impact = LogImpact.High,
});

// Clone - Spawn but without the mind transfer, also spawns at the user's coordinates not the target's
args.Verbs.Add(new Verb()
{
Text = Loc.GetString("admin-player-actions-clone"),
Category = VerbCategory.Admin,
Act = () =>
{
if (!_transformSystem.TryGetMapOrGridCoordinates(args.User, out var coords))
{
_popup.PopupEntity(Loc.GetString("admin-player-spawn-failed"), args.User, args.User);
return;
}

var stationUid = _stations.GetOwningStation(args.Target);

var profile = _ticker.GetPlayerProfile(targetActor.PlayerSession);
_spawning.SpawnPlayerMob(coords.Value, null, profile, stationUid);
},
ConfirmationPopup = true,
Impact = LogImpact.High,
});
}

// Admin Logs
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/GameTicking/GameTicker.Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async void AddPlayerToDb(Guid id)
}
}

private HumanoidCharacterProfile GetPlayerProfile(ICommonSession p)
public HumanoidCharacterProfile GetPlayerProfile(ICommonSession p)
{
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(p.UserId).SelectedCharacter;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Access.Components;
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory;
using Content.Shared.Inventory.Events;
using Content.Shared.Item;
Expand Down Expand Up @@ -45,10 +46,13 @@ protected void UpdateVisuals(EntityUid uid, ChameleonClothingComponent component
// world sprite icon
UpdateSprite(uid, proto);

// copy name and description
var meta = MetaData(uid);
_metaData.SetEntityName(uid, proto.Name, meta);
_metaData.SetEntityDescription(uid, proto.Description, meta);
// copy name and description, unless its an ID card
if (!HasComp<IdCardComponent>(uid))
{
var meta = MetaData(uid);
_metaData.SetEntityName(uid, proto.Name, meta);
_metaData.SetEntityDescription(uid, proto.Description, meta);
}

// item sprite logic
if (TryComp(uid, out ItemComponent? item) &&
Expand Down
Loading

0 comments on commit f606e39

Please sign in to comment.