Fixes structure instruments not playing due to a nullability moment

This commit is contained in:
Vera Aguilera Puerto
2021-03-13 02:46:32 +01:00
parent 116afc634b
commit c30c60efc4
2 changed files with 12 additions and 7 deletions

View File

@@ -128,13 +128,15 @@ namespace Content.Client.Instruments
private bool PlayCheck()
{
var instrumentEnt = _owner.Instrument?.Owner;
var instrument = _owner.Instrument;
if (instrument == null ||
!instrument.Owner.TryGetContainerMan(out var conMan))
{
// If either the entity or component are null, return.
if (instrumentEnt == null || instrument == null)
return false;
}
// If we're a handheld instrument, we might be in a container. Get it just in case.
instrumentEnt.TryGetContainerMan(out var conMan);
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
@@ -142,9 +144,8 @@ namespace Content.Client.Instruments
if (localPlayer?.ControlledEntity == null) return false;
// If the instrument is handheld and we're not holding it, we return.
if (instrument.Handheld && (conMan.Owner != localPlayer.ControlledEntity)) return false;
var instrumentEnt = instrument.Owner;
if ((instrument.Handheld && (conMan == null
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
// We check that we're in range unobstructed just in case.
return localPlayer.InRangeUnobstructed(instrumentEnt,