_illuminatingDreamLanternList can sometimes be null

This commit is contained in:
JohnCorby 2022-05-28 10:01:43 -07:00
parent 15ab10e05f
commit a26b8de8d1
2 changed files with 11 additions and 4 deletions

View File

@ -140,8 +140,11 @@ internal class LightSensorPatches : QSBPatch
__instance._fixedUpdateFrameDelayCount--;
}
_prevIlluminatingDreamLanternList.Clear();
_prevIlluminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
if (__instance._illuminatingDreamLanternList != null)
{
_prevIlluminatingDreamLanternList.Clear();
_prevIlluminatingDreamLanternList.AddRange(__instance._illuminatingDreamLanternList);
}
var illuminated = __instance._illuminated;
__instance.UpdateIllumination();
@ -162,7 +165,8 @@ internal class LightSensorPatches : QSBPatch
qsbLightSensor.SendMessage(new SetIlluminatedMessage(false));
}
if (!__instance._illuminatingDreamLanternList.SequenceEqual(_prevIlluminatingDreamLanternList))
if (__instance._illuminatingDreamLanternList != null
&& !__instance._illuminatingDreamLanternList.SequenceEqual(_prevIlluminatingDreamLanternList))
{
qsbLightSensor.SendMessage(new IlluminatingLanternsMessage(__instance._illuminatingDreamLanternList));
}

View File

@ -21,7 +21,10 @@ internal class QSBLightSensor : WorldObject<SingleLightSensor>
public override void SendInitialState(uint to)
{
this.SendMessage(new IlluminatedByMessage(_illuminatedBy.ToArray()) { To = to });
this.SendMessage(new IlluminatingLanternsMessage(AttachedObject._illuminatingDreamLanternList) { To = to });
if (AttachedObject._illuminatingDreamLanternList != null)
{
this.SendMessage(new IlluminatingLanternsMessage(AttachedObject._illuminatingDreamLanternList) { To = to });
}
}
public override async UniTask Init(CancellationToken ct) => QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;