Add untested rotate commands
This commit is contained in:
parent
915e6b6434
commit
d775d4e3bb
2 changed files with 50 additions and 2 deletions
|
@ -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<UnityContext<FullGameCompositionRoot>>);
|
||||
}
|
||||
|
||||
|
|
50
extracommands/RotatePlayerCommandEngine.cs
Normal file
50
extracommands/RotatePlayerCommandEngine.cs
Normal file
|
@ -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<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Ready()
|
||||
{
|
||||
CustomCommandUtility.Register<float, float, float("RotateTo", RotateToCommand, "Rotate the player to the specified direction");
|
||||
CustomCommandUtility.Register<int>("RotateClockwise", RotateClockwiseCommand, "Rotate the player clockwise from their original direction");
|
||||
}
|
||||
|
||||
private void RotateToCommand(float x, float y, float z)
|
||||
{
|
||||
ref RotationEntityStruct res = entitiesDB.QueryEntity<RotationEntityStruct>(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<RotationEntityStruct>(0u, CharacterExclusiveGroups.CharacterGroup)
|
||||
// TODO: test rotate clockwise
|
||||
res.quaternion = Quaternion.AngleAxis(degrees, Vector3.up);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
CustomCommandUtility.Unregister("RotateTo");
|
||||
CustomCommandUtility.Unregister("RotateClockwise");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue