Rotatable: Allow specifying the rotation increment on the component (#5948)
This commit is contained in:
@@ -43,31 +43,37 @@ namespace Content.Server.Rotatable
|
|||||||
physics.BodyType == BodyType.Static)
|
physics.BodyType == BodyType.Static)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Verb resetRotation = new();
|
Verb resetRotation = new ()
|
||||||
resetRotation.Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero;
|
{
|
||||||
resetRotation.Category = VerbCategory.Rotate;
|
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation = Angle.Zero,
|
||||||
resetRotation.IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png";
|
Category = VerbCategory.Rotate,
|
||||||
resetRotation.Text = "Reset";
|
IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png",
|
||||||
resetRotation.Priority = -2; // show CCW, then CW, then reset
|
Text = "Reset",
|
||||||
resetRotation.CloseMenu = false;
|
Priority = -2, // show CCW, then CW, then reset
|
||||||
|
CloseMenu = false,
|
||||||
|
};
|
||||||
args.Verbs.Add(resetRotation);
|
args.Verbs.Add(resetRotation);
|
||||||
|
|
||||||
// rotate clockwise
|
// rotate clockwise
|
||||||
Verb rotateCW = new();
|
Verb rotateCW = new()
|
||||||
rotateCW.Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation += Angle.FromDegrees(-90);
|
{
|
||||||
rotateCW.Category = VerbCategory.Rotate;
|
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation -= component.Increment,
|
||||||
rotateCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png";
|
Category = VerbCategory.Rotate,
|
||||||
rotateCW.Priority = -1;
|
IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png",
|
||||||
rotateCW.CloseMenu = false; // allow for easy double rotations.
|
Priority = -1,
|
||||||
|
CloseMenu = false, // allow for easy double rotations.
|
||||||
|
};
|
||||||
args.Verbs.Add(rotateCW);
|
args.Verbs.Add(rotateCW);
|
||||||
|
|
||||||
// rotate counter-clockwise
|
// rotate counter-clockwise
|
||||||
Verb rotateCCW = new();
|
Verb rotateCCW = new()
|
||||||
rotateCCW.Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation += Angle.FromDegrees(90);
|
{
|
||||||
rotateCCW.Category = VerbCategory.Rotate;
|
Act = () => EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation += component.Increment,
|
||||||
rotateCCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png";
|
Category = VerbCategory.Rotate,
|
||||||
rotateCCW.Priority = 0;
|
IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png",
|
||||||
rotateCCW.CloseMenu = false; // allow for easy double rotations.
|
Priority = 0,
|
||||||
|
CloseMenu = false, // allow for easy double rotations.
|
||||||
|
};
|
||||||
args.Verbs.Add(rotateCCW);
|
args.Verbs.Add(rotateCCW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
namespace Content.Shared.Rotatable
|
namespace Content.Shared.Rotatable
|
||||||
{
|
{
|
||||||
@@ -22,5 +23,12 @@ namespace Content.Shared.Rotatable
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("rotateWhilePulling")]
|
[DataField("rotateWhilePulling")]
|
||||||
public bool RotateWhilePulling { get; protected set; } = true;
|
public bool RotateWhilePulling { get; protected set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The angular value to change when using the rotate verbs.
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("increment")]
|
||||||
|
public Angle Increment { get; protected set; } = Angle.FromDegrees(90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user