|
- using System;
- using System.Collections.Generic;
- 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 Svelto.Tasks;
- using Svelto.Tasks.ExtraLean;
- using RobocraftX;
- using RobocraftX.Schedulers;
-
- using GamecraftModdingAPI.Commands;
- using GamecraftModdingAPI.Tasks;
- using GamecraftModdingAPI.Utility;
-
- namespace ExtraCommands.Basics
- {
- //[CustomCommand("Chain")]
- class ChainCommandEngine : ICustomCommandEngine
- {
- public string Description => "Run two commands one after the other";
-
- public string Name => "Chain";
-
- public IEntitiesDB entitiesDB { set; private get; }
-
- public void Ready()
- {
- CommandRegistrationHelper.Register<string, string>(Name, ChainCommand, Description);
- }
-
- private void ChainCommand(string command1, string command2)
- {
- string command1a = decomma(command1);
- string command2a = decomma(command2);
- ScheduleCommands(command1a, command2a).RunOn(Scheduler.extraLeanRunner);
- }
-
- private IEnumerator<TaskContract> ScheduleCommands(string c1, string c2)
- {
- yield return Yield.It;
- bool success1 = uREPL.Evaluator.Evaluate(c1).type == CompileResult.Type.Success;
- if (!success1)
- {
- Logging.CommandLogError("First command was not executed successfully");
- }
- bool success2 = uREPL.Evaluator.Evaluate(c2).type == CompileResult.Type.Success;
- if (!success2)
- {
- Logging.CommandLogError("Second command was not executed successfully");
- }
- }
-
- private string decomma(string strIn)
- {
- return strIn.Replace(", ", " ");
- }
-
- public void Dispose()
- {
- CommandRegistrationHelper.Unregister("Chain");
- }
- }
- }
|