Fix ItemSlots compiler warnings (#18226)

This commit is contained in:
metalgearsloth
2023-07-23 14:48:00 +10:00
committed by GitHub
parent df1dcb74ac
commit 83e3d614f0
3 changed files with 19 additions and 24 deletions

View File

@@ -5,7 +5,6 @@ using Content.Shared.Access.Components;
using Content.Shared.Access.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Serilog;
namespace Content.IntegrationTests.Tests.Access
{

View File

@@ -77,13 +77,6 @@ namespace Content.Shared.Containers.ItemSlots
[DataField("ejectSound")]
public SoundSpecifier EjectSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg");
/// <summary>
/// Options used for playing the insert/eject sounds.
/// </summary>
[DataField("soundOptions")]
[Obsolete("Use the sound specifer parameters instead")]
public AudioParams SoundOptions = AudioParams.Default;
/// <summary>
/// The name of this item slot. This will be shown to the user in the verb menu.
/// </summary>
@@ -228,7 +221,6 @@ namespace Content.Shared.Containers.ItemSlots
InsertSound = other.InsertSound;
EjectSound = other.EjectSound;
SoundOptions = other.SoundOptions;
Name = other.Name;
Locked = other.Locked;
InsertOnInteract = other.InsertOnInteract;

View File

@@ -65,7 +65,7 @@ namespace Content.Shared.Containers.ItemSlots
if (slot.HasItem || string.IsNullOrEmpty(slot.StartingItem))
continue;
var item = EntityManager.SpawnEntity(slot.StartingItem, EntityManager.GetComponent<TransformComponent>(itemSlots.Owner).Coordinates);
var item = EntityManager.SpawnEntity(slot.StartingItem, EntityManager.GetComponent<TransformComponent>(uid).Coordinates);
slot.ContainerSlot?.Insert(item);
}
}
@@ -77,7 +77,7 @@ namespace Content.Shared.Containers.ItemSlots
{
foreach (var (id, slot) in itemSlots.Slots)
{
slot.ContainerSlot = _containers.EnsureContainer<ContainerSlot>(itemSlots.Owner, id);
slot.ContainerSlot = _containers.EnsureContainer<ContainerSlot>(uid, id);
}
}
@@ -93,13 +93,13 @@ namespace Content.Shared.Containers.ItemSlots
if (itemSlots.Slots.TryGetValue(id, out var existing))
{
if (existing.Local)
Logger.Error($"Duplicate item slot key. Entity: {EntityManager.GetComponent<MetaDataComponent>(itemSlots.Owner).EntityName} ({uid}), key: {id}");
Log.Error($"Duplicate item slot key. Entity: {EntityManager.GetComponent<MetaDataComponent>(uid).EntityName} ({uid}), key: {id}");
else
// server state takes priority
slot.CopyFrom(existing);
}
slot.ContainerSlot = _containers.EnsureContainer<ContainerSlot>(itemSlots.Owner, id);
slot.ContainerSlot = _containers.EnsureContainer<ContainerSlot>(uid, id);
itemSlots.Slots[id] = slot;
Dirty(itemSlots);
}
@@ -340,7 +340,7 @@ namespace Content.Shared.Containers.ItemSlots
if (ejected != null && ejected.Value && user != null)
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(user.Value)} ejected {ToPrettyString(item)} from {slot.ContainerSlot?.ID + " slot of "}{ToPrettyString(uid)}");
_audioSystem.PlayPredicted(slot.EjectSound, uid, excludeUserAudio ? user : null, slot.SoundOptions);
_audioSystem.PlayPredicted(slot.EjectSound, uid, excludeUserAudio ? user : null);
}
/// <summary>
@@ -477,9 +477,11 @@ namespace Content.Shared.Containers.ItemSlots
? Loc.GetString(slot.Name)
: EntityManager.GetComponent<MetaDataComponent>(slot.Item.Value).EntityName ?? string.Empty;
AlternativeVerb verb = new();
verb.IconEntity = slot.Item;
verb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true);
AlternativeVerb verb = new()
{
IconEntity = slot.Item,
Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true)
};
if (slot.EjectVerbText == null)
{
@@ -538,18 +540,20 @@ namespace Content.Shared.Containers.ItemSlots
var verbSubject = slot.Name != string.Empty
? Loc.GetString(slot.Name)
: Name(args.Using.Value) ?? string.Empty;
: Name(args.Using.Value);
InteractionVerb insertVerb = new();
insertVerb.IconEntity = args.Using;
insertVerb.Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true);
InteractionVerb insertVerb = new()
{
IconEntity = args.Using,
Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true)
};
if (slot.InsertVerbText != null)
{
insertVerb.Text = Loc.GetString(slot.InsertVerbText);
insertVerb.Icon =
new SpriteSpecifier.Texture(
new("/Textures/Interface/VerbIcons/insert.svg.192dpi.png"));
new ResPath("/Textures/Interface/VerbIcons/insert.svg.192dpi.png"));
}
else if(slot.EjectOnInteract)
{
@@ -558,7 +562,7 @@ namespace Content.Shared.Containers.ItemSlots
insertVerb.Text = Loc.GetString("place-item-verb-text", ("subject", verbSubject));
insertVerb.Icon =
new SpriteSpecifier.Texture(
new("/Textures/Interface/VerbIcons/drop.svg.192dpi.png"));
new ResPath("/Textures/Interface/VerbIcons/drop.svg.192dpi.png"));
}
else
{
@@ -635,7 +639,7 @@ namespace Content.Shared.Containers.ItemSlots
return;
slot.Locked = locked;
itemSlots.Dirty();
Dirty(uid, itemSlots);
}
/// <summary>