// Hook location : ProgramRunner.ExecuteProgram() public static bool onCommandSent(out bool disconnects, ref bool returnFlag, object osObj, string[] arguments) { var os = osObj as OS; var commandSentEvent = new Event.CommandSentEvent(os, arguments) { Disconnects = true }; commandSentEvent.CallEvent(); disconnects = commandSentEvent.Disconnects; returnFlag = disconnects; if (commandSentEvent.IsCancelled) { if (os.commandInvalid) { os.commandInvalid = false; } else if (commandSentEvent.StateChange != CommandDisplayStateChange.None) { var state = commandSentEvent.State; os.display.command = state; os.display.commandArgs = (state + " " + string.Join(" ", commandSentEvent.Arguments.Skip(1).ToArray())).Split(' '); os.display.typeChanged(); } return(true); } disconnects = false; return(false); }
// Hook location : ProgramRunner.ExecuteProgram() public static bool onCommandSent(out bool disconnects, object osObj, string[] arguments) { var os = osObj as Hacknet.OS; var commandSentEvent = new Event.CommandSentEvent(os, arguments); commandSentEvent.CallEvent(); if (commandSentEvent.IsCancelled) { disconnects = commandSentEvent.Disconnects; return(true); } disconnects = commandSentEvent.Disconnects; return(false); }
public static bool onCommandSent(out bool disconnects, ref bool returnFlag, object osObj, string[] arguments) { var os = osObj as OS; commandSentEvent = new Event.CommandSentEvent(os, arguments) { Disconnects = true }; var exceptions = commandSentEvent.CallEvent(); if (exceptions.Count > 0) { foreach (var pair in exceptions) { os.WriteLine("Command Listener Method '{0}' failed with: {1}", pair.Key, pair.Value); } } disconnects = commandSentEvent.Disconnects; returnFlag = disconnects; if (commandSentEvent.IsCancelled) { var commandFinishedEvent = new Event.CommandFinishedEvent(commandSentEvent); commandFinishedEvent.CallEvent(); disconnects = commandFinishedEvent.SentEvent.Disconnects; returnFlag = disconnects; if (os.commandInvalid) { os.commandInvalid = false; } else if (commandSentEvent.StateChange != CommandDisplayStateChange.None) { var state = commandSentEvent.State; os.display.command = state; os.display.commandArgs = (state + " " + string.Join(" ", commandSentEvent.Arguments.Skip(1).ToArray())).Split(' '); os.display.typeChanged(); } return(true); } disconnects = false; return(false); }
public CommandFinishedEvent(CommandSentEvent e) : base(e.OS, e.Arguments.ToArray()) { SentEvent = e; }