void RestartService() { _log.Debug("Restarting supervised service"); var createArguments = new CommandScriptStepArguments { _serviceBuilderFactory, }; var unloadArguments = new CommandScriptStepArguments { _serviceHandle, }; var script = new CommandScript { new CommandScriptStep <CreateServiceCommand>(createArguments), new CommandScriptStep <StopServiceCommand>(unloadArguments), new CommandScriptStep <StartServiceCommand>(createArguments), new CommandScriptStep <UnloadServiceCommand>(unloadArguments), }; bool restarted = Execute(script); if (restarted) { _serviceHandle = createArguments.Get <ServiceHandle>(); } }
bool CommandHandler.Handle(Guid commandId, CommandScript script) { if (commandId == Guid.Empty) return true; return _commandHandlers.Any(handler => handler.Handle(commandId, script)); }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as BindCommand).TheClient; string key = entry.GetArgument(queue, 0); Key k = KeyHandler.GetKeyForName(key); // TODO: Bad key error if (entry.Arguments.Count == 1) { CommandScript cs = KeyHandler.GetBind(k); if (cs == null) { queue.HandleError(entry, "That key is not bound, or does not exist."); } else { entry.Info(queue, TagParser.Escape(KeyHandler.keystonames[k] + ": {\n" + cs.FullString() + "}")); } } else if (entry.Arguments.Count >= 2) { KeyHandler.BindKey(k, entry.GetArgument(queue, 1)); entry.Good(queue, "Keybind updated for " + KeyHandler.keystonames[k] + "."); } }
public UnturnedCustomCommand(string name, string help, CommandScript script) { this._command = name; this._help = help; this._info = help; ExecScript = script; }
public override void Execute(PlayerCommandEntry entry) { if (entry.InputArguments.Count <= 0) { entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, "/remote <commands>"); return; } CommandQueue queue = CommandScript.SeparateCommands("command_line", entry.AllArguments(), entry.Player.TheServer.Commands.CommandSystem, false).ToQueue(entry.Player.TheServer.Commands.CommandSystem); queue.SetVariable("player", new PlayerTag(entry.Player)); queue.Outputsystem = (message, messageType) => { string bcolor = "^r^7"; switch (messageType) { case MessageType.INFO: case MessageType.GOOD: bcolor = "^r^2"; break; case MessageType.BAD: bcolor = "^r^3"; break; } entry.Player.SendMessage(TextChannel.COMMAND_RESPONSE, entry.Player.TheServer.Commands.CommandSystem.TagSystem.ParseTagsFromText(message, bcolor, queue.CommandStack.Peek().Variables, DebugMode.FULL, (o) => { /* DO NOTHING */ }, true)); }; queue.Execute(); }
/// <summary> /// Binds a key to a command. /// </summary> /// <param name="key">The key to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> public static void BindKey(Key key, string bind) { Binds.Remove(key); InverseBinds.Remove(key); if (bind != null) { CommandScript script = CommandScript.SeparateCommands("bind_" + key, bind, Client.Central.Commands.CommandSystem, false); script.Debug = DebugMode.MINIMAL; Binds[key] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + key, new List <CommandEntry>() { fixedentry }) { Debug = DebugMode.MINIMAL }; InverseBinds[key] = nscript; } } Modified = true; }
/// <summary> /// Binds a key to a command. /// </summary> /// <param name="key">The key to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> public static void BindKey(Key key, List <CommandEntry> bind, int adj) { Binds.Remove(key); InverseBinds.Remove(key); if (bind != null) { CommandScript script = new CommandScript("_bind_for_" + keystonames[key], bind, adj); script.Debug = DebugMode.MINIMAL; Binds[key] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + key, new List <CommandEntry>() { fixedentry }) { Debug = DebugMode.MINIMAL }; InverseBinds[key] = nscript; } } Modified = true; }
public static void Execute(CommandQueue queue, CommandEntry entry) { Client TheClient = (entry.Command as GP_BindCommand).TheClient; string key = entry.GetArgument(queue, 0); if (!Enum.TryParse(key, true, out GamePadButton btn)) { queue.HandleError(entry, "Unknown button: " + key); return; } if (entry.Arguments.Count == 1) { CommandScript cs = TheClient.Gamepad.ButtonBinds[(int)btn]; if (cs == null) { queue.HandleError(entry, "That button is not bound, or does not exist."); } else { entry.InfoOutput(queue, btn + ": {\n" + cs.FullString() + "}"); } } else if (entry.Arguments.Count >= 2) { TheClient.Gamepad.BindButton(btn, entry.GetArgument(queue, 1)); entry.GoodOutput(queue, "Keybind updated for " + btn + "."); } }
/// <summary> /// Called after an ability is used, places abilites on cooldown and checks if the player hits. /// </summary> /// <param name="ability">The ability.</param> /// <param name="cd">The cd.</param> /// <param name="damage">The damage.</param> public void EndOfTurn(string ability, int cd, int damage) { //Make sure the script has a reference to the GameTurnController if (!GameTurnController) { GameTurnController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameTurnController>(); } switch (ability) { case "Thrust": GetComponent <Animator>().SetTrigger("PlayerThrust"); break; case "Slash": case "StrainSlash": GetComponent <Animator>().SetTrigger("PlayerSlash"); break; case "Block": GetComponent <Animator>().SetTrigger("PlayerBlock"); break; case "Slam": GetComponent <Animator>().SetTrigger("PlayerSDash"); break; } //Check if the Player hits string hit = CalculateHit(); //Get a reference to the enemy GameObject enemyGameObject = CommandScript.GetRaycastObject(); switch (hit) { //If missing case "Miss": //Inform the Player and let the enemy know if (ability != "Block" && ability != "ShieldBlock") { DialogueScript.CombatTextPlayer("You missed the enemy!"); enemyGameObject.GetComponent <EnemyScript>().PlayerMissed(); } break; //If hit case "Hit": //Call the function to do damage and place the ability on cooldown StartCoroutine(DoDamage(damage, ability)); AddToCooldownList(ability, cd); break; //Or if it's a crit case "Crit": //Call the damage function and give it twice the amount of damage, then set ability cooldown StartCoroutine(DoDamage(damage * 2, ability)); AddToCooldownList(ability, cd); break; } //Change the turn ChangeTurn(ability, hit); }
void StartService() { if (_serviceHandle != null) { _log.Debug("Attempted to start service, but it is already started"); return; } string reason; if (!CanStartService(out reason)) { _log.DebugFormat("Attempted to start service, but it is not available: {0}", reason); return; } _log.Debug("Starting supervised service"); var arguments = new CommandScriptStepArguments { _serviceBuilderFactory }; var script = new CommandScript { new CommandScriptStep <CreateServiceCommand>(arguments), new CommandScriptStep <StartServiceCommand>(arguments), }; bool started = Execute(script); if (started) { _serviceHandle = arguments.Get <ServiceHandle>(); } }
void StartService() { if (_serviceHandle != null) { _log.Debug("Attempted to start service, but it is already started"); return; } if (!_serviceAvailability.CanStart()) { _log.Debug("Attempted to start service, but it is unavailable"); return; } _log.Debug("Starting supervised service"); var arguments = new CommandScriptStepArguments { _serviceBuilderFactory }; var script = new CommandScript { new CommandScriptStep <CreateServiceCommand>(arguments), new CommandScriptStep <StartServiceCommand>(arguments), }; bool started = Execute(script); if (started) { _serviceHandle = arguments.Get <ServiceHandle>(); } }
bool Execute(CommandScript script) { script.Variables.Add(_settings); script.Variables.Add <HostControl>(this); return(((CommandHandler)this).Handle(script.NextCommandId, script)); }
public Driver(Node goal) { _cs = new CommandScript(); _location = new TrackerMatrix(); _robot = new Robot("COM19"); _robot.Open(); _goal = goal; }
bool CommandHandler.Handle(Guid commandId, CommandScript script) { if (commandId == Guid.Empty) { return(true); } return(_commandHandlers.Any(handler => handler.Handle(commandId, script))); }
/// <summary> /// Binds a key to a command. /// </summary> /// <param name="key">The key to bind</param> /// <param name="bind">The command to bind to it (null to unbind)</param> public static void BindKey(Key key, string bind) { Binds.Remove(key); if (bind != null) { CommandScript script = CommandScript.SeparateCommands("BIND:" + key, bind, ClientCommands.CommandSystem); script.Debug = DebugMode.MINIMAL; Binds.Add(key, script); } Modified = true; }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { _log.Debug("CreateServiceCommand Compensating..."); ServiceHandle serviceHandle; if (audit.Result.TryGetValue(out serviceHandle)) { serviceHandle.Dispose(); } return true; }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { _log.Debug("CreateServiceCommand Compensating..."); ServiceHandle serviceHandle; if (audit.Result.TryGetValue(out serviceHandle)) { serviceHandle.Dispose(); } return(true); }
/* Add - Adds a command to the top of the stack, pausing the current item and executing it next frame */ public void Add(CommandScript command) { if(commands.Count > 0) { // Make sure we're not just receiving the same action again if(currentCommand.GetType() != command.GetType()) { commands.Push(command); } } else { // The stack is empty so push it! commands.Push(command); } }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { var started = audit.Result.Get<bool>("started"); if (started) { var serviceHandle = audit.Result.Get<ServiceHandle>(); var hostControl = audit.Result.Get<HostControl>(); return serviceHandle.Stop(hostControl); } return true; }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { var started = audit.Result.Get <bool>("started"); if (started) { var serviceHandle = audit.Result.Get <ServiceHandle>(); var hostControl = audit.Result.Get <HostControl>(); return(serviceHandle.Stop(hostControl)); } return(true); }
/// <summary> /// Pushes the wall /// </summary> /// <param name="arg">The argument.</param> /// <param name="length">Length (for pushing wall)</param> public void Push(string arg, string length) { //If the player wants to push a button if (string.Equals(arg, "button", StringComparison.CurrentCultureIgnoreCase)) { GameObject hit = CommandScript.GetRaycastObject("Button"); if (hit == null) { DialogueScript.ErrorText("There's nothing here to push."); return; } if (hit.transform.GetComponent <Button>().IsPressed == false) { MovementHappening = true; StartCoroutine(RotateAndInteract(hit)); } else { DialogueScript.ErrorText("It seems like you've already pressed the button."); } } int pushDistance = 0; if (length != null && length.All(char.IsDigit)) { pushDistance = int.Parse(length); } if (string.Equals(arg, "wall", StringComparison.CurrentCultureIgnoreCase)) { GameObject hit = GetRaycastObject(); if (hit.tag == "PushableWall") { if (pushDistance == 0) { pushDistance = 100; } StartCoroutine(PushTheWall(hit, pushDistance)); } else { DialogueScript.ErrorText("There's no wall there to push."); } } }
/// <summary> /// Binds a key to a command. /// </summary> /// <param name="key">The key to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> public static void BindKey(Key key, string bind) { Binds.Remove(key); InverseBinds.Remove(key); if (bind != null) { CommandScript script = CommandScript.SeparateCommands("bind_" + key, bind, Client.Central.Commands.CommandSystem, false); script.Debug = DebugMode.MINIMAL; Binds[key] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + key, new List<CommandEntry>() { fixedentry }) { Debug = DebugMode.MINIMAL }; InverseBinds[key] = nscript; } } Modified = true; }
public override void Loaded(DockItem item) { base.Loaded(item); mPersistence = (CommandLinePersistence)ComponentManager.LoadObject("CommandLine", typeof(CommandLinePersistence), item); Task.Factory.StartNew(() => { System.Threading.Thread.CurrentThread.Name = "CommandLine.Loaded"; if (mPersistence == null) { mPersistence = new CommandLinePersistence() { Script = "" } } ; // TODO: set a default script here try { ComponentManager.Execute(mPersistence.Script); } catch (Exception ex) { consoleview.WriteOutput("Error: " + ex.Message); consoleview.Prompt(true); } m_ScriptingInstance = new CommandScript(this, consoleview, ComponentManager); // output can be redirected to any object which implements method write and property softspace string[] phython_script_for_redirecting_stdout_and_stderr = new string[] { "import sys", "cmd=app().GetInstance(\"" + (this as ILocalizableComponent).Name + "\")", "sys.stderr=cmd", "sys.stdout=cmd" }; ComponentManager.Execute(String.Join("\r\n", phython_script_for_redirecting_stdout_and_stderr)); }); }
IEnumerator DoDamage(int damage, string ability) { if (!PlayerScript) { PlayerScript = GetComponent <Player>(); } GameObject enemyGameObject = CommandScript.GetRaycastObject(); var enemyScript = enemyGameObject.GetComponent <EnemyScript>(); yield return(new WaitForSeconds(1)); if (damage == 0) { enemyScript.PlayerMissed(); yield break; } if (enemyGameObject.GetComponent <EnemyCombat>().isBlocking == false) { int damageDone = CalculateDamage(damage); GameObject.FindGameObjectWithTag("Weapon").GetComponent <AudioSource>().Play(); if (enemyGameObject.name != "BallOfDarkness") { enemyGameObject.GetComponent <AudioSource>().Play(); } if (ability == "Slam") { enemyScript.CheckHealth(damageDone, ability); } else { enemyScript.CheckHealth(damageDone, ability); } GameObject.FindGameObjectWithTag("UI").GetComponent <InterfaceScript>().ShowDamage(damageDone); } else { DialogueScript.CombatTextEnemy("The enemy blocks your attack"); GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn; enemyGameObject.GetComponent <EnemyCombat>().StartTurn(); } }
public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry) { if (entry.Arguments[0].ToString() == "\0CALLBACK") { return; } if (entry.Arguments.Count < 3) { ShowUsage(queue, entry); return; } bool servermode = entry.GetArgument(queue, 0).ToLowerFast() == "server"; string name = entry.GetArgument(queue, 1).ToLowerFast(); string help = entry.GetArgument(queue, 2); if (entry.InnerCommandBlock == null) { queue.HandleError(entry, "Event command invalid: No block follows!"); return; } // NOTE: Commands are compiled! CommandScript script = new CommandScript("ut_command_" + name, entry.InnerCommandBlock, entry.BlockStart, queue.CurrentEntry.Types, true) { Debug = DebugMode.MINIMAL }; UnturnedCustomCommand ucc = new UnturnedCustomCommand(name, help, script); if (servermode) { Commander.commands.Insert(1, ucc); } else { UnturnedFreneticMod.Instance.PlayerCommands.Add(ucc); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Registered command!"); } }
/// <summary> /// Binds a button to a command. /// </summary> /// <param name="btn">The button to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> public void BindButton(GamePadButton btn, string bind) { ButtonBinds[(int)btn] = null; ButtonInverseBinds[(int)btn] = null; if (bind != null) { CommandScript script = CommandScript.SeparateCommands("bind_" + btn, bind, TheClient.Commands.CommandSystem); script.Debug = DebugMode.MINIMAL; ButtonBinds[(int)btn] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + btn, new List <CommandEntry>() { fixedentry }, mode: DebugMode.MINIMAL); ButtonInverseBinds[(int)btn] = nscript; } } Modified = true; }
void StopService() { _log.Debug("Stopping supervised service"); var unloadArguments = new CommandScriptStepArguments { _serviceHandle, }; var script = new CommandScript { new CommandScriptStep <StopServiceCommand>(unloadArguments), new CommandScriptStep <UnloadServiceCommand>(unloadArguments), }; bool stopped = Execute(script); if (stopped) { _serviceHandle = null; } }
/// <summary> /// Enters the specified argument. /// </summary> /// <param name="arg">The argument.</param> public void Enter() { //CheckString("Enter", arg); GameObject hit = CommandScript.GetRaycastObject(); if (hit == null) { DialogueScript.ErrorText("There's nothing in front of you to enter"); return; } if (hit.transform.tag == "Hatch") { if (LevelScript.ExitOpen || SceneManager.GetActiveScene().name == "Tutorial") { PlayerPrefs.SetInt("PlayedTutorial", 1); DialogueScript.GameInformationText("You slowly descend into the darkness."); GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <LevelChanger>().ChangeLevel(); LevelFinished = true; return; } DialogueScript.ErrorText("You can't enter something that isn't open."); } }
void Awake() { myNavMeshAgent = GetComponent <NavMeshAgent>(); if (null == myOwner) { myOwner = GetComponent <OwnerScript>(); } if (null == myHealth) { myHealth = GetComponent <HealthScript>(); } if (null == myCommands) { myCommands = GetComponent <CommandScript>(); } if (null == myAttackMessenger) { myAttackMessenger = gameObject.AddComponent <Messenger_Script>() as Messenger_Script; } }
/// <summary>Returns a FunctionTag for the given text.</summary> /// <param name="data">The data.</param> /// <param name="input">The input text.</param> /// <returns>A TagTypeTag.</returns> public static FunctionTag For(TagData data, string input) { if (!input.Contains('|')) { CommandScript script = data.Engine.GetFunction(input); if (script == null) { throw data.Error($"Unknown script name '{TextStyle.Separate}{input}{TextStyle.Base}'."); } return(new FunctionTag(script)); } ListTag list = ListTag.For(input); if (list.Internal.Count < 2) { throw data.Error("Cannot construct FunctionTag with empty input."); } string type = list.Internal[0].ToString(); if (type == "anon") { if (list.Internal.Count < 4) { throw data.Error("Cannot construct FunctionTag without start line, name, and commandlist input."); } string name = list.Internal[1].ToString(); int startLine = (int)IntegerTag.For(list.Internal[2], data).Internal; string commands = list.Internal[3].ToString(); CommandScript script = ScriptParser.SeparateCommands(name, commands, data.Engine, startLine, data.DBMode); if (script == null) { throw data.Error("Anonymous function failed to generate."); } script.TypeName = CommandScript.TYPE_NAME_ANONYMOUS; script.IsAnonymous = true; script.AnonymousString = input["anon|".Length..];
/// <summary> /// Binds a button to a command. /// </summary> /// <param name="btn">The button to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> /// <param name="adj">adjustment location for the script.</param> public void BindButton(GamePadButton btn, List <CommandEntry> bind, int adj) { ButtonBinds[(int)btn] = null; ButtonInverseBinds[(int)btn] = null; if (bind != null) { CommandScript script = new CommandScript("_bind_for_" + btn, bind, adj) { Debug = DebugMode.MINIMAL }; ButtonBinds[(int)btn] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + btn, new List <CommandEntry>() { fixedentry }, mode: DebugMode.MINIMAL); ButtonInverseBinds[(int)btn] = nscript; } } Modified = true; }
void Awake() { myNavMeshAgent = GetComponent<NavMeshAgent>(); if(null == myOwner) { myOwner = GetComponent<OwnerScript>(); } if(null == myHealth) { myHealth = GetComponent<HealthScript>(); } if(null == myCommands) { myCommands = GetComponent<CommandScript>(); } if(null == myAttackMessenger) { myAttackMessenger = gameObject.AddComponent<Messenger_Script>() as Messenger_Script; } }
/// <summary>Executes the run command.</summary> /// <param name="queue">The command queue involved.</param> /// <param name="entry">The command details to be ran.</param> public static void Execute(CommandQueue queue, CommandEntry entry) { string fname = entry.GetArgument(queue, 0).ToLowerFast(); ScriptRanPreEventArgs args = new() { ScriptName = fname }; RunfileCommand rcmd = entry.Command as RunfileCommand; if (rcmd.OnScriptRanPreEvent != null) { rcmd.OnScriptRanPreEvent.Fire(args); } if (args.Cancelled) { entry.BadOutput(queue, "Script running cancelled via the ScriptRanPreEvent."); if (entry.WaitFor && queue.WaitingOn == entry) { queue.WaitingOn = null; } return; } CommandScript script = queue.Engine.GetScriptFile(args.ScriptName, out string status); if (script != null) { ScriptRanEventArgs args2 = new() { Script = script }; if (rcmd.OnScriptRanEvent != null) { rcmd.OnScriptRanEvent.Fire(args2); } if (args2.Cancelled) { entry.BadOutput(queue, "Script running cancelled via the ScriptRanEvent."); if (entry.WaitFor && queue.WaitingOn == entry) { queue.WaitingOn = null; } return; } if (script == null) { entry.BadOutput(queue, "Script running nullified via the ScriptRanEvent."); if (entry.WaitFor && queue.WaitingOn == entry) { queue.WaitingOn = null; } return; } script = args2.Script; if (entry.ShouldShowGood(queue)) { entry.GoodOutput(queue, "Running '" + TextStyle.Separate + fname + TextStyle.Base + "'..."); } Dictionary <string, TemplateObject> vars = new(); queue.Engine.ExecuteScript(script, ref vars, out CommandQueue nqueue); if (entry.WaitFor && queue.WaitingOn == entry) { if (!nqueue.Running) { queue.WaitingOn = null; } else { EntryFinisher fin = new() { Entry = entry, Queue = queue }; nqueue.Complete += fin.Complete; } } ScriptRanPostEventArgs args4 = new() { Script = script }; if (rcmd.OnScriptRanPostEvent != null) { rcmd.OnScriptRanPostEvent.Fire(args4); } // TODO: queue.SetVariable("run_variables", new MapTag(nqueue.LowestVariables)); // TODO: use the ^= syntax here. } else { queue.HandleError(entry, "Cannot run script '" + TextStyle.Separate + fname + TextStyle.Base + "': " + status + "!"); if (entry.WaitFor && queue.WaitingOn == entry) { queue.WaitingOn = null; } } } }
public override void Loaded() { // important to call base first to ensure loading of persistency base.Loaded(); Task.Factory.StartNew(() => { if (mPersistence == null) mPersistence = new CommandLinePersistence() { Script = "" }; // TODO: set a default script here try { ComponentManager.Execute(mPersistence.Script); } catch (Exception ex) { consoleview.WriteOutput("Error: " + ex.Message); consoleview.Prompt(true); } m_ScriptingInstance = new CommandScript(this, consoleview, ComponentManager); // output can be redirected to any object which implements method write and property softspace string[] phython_script_for_redirecting_stdout_and_stderr = new string[] { "import sys", "cmd=app().GetInstance(\""+(this as ILocalizableComponent).Name+"\")", "sys.stderr=cmd", "sys.stdout=cmd" }; ComponentManager.Execute(String.Join("\r\n", phython_script_for_redirecting_stdout_and_stderr)); }); }
/// <summary> /// Move the Player forward 'steps' blocks. /// </summary> /// <param name="steps"></param> /// <returns></returns> private IEnumerator MoveForward(int steps) { for (int i = 0; i < (steps * 20); i++) { if (i % 20 == 0 || i == 0 && steps > 0) { CorrectPosition(); GetComponent <AudioSource>().Play(); GameObject hit = CommandScript.GetRaycastObject(); bool canContinue = false; if (hit == null) { continue; } switch (hit.transform.tag) { case "Tablet": DialogueScript.GameInformationText("You swoop up a piece of interesting stone on your way past..."); hit.GetComponent <PuzzlePieceScript>().WalkedOverPiece(); canContinue = true; break; case "Hatch": if (LevelScript.ExitOpen) { DialogueScript.GameInformationText("You almost trip and fall into the black void...."); DialogueScript.GameInformationText("Maybe you should try to enter it instead?"); MovementHappening = false; } if (!LevelScript.ExitOpen) { canContinue = true; } break; case "Enemy": case "Door": case "Chest": case "Wall": case "PushableWall": case "Button": case "Torch": DialogueScript.ErrorText("You can't move further that direction"); MetObstacle = true; MovementHappening = false; break; case "Stairs": DialogueScript.ErrorText("That'd make you walk into the ladder."); DialogueScript.ErrorText("Maybe try to climb it?"); MetObstacle = true; MovementHappening = false; break; case "Key": DialogueScript.GameInformationText("You pick up a key as you walk past it."); hit.transform.gameObject.GetComponent <AudioSource>().Play(); hit.transform.position = Vector3.one * 99999f; Destroy(hit.transform.gameObject, 2); Keys += 1; InterfaceScript.InfoKeyText.text = "Your Keys: " + Keys; canContinue = true; break; } if (!canContinue) { yield break; } } transform.Translate(0, 0, 0.1f); yield return(new WaitForEndOfFrame()); } CorrectRotation(); MovementHappening = false; }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { // we can't unstop a service return(false); }
void StartService() { if (_serviceHandle != null) { _log.Debug("Attempted to start service, but it is already started"); return; } string reason; if (!CanStartService(out reason)) { _log.DebugFormat("Attempted to start service, but it is not available: {0}", reason); return; } _log.Debug("Starting supervised service"); var arguments = new CommandScriptStepArguments {_serviceBuilderFactory}; var script = new CommandScript { new CommandScriptStep<CreateServiceCommand>(arguments), new CommandScriptStep<StartServiceCommand>(arguments), }; bool started = Execute(script); if (started) { _serviceHandle = arguments.Get<ServiceHandle>(); } }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { // we can't unstop a service return false; }
// Use this for initialization void Start() { TChar = this.GetComponentInChildren <TestChar>(); comm = this.GetComponent <CommandScript>(); }
public static CommandScript Get() { if (m_Instance == null) m_Instance = (CommandScript)FindObjectOfType(typeof(CommandScript)); return m_Instance; }
bool Execute(CommandScript script) { script.Variables.Add(_settings); script.Variables.Add<HostControl>(this); return ((CommandHandler)this).Handle(script.NextCommandId, script); }
/// <summary> /// Binds a key to a command. /// </summary> /// <param name="key">The key to bind.</param> /// <param name="bind">The command to bind to it (null to unbind).</param> public static void BindKey(Key key, List<CommandEntry> bind, int adj) { Binds.Remove(key); InverseBinds.Remove(key); if (bind != null) { CommandScript script = new CommandScript("_bind_for_" + keystonames[key], bind, adj); script.Debug = DebugMode.MINIMAL; Binds[key] = script; if (script.Created.Entries.Length == 1 && script.Created.Entries[0].Marker == 1) { CommandEntry fixedentry = script.Created.Entries[0].Duplicate(); fixedentry.Marker = 2; CommandScript nscript = new CommandScript("inverse_bind_" + key, new List<CommandEntry>() { fixedentry }) { Debug = DebugMode.MINIMAL }; InverseBinds[key] = nscript; } } Modified = true; }
public override void Execute(CommandQueue queue, CommandEntry entry) { if (entry.Arguments[0].ToString() == "\0CALLBACK") { return; } if (entry.Arguments.Count < 3) { ShowUsage(queue, entry); return; } bool servermode = entry.GetArgument(queue, 0).ToLowerFast() == "server"; string name = entry.GetArgument(queue, 1).ToLowerFast(); string help = entry.GetArgument(queue, 2); if (entry.InnerCommandBlock == null) { queue.HandleError(entry, "Event command invalid: No block follows!"); return; } // NOTE: Commands are compiled! CommandScript script = new CommandScript("ut_command_" + name, entry.InnerCommandBlock, entry.BlockStart, queue.CurrentEntry.Types, true) { Debug = DebugMode.MINIMAL }; UnturnedCustomCommand ucc = new UnturnedCustomCommand(name, help, script); if (servermode) { Commander.commands.Insert(1, ucc); } else { UnturnedFreneticMod.Instance.PlayerCommands.Add(ucc); } if (entry.ShouldShowGood(queue)) { entry.Good(queue, "Registered command!"); } }
void StopService() { _log.Debug("Stopping supervised service"); var unloadArguments = new CommandScriptStepArguments { _serviceHandle, }; var script = new CommandScript { new CommandScriptStep<StopServiceCommand>(unloadArguments), new CommandScriptStep<UnloadServiceCommand>(unloadArguments), }; bool stopped = Execute(script); if (stopped) { _serviceHandle = null; } }
void RestartService() { _log.Debug("Restarting supervised service"); var createArguments = new CommandScriptStepArguments { _serviceBuilderFactory, }; var unloadArguments = new CommandScriptStepArguments { _serviceHandle, }; var script = new CommandScript { new CommandScriptStep<CreateServiceCommand>(createArguments), new CommandScriptStep<StopServiceCommand>(unloadArguments), new CommandScriptStep<StartServiceCommand>(createArguments), new CommandScriptStep<UnloadServiceCommand>(unloadArguments), }; bool restarted = Execute(script); if (restarted) { _serviceHandle = createArguments.Get<ServiceHandle>(); } }
public bool Compensate(CommandScriptStepAudit audit, CommandScript commandScript) { // we can't really reload an AppDomain now, can we? return true; }