Fix entityUid nullability for handcuffs and morgues (#5757)
This commit is contained in:
@@ -177,7 +177,7 @@ namespace Content.Server.Cuffs.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The cuffed entity</param>
|
/// <param name="user">The cuffed entity</param>
|
||||||
/// <param name="cuffsToRemove">Optional param for the handcuff entity to remove from the cuffed entity. If null, uses the most recently added handcuff entity.</param>
|
/// <param name="cuffsToRemove">Optional param for the handcuff entity to remove from the cuffed entity. If null, uses the most recently added handcuff entity.</param>
|
||||||
public async void TryUncuff(EntityUid user, EntityUid cuffsToRemove = default)
|
public async void TryUncuff(EntityUid user, EntityUid? cuffsToRemove = null)
|
||||||
{
|
{
|
||||||
if (_uncuffing) return;
|
if (_uncuffing) return;
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ namespace Content.Server.Cuffs.Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!Container.ContainedEntities.Contains(cuffsToRemove))
|
if (!Container.ContainedEntities.Contains(cuffsToRemove.Value))
|
||||||
{
|
{
|
||||||
Logger.Warning("A user is trying to remove handcuffs that aren't in the owner's container. This should never happen!");
|
Logger.Warning("A user is trying to remove handcuffs that aren't in the owner's container. This should never happen!");
|
||||||
}
|
}
|
||||||
@@ -220,13 +220,6 @@ namespace Content.Server.Cuffs.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Why are we even doing this check?
|
|
||||||
if (!cuffsToRemove.InRangeUnobstructed(Owner))
|
|
||||||
{
|
|
||||||
Logger.Warning("Handcuffs being removed from player are obstructed or too far away! This should not happen!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
user.PopupMessage(Loc.GetString("cuffable-component-start-removing-cuffs-message"));
|
user.PopupMessage(Loc.GetString("cuffable-component-start-removing-cuffs-message"));
|
||||||
|
|
||||||
if (isOwner)
|
if (isOwner)
|
||||||
@@ -258,16 +251,18 @@ namespace Content.Server.Cuffs.Components
|
|||||||
{
|
{
|
||||||
SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound.GetSound(), Owner);
|
SoundSystem.Play(Filter.Pvs(Owner), cuff.EndUncuffSound.GetSound(), Owner);
|
||||||
|
|
||||||
Container.ForceRemove(cuffsToRemove);
|
Container.ForceRemove(cuffsToRemove.Value);
|
||||||
_entMan.GetComponent<TransformComponent>(cuffsToRemove).AttachToGridOrMap();
|
var transform = _entMan.GetComponent<TransformComponent>(cuffsToRemove.Value);
|
||||||
_entMan.GetComponent<TransformComponent>(cuffsToRemove).WorldPosition = _entMan.GetComponent<TransformComponent>(Owner).WorldPosition;
|
transform.AttachToGridOrMap();
|
||||||
|
transform.WorldPosition = _entMan.GetComponent<TransformComponent>(Owner).WorldPosition;
|
||||||
|
|
||||||
if (cuff.BreakOnRemove)
|
if (cuff.BreakOnRemove)
|
||||||
{
|
{
|
||||||
cuff.Broken = true;
|
cuff.Broken = true;
|
||||||
|
|
||||||
_entMan.GetComponent<MetaDataComponent>(cuffsToRemove).EntityName = cuff.BrokenName;
|
var meta = _entMan.GetComponent<MetaDataComponent>(cuffsToRemove.Value);
|
||||||
_entMan.GetComponent<MetaDataComponent>(cuffsToRemove).EntityDescription = cuff.BrokenDesc;
|
meta.EntityName = cuff.BrokenName;
|
||||||
|
meta.EntityDescription = cuff.BrokenDesc;
|
||||||
|
|
||||||
if (_entMan.TryGetComponent<SpriteComponent?>(cuffsToRemove, out var sprite) && cuff.BrokenState != null)
|
if (_entMan.TryGetComponent<SpriteComponent?>(cuffsToRemove, out var sprite) && cuff.BrokenState != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
private string? _trayPrototypeId;
|
private string? _trayPrototypeId;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private EntityUid _tray;
|
private EntityUid? _tray;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public ContainerSlot? TrayContainer { get; private set; }
|
public ContainerSlot? TrayContainer { get; private set; }
|
||||||
@@ -67,7 +67,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
public override Vector2 ContentsDumpPosition()
|
public override Vector2 ContentsDumpPosition()
|
||||||
{
|
{
|
||||||
if (_tray != null)
|
if (_tray != null)
|
||||||
return _entMan.GetComponent<TransformComponent>(_tray).WorldPosition;
|
return _entMan.GetComponent<TransformComponent>(_tray.Value).WorldPosition;
|
||||||
return base.ContentsDumpPosition();
|
return base.ContentsDumpPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,15 +103,15 @@ namespace Content.Server.Morgue.Components
|
|||||||
if (_tray == null)
|
if (_tray == null)
|
||||||
{
|
{
|
||||||
_tray = _entMan.SpawnEntity(_trayPrototypeId, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
_tray = _entMan.SpawnEntity(_trayPrototypeId, _entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||||
var trayComp = _tray.EnsureComponent<MorgueTrayComponent>();
|
var trayComp = _tray.Value.EnsureComponent<MorgueTrayComponent>();
|
||||||
trayComp.Morgue = Owner;
|
trayComp.Morgue = Owner;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TrayContainer?.Remove(_tray);
|
TrayContainer?.Remove(_tray.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
_entMan.GetComponent<TransformComponent>(_tray).Coordinates = new EntityCoordinates(Owner, 0, -1);
|
_entMan.GetComponent<TransformComponent>(_tray.Value).Coordinates = new EntityCoordinates(Owner, 0, -1);
|
||||||
|
|
||||||
base.OpenStorage();
|
base.OpenStorage();
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
|
|
||||||
if (_tray != null)
|
if (_tray != null)
|
||||||
{
|
{
|
||||||
TrayContainer?.Insert(_tray);
|
TrayContainer?.Insert(_tray.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ namespace Content.Server.Morgue.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entityLookup = IoCManager.Resolve<IEntityLookup>();
|
var entityLookup = IoCManager.Resolve<IEntityLookup>();
|
||||||
foreach (var entity in entityLookup.GetEntitiesIntersecting(_tray, flags: LookupFlags.None))
|
foreach (var entity in entityLookup.GetEntitiesIntersecting(_tray.Value, flags: LookupFlags.None))
|
||||||
{
|
{
|
||||||
yield return entity;
|
yield return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user