From a5cd3784bfcfa5f93871247305a53de2e8e8ade0 Mon Sep 17 00:00:00 2001 From: E F R <602406+Efruit@users.noreply.github.com> Date: Fri, 31 Dec 2021 02:20:22 +0000 Subject: [PATCH] Rotatable: Allow specifying the rotation increment on the component (#5948) --- Content.Server/Rotatable/RotatableSystem.cs | 44 +++++++++++-------- .../Rotatable/RotatableComponent.cs | 8 ++++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index 5f64d88cc1..93735132b8 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -43,31 +43,37 @@ namespace Content.Server.Rotatable physics.BodyType == BodyType.Static) return; - Verb resetRotation = new(); - resetRotation.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation = Angle.Zero; - resetRotation.Category = VerbCategory.Rotate; - resetRotation.IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png"; - resetRotation.Text = "Reset"; - resetRotation.Priority = -2; // show CCW, then CW, then reset - resetRotation.CloseMenu = false; + Verb resetRotation = new () + { + Act = () => EntityManager.GetComponent(component.Owner).LocalRotation = Angle.Zero, + Category = VerbCategory.Rotate, + IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png", + Text = "Reset", + Priority = -2, // show CCW, then CW, then reset + CloseMenu = false, + }; args.Verbs.Add(resetRotation); // rotate clockwise - Verb rotateCW = new(); - rotateCW.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(-90); - rotateCW.Category = VerbCategory.Rotate; - rotateCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png"; - rotateCW.Priority = -1; - rotateCW.CloseMenu = false; // allow for easy double rotations. + Verb rotateCW = new() + { + Act = () => EntityManager.GetComponent(component.Owner).LocalRotation -= component.Increment, + Category = VerbCategory.Rotate, + IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png", + Priority = -1, + CloseMenu = false, // allow for easy double rotations. + }; args.Verbs.Add(rotateCW); // rotate counter-clockwise - Verb rotateCCW = new(); - rotateCCW.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(90); - rotateCCW.Category = VerbCategory.Rotate; - rotateCCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png"; - rotateCCW.Priority = 0; - rotateCCW.CloseMenu = false; // allow for easy double rotations. + Verb rotateCCW = new() + { + Act = () => EntityManager.GetComponent(component.Owner).LocalRotation += component.Increment, + Category = VerbCategory.Rotate, + IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png", + Priority = 0, + CloseMenu = false, // allow for easy double rotations. + }; args.Verbs.Add(rotateCCW); } diff --git a/Content.Shared/Rotatable/RotatableComponent.cs b/Content.Shared/Rotatable/RotatableComponent.cs index 6f4b091e95..f2537472d0 100644 --- a/Content.Shared/Rotatable/RotatableComponent.cs +++ b/Content.Shared/Rotatable/RotatableComponent.cs @@ -1,6 +1,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.ViewVariables; +using Robust.Shared.Maths; namespace Content.Shared.Rotatable { @@ -22,5 +23,12 @@ namespace Content.Shared.Rotatable [ViewVariables(VVAccess.ReadWrite)] [DataField("rotateWhilePulling")] public bool RotateWhilePulling { get; protected set; } = true; + + /// + /// The angular value to change when using the rotate verbs. + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("increment")] + public Angle Increment { get; protected set; } = Angle.FromDegrees(90); } }