Fix not checking both perspectives of a disposals tube connection (#1947)
* Fix not checking both perspectives of a disposals tube connection * Good night LINQ Switch to Reactive whence * by god
This commit is contained in:
@@ -69,14 +69,30 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
var nextDirection = NextDirection(holder);
|
||||
var snapGrid = Owner.GetComponent<SnapGridComponent>();
|
||||
var oppositeDirection = new Angle(nextDirection.ToAngle().Theta + Math.PI).GetDir();
|
||||
var tube = snapGrid
|
||||
.GetInDir(nextDirection)
|
||||
.Select(x => x.TryGetComponent(out IDisposalTubeComponent? c) ? c : null)
|
||||
.FirstOrDefault(x => x != null && x != this && x.CanConnect(oppositeDirection, this));
|
||||
|
||||
foreach (var entity in snapGrid.GetInDir(nextDirection))
|
||||
{
|
||||
if (!entity.TryGetComponent(out IDisposalTubeComponent? tube))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!tube.CanConnect(oppositeDirection, this))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!CanConnect(nextDirection, tube))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return tube;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Remove(DisposalHolderComponent holder)
|
||||
{
|
||||
var removed = Contents.Remove(holder.Owner);
|
||||
|
||||
Reference in New Issue
Block a user