Fix cursed locker collision (#3759)

This commit is contained in:
metalgearsloth
2021-04-01 18:46:23 +11:00
committed by GitHub
parent 5ecb5b9c34
commit b6f337f7f8

View File

@@ -273,23 +273,14 @@ namespace Content.Server.GameObjects.Components.Items.Storage
if (entity == Owner) return false; if (entity == Owner) return false;
if (entity.TryGetComponent(out IPhysBody? entityPhysicsComponent)) if (entity.TryGetComponent(out IPhysBody? entityPhysicsComponent))
{ {
if(MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X if (MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X
|| MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y) || MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y)
{ {
return false; return false;
} }
} }
if (Contents.CanInsert(entity))
{ return Contents.CanInsert(entity) && Insert(entity);
Contents.Insert(entity);
entity.Transform.LocalPosition = Vector2.Zero;
if (entityPhysicsComponent != null)
{
entityPhysicsComponent.CanCollide = false;
}
return true;
}
return false;
} }
public virtual Vector2 ContentsDumpPosition() public virtual Vector2 ContentsDumpPosition()
@@ -365,7 +356,14 @@ namespace Content.Server.GameObjects.Components.Items.Storage
return true; return true;
} }
return Contents.Insert(entity); if (!Contents.Insert(entity)) return false;
entity.Transform.LocalPosition = Vector2.Zero;
if (entity.TryGetComponent(out IPhysBody? body))
{
body.CanCollide = false;
}
return true;
} }
/// <inheritdoc /> /// <inheritdoc />