|
|
@@ -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"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |