Stop caching connected tubes and discover them on each step (#1554)

This commit is contained in:
DrSmugleaf
2020-08-01 03:45:40 +02:00
committed by GitHub
parent bf30a68a5e
commit 9277ed5248
7 changed files with 50 additions and 151 deletions

View File

@@ -35,16 +35,16 @@ namespace Content.Server.GameObjects.Components.Disposal
public override Direction NextDirection(DisposalHolderComponent holder)
{
var next = Owner.Transform.LocalRotation;
var next = Owner.Transform.LocalRotation.GetDir();
var directions = ConnectableDirections().Skip(1).ToArray();
if (Connected.TryGetValue(next.GetDir(), out var forwardTube) &&
holder.PreviousTube == forwardTube)
if (holder.PreviousTube == null ||
DirectionTo(holder.PreviousTube) == next)
{
return _random.Pick(directions);
}
return next.GetDir();
return next;
}
public override void ExposeData(ObjectSerializer serializer)