From 22da6e40c416ace473abe406402a9380725bea12 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Sat, 13 Nov 2021 01:54:03 +0000 Subject: [PATCH] Flipping fixes (ensuring unanchored, rotation preservation) (#5296) --- Content.Server/Rotatable/RotatableSystem.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index 4fda03278c..1d7e3db164 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -75,8 +75,6 @@ namespace Content.Server.Rotatable /// 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(); } }