ソースを参照

Add untested rotate commands

tags/v0.0.2
NGnius (Graham) 4年前
コミット
d775d4e3bb
2個のファイルの変更50行の追加2行の削除
  1. +0
    -2
      extracommands/CommandLineCompositionRootSaveCommandPatch.cs
  2. +50
    -0
      extracommands/RotatePlayerCommandEngine.cs

+ 0
- 2
extracommands/CommandLineCompositionRootSaveCommandPatch.cs ファイルの表示

@@ -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 ファイルの表示

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

読み込み中…
キャンセル
保存