Moar Gamecraft commands!
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

70 行
1.9KB

  1. using System;
  2. using System.Collections.Generic;
  3. using RobocraftX.GUI.CommandLine;
  4. using RobocraftX.Multiplayer;
  5. using RobocraftX.StateSync;
  6. using RobocraftX.Character;
  7. using Svelto.ECS;
  8. using Unity.Entities;
  9. using UnityEngine;
  10. using uREPL;
  11. using Svelto.Context;
  12. using Svelto.Tasks;
  13. using Svelto.Tasks.ExtraLean;
  14. using RobocraftX;
  15. using RobocraftX.Schedulers;
  16. using GamecraftModdingAPI.Commands;
  17. using GamecraftModdingAPI.Tasks;
  18. using GamecraftModdingAPI.Utility;
  19. namespace ExtraCommands.Basics
  20. {
  21. //[CustomCommand("Chain")]
  22. class ChainCommandEngine : ICustomCommandEngine
  23. {
  24. public string Description => "Run two commands one after the other";
  25. public string Name => "Chain";
  26. public IEntitiesDB entitiesDB { set; private get; }
  27. public void Ready()
  28. {
  29. CommandRegistrationHelper.Register<string, string>(Name, ChainCommand, Description);
  30. }
  31. private void ChainCommand(string command1, string command2)
  32. {
  33. string command1a = decomma(command1);
  34. string command2a = decomma(command2);
  35. ScheduleCommands(command1a, command2a).RunOn(Scheduler.extraLeanRunner);
  36. }
  37. private IEnumerator<TaskContract> ScheduleCommands(string c1, string c2)
  38. {
  39. yield return Yield.It;
  40. bool success1 = uREPL.Evaluator.Evaluate(c1).type == CompileResult.Type.Success;
  41. if (!success1)
  42. {
  43. Logging.CommandLogError("First command was not executed successfully");
  44. }
  45. bool success2 = uREPL.Evaluator.Evaluate(c2).type == CompileResult.Type.Success;
  46. if (!success2)
  47. {
  48. Logging.CommandLogError("Second command was not executed successfully");
  49. }
  50. }
  51. private string decomma(string strIn)
  52. {
  53. return strIn.Replace(", ", " ");
  54. }
  55. public void Dispose()
  56. {
  57. CommandRegistrationHelper.Unregister("Chain");
  58. }
  59. }
  60. }