Pārlūkot izejas kodu

Fix Rotation commands (required updating .NET to 4.8)

tags/v0.0.2
NGnius pirms 4 gadiem
vecāks
revīzija
d636ebaaf2
2 mainītis faili ar 52 papildinājumiem un 13 dzēšanām
  1. +2
    -1
      extracommands/ExtraCommands.csproj
  2. +50
    -12
      extracommands/RotatePlayerCommandEngine.cs

+ 2
- 1
extracommands/ExtraCommands.csproj Parādīt failu

@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2</TargetFramework>
<TargetFramework>net48</TargetFramework>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>

<ItemGroup>


+ 50
- 12
extracommands/RotatePlayerCommandEngine.cs Parādīt failu

@@ -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<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");
CustomCommandUtility.Register<float, float>("RotateAbsolute", RotateAbsoluteCommand, "Rotate the player camera to the entered rotation");
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)
// TODO: test rotate to
res.quaternion.LookRotation(new Vector3(x,y,z));
uint count;
CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(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<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)
// TODO: test rotate clockwise
res.quaternion = Quaternion.AngleAxis(degrees, Vector3.up);
float2 angleDelta = new float2(vertical, horizontal);
uint count;
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()
{
CustomCommandUtility.Unregister("RotateTo");
CustomCommandUtility.Unregister("RotateClockwise");
CustomCommandUtility.Unregister("RotateAbsolute");
CustomCommandUtility.Unregister("RotateRelative");
}
}
}

Notiek ielāde…
Atcelt
Saglabāt