Fix Rotation commands (required updating .NET to 4.8)
This commit is contained in:
parent
d775d4e3bb
commit
d636ebaaf2
2 changed files with 52 additions and 13 deletions
|
@ -1,7 +1,8 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2</TargetFramework>
|
<TargetFramework>net48</TargetFramework>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -10,6 +10,9 @@ using uREPL;
|
||||||
using Svelto.Context;
|
using Svelto.Context;
|
||||||
using RobocraftX;
|
using RobocraftX;
|
||||||
using Svelto.ECS.EntityStructs;
|
using Svelto.ECS.EntityStructs;
|
||||||
|
using Unity.Mathematics;
|
||||||
|
using RobocraftX.Character.Camera;
|
||||||
|
using RobocraftX.Character.Factories;
|
||||||
|
|
||||||
namespace ExtraCommands.Basics
|
namespace ExtraCommands.Basics
|
||||||
{
|
{
|
||||||
|
@ -23,28 +26,63 @@ namespace ExtraCommands.Basics
|
||||||
|
|
||||||
public override void Ready()
|
public override void Ready()
|
||||||
{
|
{
|
||||||
CustomCommandUtility.Register<float, float, float("RotateTo", RotateToCommand, "Rotate the player to the specified direction");
|
CustomCommandUtility.Register<float, float>("RotateAbsolute", RotateAbsoluteCommand, "Rotate the player camera to the entered rotation");
|
||||||
CustomCommandUtility.Register<int>("RotateClockwise", RotateClockwiseCommand, "Rotate the player clockwise from their original direction");
|
CustomCommandUtility.Register<float, float>("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<RotationEntityStruct>(0u, CharacterExclusiveGroups.CharacterGroup)
|
uint count;
|
||||||
// TODO: test rotate to
|
CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup, out count);
|
||||||
res.quaternion.LookRotation(new Vector3(x,y,z));
|
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<InputEntityStruct>(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<RotationEntityStruct>(0u, CharacterExclusiveGroups.CharacterGroup)
|
float2 angleDelta = new float2(vertical, horizontal);
|
||||||
// TODO: test rotate clockwise
|
uint count;
|
||||||
res.quaternion = Quaternion.AngleAxis(degrees, Vector3.up);
|
ValueTuple<CharacterCameraSettingsEntityStruct[], CharacterCameraEntityStruct[]> tuple = this.entitiesDB.QueryEntities<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct>(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<InputEntityStruct>(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()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
CustomCommandUtility.Unregister("RotateTo");
|
CustomCommandUtility.Unregister("RotateAbsolute");
|
||||||
CustomCommandUtility.Unregister("RotateClockwise");
|
CustomCommandUtility.Unregister("RotateRelative");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue