Flipping fixes (ensuring unanchored, rotation preservation) (#5296)

This commit is contained in:
20kdc
2021-11-13 01:54:03 +00:00
committed by GitHub
parent 4d65e47981
commit 22da6e40c4

View File

@@ -75,8 +75,6 @@ namespace Content.Server.Rotatable
/// </summary>
public static void TryFlip(FlippableComponent component, IEntity user)
{
// TODO FLIPPABLE Currently an entity needs to be un-anchored when flipping. But the newly spawned entity
// defaults to being anchored (and spawns under floor tiles). Fix this?
if (component.Owner.TryGetComponent(out IPhysBody? physics) &&
physics.BodyType == BodyType.Static)
{
@@ -84,7 +82,11 @@ namespace Content.Server.Rotatable
return;
}
component.Owner.EntityManager.SpawnEntity(component.MirrorEntity, component.Owner.Transform.Coordinates);
var oldTransform = component.Owner.Transform;
var entity = component.Owner.EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
var newTransform = entity.Transform;
newTransform.LocalRotation = oldTransform.LocalRotation;
newTransform.Anchored = false;
component.Owner.Delete();
}
}