Skip to content

Commit

Permalink
Merge remote-tracking branch 'wizard/master' into upstream-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Mar 2, 2024
2 parents a4debfc + 7f060eb commit f97454a
Show file tree
Hide file tree
Showing 185 changed files with 24,764 additions and 21,544 deletions.
3 changes: 1 addition & 2 deletions Content.Client/Ame/UI/AmeControllerBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.Ame.UI
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Ame/UI/AmeWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Client.UserInterface;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Cargo/UI/CargoConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void PopulateProducts()
// else if category and not search
if (search.Length == 0 && _category == null ||
search.Length != 0 && prototype.Name.ToLowerInvariant().Contains(search) ||
search.Length != 0 && prototype.Description.ToLowerInvariant().Contains(search) ||
search.Length == 0 && _category != null && prototype.Category.Equals(_category))
{
var button = new CargoProductRow
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using Content.Client.Stylesheets;
using Content.Client.Viewport;
using Content.Client.Voting;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Content.Shared.Gravity;
using Content.Shared.Localizations;
using Robust.Client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ private void SyncUpdateControls(AlertsSystem alertsSystem, AlertOrderPrototype?
{
// key is the same, simply update the existing control severity / cooldown
existingAlertControl.SetSeverity(alertState.Severity);
existingAlertControl.Cooldown = alertState.Cooldown;
if (alertState.ShowCooldown)
existingAlertControl.Cooldown = alertState.Cooldown;
}
else
{
Expand Down Expand Up @@ -133,9 +134,13 @@ private void SyncUpdateControls(AlertsSystem alertsSystem, AlertOrderPrototype?

private AlertControl CreateAlertControl(AlertPrototype alert, AlertState alertState)
{
(TimeSpan, TimeSpan)? cooldown = null;
if (alertState.ShowCooldown)
cooldown = alertState.Cooldown;

var alertControl = new AlertControl(alert, alertState.Severity)
{
Cooldown = alertState.Cooldown
Cooldown = cooldown
};
alertControl.OnPressed += AlertControlPressed;
return alertControl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.UnitTesting;

namespace Content.IntegrationTests.Tests.Preferences
Expand Down Expand Up @@ -125,6 +124,17 @@ public async Task TestDeleteCharacter()
await pair.CleanReturnAsync();
}

[Test]
public async Task TestNoPendingDatabaseChanges()
{
var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var db = GetDb(server);
Assert.That(async () => await db.HasPendingModelChanges(), Is.False,
"The database has pending model changes. Add a new migration to apply them. See https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations");
await pair.CleanReturnAsync();
}

private static NetUserId NewUserId()
{
return new(Guid.NewGuid());
Expand Down
16 changes: 6 additions & 10 deletions Content.Server/Ame/Components/AmeControllerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Content.Server.Ame.EntitySystems;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Server.Ame.Components;
Expand All @@ -15,15 +15,11 @@ namespace Content.Server.Ame.Components;
public sealed partial class AmeControllerComponent : SharedAmeControllerComponent
{
/// <summary>
/// The id of the container used to store the current fuel container for the AME.
/// Antimatter fuel slot.
/// </summary>
public const string FuelContainerId = "AmeFuel";

/// <summary>
/// The container for the fuel canisters used by the AME.
/// </summary>
[ViewVariables]
public ContainerSlot JarSlot = default!;
[DataField("fuelSlot")]
[ViewVariables(VVAccess.ReadWrite)]
public ItemSlot FuelSlot = new();

/// <summary>
/// Whether or not the AME controller is currently injecting animatter into the reactor.
Expand Down
23 changes: 0 additions & 23 deletions Content.Server/Ame/Components/AmeFuelContainerComponent.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Content.Server/Ame/Components/AmeShieldComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.Ame.EntitySystems;
using Content.Shared.Ame;
using Content.Server.Ame.EntitySystems;
using Content.Shared.Ame.Components;

namespace Content.Server.Ame.Components;

Expand Down
119 changes: 62 additions & 57 deletions Content.Server/Ame/EntitySystems/AmeControllerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
using Content.Server.Chat.Managers;
using Content.Server.NodeContainer;
using Content.Server.Power.Components;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Mind.Components;
using Content.Shared.Popups;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
Expand All @@ -30,22 +26,29 @@ public sealed class AmeControllerSystem : EntitySystem
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AmeControllerComponent, ComponentStartup>(OnComponentStartup);
SubscribeLocalEvent<AmeControllerComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<AmeControllerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<AmeControllerComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<AmeControllerComponent, EntInsertedIntoContainerMessage>(OnItemSlotChanged);
SubscribeLocalEvent<AmeControllerComponent, EntRemovedFromContainerMessage>(OnItemSlotChanged);
SubscribeLocalEvent<AmeControllerComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<AmeControllerComponent, UiButtonPressedMessage>(OnUiButtonPressed);
}

private void OnInit(EntityUid uid, AmeControllerComponent component, ComponentInit args)
{
_itemSlots.AddItemSlot(uid, SharedAmeControllerComponent.FuelSlotId, component.FuelSlot);

UpdateUi(uid, component);
}

public override void Update(float frameTime)
{
var curTime = _gameTiming.CurTime;
Expand All @@ -59,6 +62,22 @@ public override void Update(float frameTime)
}
}

private void OnRemove(EntityUid uid, AmeControllerComponent component, ComponentRemove args)
{
_itemSlots.RemoveItemSlot(uid, component.FuelSlot);
}

private void OnItemSlotChanged(EntityUid uid, AmeControllerComponent component, ContainerModifiedMessage args)
{
if (!component.Initialized)
return;

if (args.Container.ID != component.FuelSlot.ID)
return;

UpdateUi(uid, component);
}

private void UpdateController(EntityUid uid, TimeSpan curTime, AmeControllerComponent? controller = null, NodeContainerComponent? nodes = null)
{
if (!Resolve(uid, ref controller))
Expand All @@ -71,23 +90,24 @@ private void UpdateController(EntityUid uid, TimeSpan curTime, AmeControllerComp

if (!controller.Injecting)
return;

if (!TryGetAMENodeGroup(uid, out var group, nodes))
return;

if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar))
if (TryComp<AmeFuelContainerComponent>(controller.FuelSlot.Item, out var fuelContainer))
{
// if the jar is empty shut down the AME
if (fuelJar.FuelAmount <= 0)
if (fuelContainer.FuelAmount <= 0)
{
SetInjecting(uid, false, null, controller);
}
else
{
var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount);
var availableInject = Math.Min(controller.InjectionAmount, fuelContainer.FuelAmount);
var powerOutput = group.InjectFuel(availableInject, out var overloading);
if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet))
powerOutlet.MaxSupply = powerOutput;
fuelJar.FuelAmount -= availableInject;
fuelContainer.FuelAmount -= availableInject;
// only play audio if we actually had an injection
if (availableInject > 0)
_audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
Expand Down Expand Up @@ -138,11 +158,28 @@ private AmeControllerBoundUserInterfaceState GetUiState(EntityUid uid, AmeContro
currentPowerSupply = powerOutlet.CurrentSupply / 1000;
}

var hasJar = Exists(controller.JarSlot.ContainedEntity);
if (!hasJar || !TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var jar))
return new AmeControllerBoundUserInterfaceState(powered, IsMasterController(uid), false, hasJar, 0, controller.InjectionAmount, coreCount, currentPowerSupply, targetedPowerSupply);

return new AmeControllerBoundUserInterfaceState(powered, IsMasterController(uid), controller.Injecting, hasJar, jar.FuelAmount, controller.InjectionAmount, coreCount, currentPowerSupply, targetedPowerSupply);
var fuelContainerInSlot = controller.FuelSlot.Item;
var hasFuelContainerInSlot = Exists(fuelContainerInSlot);
if (!hasFuelContainerInSlot || !TryComp<AmeFuelContainerComponent>(fuelContainerInSlot, out var fuelContainer))
return new AmeControllerBoundUserInterfaceState(powered,
IsMasterController(uid),
false,
hasFuelContainerInSlot,
0,
controller.InjectionAmount,
coreCount,
currentPowerSupply,
targetedPowerSupply);

return new AmeControllerBoundUserInterfaceState(powered,
IsMasterController(uid),
controller.Injecting,
hasFuelContainerInSlot,
fuelContainer.FuelAmount,
controller.InjectionAmount,
coreCount,
currentPowerSupply,
targetedPowerSupply);
}

private bool IsMasterController(EntityUid uid)
Expand Down Expand Up @@ -170,23 +207,23 @@ public void TryEject(EntityUid uid, EntityUid? user = null, AmeControllerCompone
{
if (!Resolve(uid, ref controller))
return;

if (controller.Injecting)
return;

var jar = controller.JarSlot.ContainedEntity;
if (!Exists(jar))
if (!Exists(controller.FuelSlot.Item))
return;

_containerSystem.Remove(jar!.Value, controller.JarSlot);
_itemSlots.TryEjectToHands(uid, controller.FuelSlot, user);

UpdateUi(uid, controller);
if (Exists(user))
_handsSystem.PickupOrDrop(user, jar!.Value);
}

public void SetInjecting(EntityUid uid, bool value, EntityUid? user = null, AmeControllerComponent? controller = null)
{
if (!Resolve(uid, ref controller))
return;

if (controller.Injecting == value)
return;

Expand Down Expand Up @@ -278,38 +315,6 @@ private void UpdateDisplay(EntityUid uid, int stability, AmeControllerComponent?
);
}

private void OnComponentStartup(EntityUid uid, AmeControllerComponent comp, ComponentStartup args)
{
// TODO: Fix this bad name. I'd update maps but then people get mad.
comp.JarSlot = _containerSystem.EnsureContainer<ContainerSlot>(uid, AmeControllerComponent.FuelContainerId);
}

private void OnInteractUsing(EntityUid uid, AmeControllerComponent comp, InteractUsingEvent args)
{
if (!HasComp<HandsComponent>(args.User))
{
_popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-no-hands-text"), uid, args.User);
return;
}

if (!HasComp<AmeFuelContainerComponent>(args.Used))
{
_popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-fail"), uid, args.User);
return;
}

if (Exists(comp.JarSlot.ContainedEntity))
{
_popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-already-has-jar"), uid, args.User);
return;
}

_containerSystem.Insert(args.Used, comp.JarSlot);
_popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-success"), uid, args.User, PopupType.Medium);

UpdateUi(uid, comp);
}

private void OnPowerChanged(EntityUid uid, AmeControllerComponent comp, ref PowerChangedEvent args)
{
UpdateUi(uid, comp);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Ame/EntitySystems/AmeShieldingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.Ame.Components;
using Content.Shared.Ame;
using Content.Shared.Ame.Components;
using Robust.Server.GameObjects;

namespace Content.Server.Ame.EntitySystems;
Expand Down
1 change: 0 additions & 1 deletion Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
{ "kek.", "chatsan-laughs" },
{ "rofl", "chatsan-laughs" },
{ "o7", "chatsan-salutes" },
{ "07", "chatsan-salutes" },
{ ";_;7", "chatsan-tearfully-salutes"},
{ "idk", "chatsan-shrugs" },
{ "idk.", "chatsan-shrugs" },
Expand Down
Loading

0 comments on commit f97454a

Please sign in to comment.