Rotatable: Allow specifying the rotation increment on the component (#5948)

This commit is contained in:
E F R
2021-12-31 02:20:22 +00:00
committed by GitHub
parent f6a25641e1
commit a5cd3784bf
2 changed files with 33 additions and 19 deletions

View File

@@ -43,31 +43,37 @@ namespace Content.Server.Rotatable
physics.BodyType == BodyType.Static)
return;
Verb resetRotation = new();
resetRotation.Act = () => EntityManager.GetComponent<TransformComponent>(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<TransformComponent>(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<TransformComponent>(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<TransformComponent>(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<TransformComponent>(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<TransformComponent>(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);
}