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 Content.Shared.Access.Systems;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Serilog;
namespace Content.IntegrationTests.Tests.Access namespace Content.IntegrationTests.Tests.Access
{ {

View File

@@ -77,13 +77,6 @@ namespace Content.Shared.Containers.ItemSlots
[DataField("ejectSound")] [DataField("ejectSound")]
public SoundSpecifier EjectSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagOut/revolver_magout.ogg"); 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> /// <summary>
/// The name of this item slot. This will be shown to the user in the verb menu. /// The name of this item slot. This will be shown to the user in the verb menu.
/// </summary> /// </summary>
@@ -228,7 +221,6 @@ namespace Content.Shared.Containers.ItemSlots
InsertSound = other.InsertSound; InsertSound = other.InsertSound;
EjectSound = other.EjectSound; EjectSound = other.EjectSound;
SoundOptions = other.SoundOptions;
Name = other.Name; Name = other.Name;
Locked = other.Locked; Locked = other.Locked;
InsertOnInteract = other.InsertOnInteract; InsertOnInteract = other.InsertOnInteract;

View File

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