* Fix conveyor and conveyor switch serialization

* SS14 in reactive when

* Fix new test fail with units being able to accept items when unpowered
This commit is contained in:
DrSmugleaf
2020-08-01 01:20:41 +02:00
committed by GitHub
parent 86f74b35d1
commit 9063379af9
3 changed files with 50 additions and 33 deletions

View File

@@ -208,16 +208,21 @@ namespace Content.Server.GameObjects.Components.Conveyor
serializer.DataReadWriteFunction(
"switches",
new List<IEntity>(),
switches =>
new List<EntityUid>(),
ids =>
{
if (switches == null)
if (ids == null)
{
return;
}
foreach (var @switch in switches)
foreach (var id in ids)
{
if (!Owner.EntityManager.TryGetEntity(id, out var @switch))
{
continue;
}
if (!@switch.TryGetComponent(out ConveyorSwitchComponent component))
{
continue;
@@ -226,7 +231,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
component.Connect(this);
}
},
() => _group?.Switches.Select(@switch => @switch.Owner));
() => _group?.Switches.Select(@switch => @switch.Owner.Uid).ToList());
serializer.DataField(ref _angle, "angle", 0);
serializer.DataField(ref _speed, "speed", 2);

View File

@@ -129,16 +129,21 @@ namespace Content.Server.GameObjects.Components.Conveyor
serializer.DataReadWriteFunction(
"conveyors",
new List<IEntity>(),
conveyors =>
new List<EntityUid>(),
ids =>
{
if (conveyors == null)
if (ids == null)
{
return;
}
foreach (var conveyor in conveyors)
foreach (var id in ids)
{
if (!Owner.EntityManager.TryGetEntity(id, out var conveyor))
{
continue;
}
if (!conveyor.TryGetComponent(out ConveyorComponent component))
{
continue;
@@ -147,20 +152,25 @@ namespace Content.Server.GameObjects.Components.Conveyor
Connect(component);
}
},
() => _group?.Conveyors.Select(conveyor => conveyor.Owner));
() => _group?.Conveyors.Select(conveyor => conveyor.Owner.Uid).ToList());
serializer.DataReadWriteFunction(
"switches",
new List<IEntity>(),
switches =>
new List<EntityUid>(),
ids =>
{
if (switches == null)
if (ids == null)
{
return;
}
foreach (var @switch in switches)
foreach (var id in ids)
{
if (!Owner.EntityManager.TryGetEntity(id, out var @switch))
{
continue;
}
if (!@switch.TryGetComponent(out ConveyorSwitchComponent component))
{
continue;
@@ -169,7 +179,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
component.SyncWith(this);
}
},
() => _group?.Switches.Select(@switch => @switch.Owner));
() => _group?.Switches.Select(@switch => @switch.Owner.Uid).ToList());
}
public override void OnRemove()