Fixes crash when computer prototype doesn't have a container manager but specifies a board prototype

This commit is contained in:
Vera Aguilera Puerto
2021-04-04 20:51:26 +02:00
parent c817fa6299
commit fdf663342e

View File

@@ -21,6 +21,9 @@ namespace Content.Server.GameObjects.Components
{ {
base.Initialize(); base.Initialize();
// Let's ensure the container manager and container are here.
Owner.EnsureContainer<Container>("board", out var _);
if (Owner.TryGetComponent(out PowerReceiverComponent? powerReceiver) && if (Owner.TryGetComponent(out PowerReceiverComponent? powerReceiver) &&
Owner.TryGetComponent(out AppearanceComponent? appearance)) Owner.TryGetComponent(out AppearanceComponent? appearance))
{ {
@@ -62,7 +65,7 @@ namespace Content.Server.GameObjects.Components
if (string.IsNullOrEmpty(_boardPrototype)) if (string.IsNullOrEmpty(_boardPrototype))
return; return;
var container = ContainerHelpers.EnsureContainer<Container>(Owner, "board", out var existed); var container = Owner.EnsureContainer<Container>("board", out var existed);
if (existed) if (existed)
{ {