private void AddFlipVerb(EntityUid uid, FlippableComponent component, GetOtherVerbsEvent args) { if (!args.CanAccess || !args.CanInteract || component.MirrorEntity == null) { return; } Verb verb = new(); verb.Act = () => TryFlip(component, args.User); verb.Text = Loc.GetString("flippable-verb-get-data-text"); // TODO VERB ICONS Add Uno reverse card style icon? args.Verbs.Add(verb); }
/// <summary> /// Replace a flippable entity with it's flipped / mirror-symmetric entity. /// </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) { component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); return; } component.Owner.EntityManager.SpawnEntity(component.MirrorEntity, component.Owner.Transform.Coordinates); component.Owner.Delete(); }
/// <summary> /// Replace a flippable entity with it's flipped / mirror-symmetric entity. /// </summary> public void TryFlip(FlippableComponent component, EntityUid user) { if (EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && physics.BodyType == BodyType.Static) { component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); return; } var oldTransform = EntityManager.GetComponent <TransformComponent>(component.Owner); var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates); var newTransform = EntityManager.GetComponent <TransformComponent>(entity); newTransform.LocalRotation = oldTransform.LocalRotation; newTransform.Anchored = false; EntityManager.DeleteEntity(component.Owner); }