Fixes structure instruments not playing due to a nullability moment
This commit is contained in:
@@ -128,13 +128,15 @@ namespace Content.Client.Instruments
|
|||||||
|
|
||||||
private bool PlayCheck()
|
private bool PlayCheck()
|
||||||
{
|
{
|
||||||
|
var instrumentEnt = _owner.Instrument?.Owner;
|
||||||
var instrument = _owner.Instrument;
|
var instrument = _owner.Instrument;
|
||||||
|
|
||||||
if (instrument == null ||
|
// If either the entity or component are null, return.
|
||||||
!instrument.Owner.TryGetContainerMan(out var conMan))
|
if (instrumentEnt == null || instrument == null)
|
||||||
{
|
|
||||||
return false;
|
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;
|
var localPlayer = IoCManager.Resolve<IPlayerManager>().LocalPlayer;
|
||||||
|
|
||||||
@@ -142,9 +144,8 @@ namespace Content.Client.Instruments
|
|||||||
if (localPlayer?.ControlledEntity == null) return false;
|
if (localPlayer?.ControlledEntity == null) return false;
|
||||||
|
|
||||||
// If the instrument is handheld and we're not holding it, we return.
|
// If the instrument is handheld and we're not holding it, we return.
|
||||||
if (instrument.Handheld && (conMan.Owner != localPlayer.ControlledEntity)) return false;
|
if ((instrument.Handheld && (conMan == null
|
||||||
|
|| conMan.Owner != localPlayer.ControlledEntity))) return false;
|
||||||
var instrumentEnt = instrument.Owner;
|
|
||||||
|
|
||||||
// We check that we're in range unobstructed just in case.
|
// We check that we're in range unobstructed just in case.
|
||||||
return localPlayer.InRangeUnobstructed(instrumentEnt,
|
return localPlayer.InRangeUnobstructed(instrumentEnt,
|
||||||
|
|||||||
4
Resources/Changelog/Parts/instruments.yml
Normal file
4
Resources/Changelog/Parts/instruments.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
author: Zumorica
|
||||||
|
changes:
|
||||||
|
- type: Fix
|
||||||
|
message: Fixes structure instruments (like the piano) not playing at all.
|
||||||
Reference in New Issue
Block a user