diff --git a/extracommands/CommandLineCompositionRootSaveCommandPatch.cs b/extracommands/CommandLineCompositionRootSaveCommandPatch.cs index 4ce8510..34c2837 100644 --- a/extracommands/CommandLineCompositionRootSaveCommandPatch.cs +++ b/extracommands/CommandLineCompositionRootSaveCommandPatch.cs @@ -38,13 +38,11 @@ namespace ExtraCommands } } } - // enginesRoot.AddEngine(new UnregisterCommandEngine(contextHolder, enginesRoot, physicsWorld, reloadGame, multiplayerParameters)); Debug.Log($"Added {engineCount} custom command engines"); } static MethodBase TargetMethod(HarmonyInstance instance) { - Type targetType = Harmony.AccessTools.TypeByName(""); return _ComposeMethodInfo(CommandLineCompositionRoot.Compose>); } diff --git a/extracommands/RotatePlayerCommandEngine.cs b/extracommands/RotatePlayerCommandEngine.cs new file mode 100644 index 0000000..ae276eb --- /dev/null +++ b/extracommands/RotatePlayerCommandEngine.cs @@ -0,0 +1,50 @@ +using System; +using RobocraftX.GUI.CommandLine; +using RobocraftX.Multiplayer; +using RobocraftX.StateSync; +using RobocraftX.Character; +using Svelto.ECS; +using Unity.Entities; +using UnityEngine; +using uREPL; +using Svelto.Context; +using RobocraftX; +using Svelto.ECS.EntityStructs; + +namespace ExtraCommands.Basics +{ + [CustomCommand("RotateTo")] + class RotatePlayerCommandEngine : CustomCommandEngine + { + + public RotatePlayerCommandEngine(UnityContext ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams) + { + } + + public override void Ready() + { + CustomCommandUtility.Register("RotateClockwise", RotateClockwiseCommand, "Rotate the player clockwise from their original direction"); + } + + private void RotateToCommand(float x, float y, float z) + { + ref RotationEntityStruct res = entitiesDB.QueryEntity(0u, CharacterExclusiveGroups.CharacterGroup) + // TODO: test rotate to + res.quaternion.LookRotation(new Vector3(x,y,z)); + } + + private void RotateClockwiseCommand(int degrees) + { + ref RotationEntityStruct res = entitiesDB.QueryEntity(0u, CharacterExclusiveGroups.CharacterGroup) + // TODO: test rotate clockwise + res.quaternion = Quaternion.AngleAxis(degrees, Vector3.up); + } + + public override void Dispose() + { + CustomCommandUtility.Unregister("RotateTo"); + CustomCommandUtility.Unregister("RotateClockwise"); + } + } +}