Browse Source

Add untested rotate commands

tags/v0.0.2
NGnius (Graham) 5 years ago
parent
commit
d775d4e3bb
2 changed files with 50 additions and 2 deletions
  1. +0
    -2
      extracommands/CommandLineCompositionRootSaveCommandPatch.cs
  2. +50
    -0
      extracommands/RotatePlayerCommandEngine.cs

+ 0
- 2
extracommands/CommandLineCompositionRootSaveCommandPatch.cs View File

@@ -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
- 0
extracommands/RotatePlayerCommandEngine.cs View 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…
Cancel
Save