diff --git a/extracommands/ExtraCommands.csproj b/extracommands/ExtraCommands.csproj index 258e1be..576f441 100644 --- a/extracommands/ExtraCommands.csproj +++ b/extracommands/ExtraCommands.csproj @@ -1,7 +1,8 @@  - netstandard2 + net48 + true diff --git a/extracommands/RotatePlayerCommandEngine.cs b/extracommands/RotatePlayerCommandEngine.cs index ae276eb..f386fa8 100644 --- a/extracommands/RotatePlayerCommandEngine.cs +++ b/extracommands/RotatePlayerCommandEngine.cs @@ -10,6 +10,9 @@ using uREPL; using Svelto.Context; using RobocraftX; using Svelto.ECS.EntityStructs; +using Unity.Mathematics; +using RobocraftX.Character.Camera; +using RobocraftX.Character.Factories; namespace ExtraCommands.Basics { @@ -23,28 +26,63 @@ namespace ExtraCommands.Basics public override void Ready() { - CustomCommandUtility.Register("RotateClockwise", RotateClockwiseCommand, "Rotate the player clockwise from their original direction"); + CustomCommandUtility.Register("RotateAbsolute", RotateAbsoluteCommand, "Rotate the player camera to the entered rotation"); + CustomCommandUtility.Register("RotateRelative", RotateRelativeCommand, "Rotate the player camera by the entered rotation"); } - private void RotateToCommand(float x, float y, float z) + + private void RotateAbsoluteCommand(float vertical, float horizontal) { - ref RotationEntityStruct res = entitiesDB.QueryEntity(0u, CharacterExclusiveGroups.CharacterGroup) - // TODO: test rotate to - res.quaternion.LookRotation(new Vector3(x,y,z)); + uint count; + CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities(CameraExclusiveGroups.VisualCameraGroup, out count); + int num2 = 0; + while ((long)num2 < (long)((ulong)count)) + { + cameras[num2].eulerRotation.x = vertical; + cameras[num2].eulerRotation.y = horizontal; + // TODO: Multiplayer compatibility + /* + uint num3; + InputEntityStruct[] array; + if (this.entitiesDB.TryQueryEntitiesAndIndex(item2[num2].ID.entityID, PlayersExclusiveGroups.LocalPlayers, out num3, out array)) + { + desiredDistance = math.clamp(desiredDistance, 0f, item[num2].maxDistance); + array[(int)num3].cameraZoomFactor = math.unlerp(item[num2].minDistance, item[num2].maxDistance, desiredDistance); + } + */ + num2++; + } } - private void RotateClockwiseCommand(int degrees) + private void RotateRelativeCommand(float vertical, float horizontal) { - ref RotationEntityStruct res = entitiesDB.QueryEntity(0u, CharacterExclusiveGroups.CharacterGroup) - // TODO: test rotate clockwise - res.quaternion = Quaternion.AngleAxis(degrees, Vector3.up); + float2 angleDelta = new float2(vertical, horizontal); + uint count; + ValueTuple tuple = this.entitiesDB.QueryEntities(CameraExclusiveGroups.VisualCameraGroup, out count); + CharacterCameraSettingsEntityStruct[] settings = tuple.Item1; + CharacterCameraEntityStruct[] cameras = tuple.Item2; + int num2 = 0; + while ((long)num2 < (long)((ulong)count)) + { + CharacterCameraMovementUtility.UpdateCameraRotationFromDelta(ref cameras[num2], in settings[num2], angleDelta); + // TODO: Multiplayer compatibility + /* + uint num3; + InputEntityStruct[] array; + if (this.entitiesDB.TryQueryEntitiesAndIndex(item2[num2].ID.entityID, PlayersExclusiveGroups.LocalPlayers, out num3, out array)) + { + desiredDistance = math.clamp(desiredDistance, 0f, item[num2].maxDistance); + array[(int)num3].cameraZoomFactor = math.unlerp(item[num2].minDistance, item[num2].maxDistance, desiredDistance); + } + */ + num2++; + } } public override void Dispose() { - CustomCommandUtility.Unregister("RotateTo"); - CustomCommandUtility.Unregister("RotateClockwise"); + CustomCommandUtility.Unregister("RotateAbsolute"); + CustomCommandUtility.Unregister("RotateRelative"); } } }