diff --git a/src/Murder.Editor/Architect.cs b/src/Murder.Editor/Architect.cs index 37fec289..c9384f4a 100644 --- a/src/Murder.Editor/Architect.cs +++ b/src/Murder.Editor/Architect.cs @@ -89,8 +89,7 @@ protected override void Initialize() Instance = this; _playerInput.Register(MurderInputAxis.EditorCamera, - new InputButtonAxis(Keys.W, Keys.A, Keys.S, Keys.D), - new InputButtonAxis(Keys.Up, Keys.Left, Keys.Down, Keys.Right)); + new InputButtonAxis(Keys.W, Keys.A, Keys.S, Keys.D)); ImGuiRenderer = new ImGuiRenderer(this); ImGuiRenderer.RebuildFontAtlas(); diff --git a/src/Murder.Editor/Systems/EditorCameraControllerSystem.cs b/src/Murder.Editor/Systems/EditorCameraControllerSystem.cs index 313a8a4c..879ecb29 100644 --- a/src/Murder.Editor/Systems/EditorCameraControllerSystem.cs +++ b/src/Murder.Editor/Systems/EditorCameraControllerSystem.cs @@ -64,7 +64,7 @@ public void Update(Context context) { // Handled by ImGui } - else if (!Game.Input.Down(Keys.LeftControl) && noEntitiesSelected) + else if (!Game.Input.Down(Keys.LeftControl)) { Vector2 cameraMovement = Architect.Input.GetAxis(MurderInputAxis.EditorCamera).Value * Game.DeltaTime * Architect.EditorSettings.WasdCameraSpeed * Math.Clamp((1f / hook.CurrentZoomLevel), .75f, 10f); if (Game.Input.Down(Keys.LeftShift)) diff --git a/src/Murder.Editor/Systems/EntitiesShortcutsSystem.cs b/src/Murder.Editor/Systems/EntitiesShortcutsSystem.cs index f46809ec..ebc8c430 100644 --- a/src/Murder.Editor/Systems/EntitiesShortcutsSystem.cs +++ b/src/Murder.Editor/Systems/EntitiesShortcutsSystem.cs @@ -2,11 +2,13 @@ using Bang.Contexts; using Bang.Entities; using Bang.Systems; +using Murder.Components; using Murder.Components.Graphics; using Murder.Core.Graphics; using Murder.Editor.Attributes; using Murder.Editor.Components; using Murder.Editor.Messages; +using Murder.Helpers; using Murder.Utilities; namespace Murder.Editor.Systems; @@ -35,6 +37,27 @@ public void Update(Context context) return; } + if (Game.Input.Shortcut(Microsoft.Xna.Framework.Input.Keys.R)) + { + foreach (var entity in hook.AllSelectedEntities) + { + Direction currentDirection = entity.Value.TryGetFacing()?.Direction ?? Direction.Right; + currentDirection = currentDirection.Rotate90Degrees(); + entity.Value.SetFacing(currentDirection); + + entity.Value.SendMessage(new AssetUpdatedMessage(typeof(FacingComponent))); + + if (entity.Value.TryGetSprite() is SpriteComponent sprite) + { + if (!sprite.RotateWithFacing) + { + entity.Value.SetSprite(sprite with { RotateWithFacing = true }); + entity.Value.SendMessage(new AssetUpdatedMessage(typeof(SpriteComponent))); + } + } + } + } + if (Game.Input.Shortcut(Microsoft.Xna.Framework.Input.Keys.H)) { foreach (var entity in hook.AllSelectedEntities) diff --git a/src/Murder/Components/Graphics/SpriteComponent.cs b/src/Murder/Components/Graphics/SpriteComponent.cs index 3ee24dcf..d0d85c0a 100644 --- a/src/Murder/Components/Graphics/SpriteComponent.cs +++ b/src/Murder/Components/Graphics/SpriteComponent.cs @@ -28,7 +28,7 @@ namespace Murder.Components [Tooltip("(0,0) is top left and (1,1) is bottom right"), Slider()] public readonly Vector2 Offset = Vector2.Zero; - public readonly bool RotateWithFacing = false; + public readonly bool RotateWithFacing { get; init; } = false; public readonly OutlineStyle HighlightStyle { get; init; } = OutlineStyle.None; public readonly bool UseUnscaledTime = false; diff --git a/src/Murder/Utilities/DirectionHelper.cs b/src/Murder/Utilities/DirectionHelper.cs index 372cf94e..1a53e6e2 100644 --- a/src/Murder/Utilities/DirectionHelper.cs +++ b/src/Murder/Utilities/DirectionHelper.cs @@ -34,6 +34,12 @@ public enum DirectionFlags public static class DirectionHelper { + public static Direction Rotate90Degrees(this Direction direction) + { + int newDirection = (int)direction + 2; + return (Direction)newDirection; + } + public static DirectionFlags ToDirectionFlag(this Direction direction) { switch (direction)