コード例 #1
0
        public override void initFiles()
        {
            base.initFiles();
            Folder storageFolder = this.comp.files.root.searchForFolder("IRC");

            if (storageFolder == null)
            {
                storageFolder = new Folder("IRC");
                this.comp.files.root.folders.Add(storageFolder);
            }
            this.System = new IRCSystem(storageFolder);
            for (int index = 0; index < this.StartingMessages.Count; ++index)
            {
                this.System.AddLog(this.StartingMessages[index].Key, this.StartingMessages[index].Value, (string)null);
            }
            string str = this.name + "\nRequireAuth: " + (this.RequiresLogin ? "true" : "false") + "\n" + Utils.convertColorToParseableString(this.ThemeColor) + "\n";

            foreach (KeyValuePair <string, Color> userColor in this.UserColors)
            {
                str = str + userColor.Key + "#%#" + Utils.convertColorToParseableString(userColor.Value) + "\n";
            }
            storageFolder.files.Add(new FileEntry(str.Trim(), "users.cfg"));
            Folder sourceFolder = storageFolder.searchForFolder("runtime");

            if (sourceFolder == null)
            {
                sourceFolder = new Folder("runtime");
                storageFolder.folders.Add(sourceFolder);
            }
            this.DelayedActions = new DelayableActionSystem(sourceFolder, (object)this.os);
        }
コード例 #2
0
ファイル: SACrashComputer.cs プロジェクト: hochladen/Hacknet
        public override void Trigger(object os_obj)
        {
            OS       os        = (OS)os_obj;
            Computer computer1 = Programs.getComputer(os, this.TargetComp);

            if (computer1 == null && !OS.DEBUG_COMMANDS)
            {
                return;
            }
            if ((double)this.Delay <= 0.0)
            {
                computer1.crash(this.CrashSource);
            }
            else
            {
                Computer computer2 = Programs.getComputer(os, this.DelayHost);
                if (computer2 == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer2 + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer2).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #3
0
        public DelayableActionSystem(Folder sourceFolder, object osObj)
        {
            DelayableActionSystem delayableActionSystem = this;

            this.folder = sourceFolder;
            ((OS)osObj).UpdateSubscriptions += (Action <float>)(t => delayableActionSystem.Update(t, (object)(OS)osObj));
        }
コード例 #4
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                if (this.ExeName == "*")
                {
                    this.ExeName = "";
                }
                for (int index = 0; index < os.exes.Count; ++index)
                {
                    if (os.exes[index].name.ToLower().Contains(this.ExeName.ToLower()))
                    {
                        os.exes[index].isExiting = true;
                    }
                }
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #5
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                List <string> stringList = new List <string>((IEnumerable <string>) this.ContentLines.Split(Utils.robustNewlineDelim, StringSplitOptions.None));
                while (stringList.Count < 3)
                {
                    stringList.Add("");
                }
                os.EffectsUpdater.StartScreenBleed(this.TotalDurationSeconds, this.AlertTitle, stringList[0], stringList[1], stringList[2], this.CompleteAction);
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #6
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                Computer computer = Programs.getComputer(os, this.TargetComp);
                if (computer == null)
                {
                    return;
                }
                do
                {
                    os.netMap.visibleNodes.Remove(os.netMap.nodes.IndexOf(computer));
                }while (os.netMap.visibleNodes.Contains(os.netMap.nodes.IndexOf(computer)));
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #7
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                Computer computer = Programs.getComputer(os, this.TargetComp);
                if (computer == null)
                {
                    return;
                }
                for (int index = 0; index < computer.users.Count; ++index)
                {
                    if (computer.users[index].name == this.Username)
                    {
                        UserDetail user = computer.users[index];
                        user.known            = true;
                        computer.users[index] = user;
                    }
                }
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #8
0
ファイル: SAShowNode.cs プロジェクト: hochladen/Hacknet
 public override void Trigger(object os_obj)
 {
     if ((double)this.Delay <= 0.0)
     {
         OS       os       = (OS)os_obj;
         Computer computer = Programs.getComputer(os, this.Target);
         if (computer != null)
         {
             os.netMap.discoverNode(computer);
         }
         else if (OS.DEBUG_COMMANDS)
         {
             os.write("Error revealing node " + this.Target + " : NODE NOT FOUND");
         }
     }
     else
     {
         Computer computer = Programs.getComputer((OS)os_obj, this.DelayHost);
         if (computer == null)
         {
             throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
         }
         float delay = this.Delay;
         this.Delay = -1f;
         DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
     }
 }
コード例 #9
0
ファイル: SAAppendToFile.cs プロジェクト: hochladen/Hacknet
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                Computer computer     = Programs.getComputer(os, this.TargetComp);
                Folder   folderAtPath = Programs.getFolderAtPath(this.TargetFolderpath, os, computer.files.root, true);
                if (folderAtPath == null)
                {
                    return;
                }
                FileEntry fileEntry = folderAtPath.searchForFile(this.TargetFilename);
                fileEntry.data = fileEntry.data + "\n" + this.DataToAdd;
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #10
0
ファイル: SAChangeIP.cs プロジェクト: hochladen/Hacknet
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                Computer computer = Programs.getComputer(os, this.TargetComp);
                if (computer == null)
                {
                    return;
                }
                if (string.IsNullOrWhiteSpace(this.NewIP) || this.NewIP.StartsWith("#RANDOM"))
                {
                    this.NewIP = NetworkMap.generateRandomIP();
                }
                computer.ip = this.NewIP;
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #11
0
        public override void loadInit()
        {
            base.loadInit();
            Folder storageFolder = this.comp.files.root.searchForFolder("IRC");

            this.System         = new IRCSystem(storageFolder);
            this.DelayedActions = new DelayableActionSystem(storageFolder.searchForFolder("runtime"), (object)this.os);
            this.ReloadUserColors();
        }
コード例 #12
0
 public override void Trigger(object os_obj)
 {
     if ((double)this.Delay <= 0.0)
     {
         RunnableConditionalActions.LoadIntoOS(this.Filepath, os_obj);
     }
     else
     {
         Computer computer = Programs.getComputer((OS)os_obj, this.DelayHost);
         if (computer == null)
         {
             throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
         }
         float delay = this.Delay;
         this.Delay = -1f;
         DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
     }
 }
コード例 #13
0
ファイル: SAHideAllNodes.cs プロジェクト: hochladen/Hacknet
 public override void Trigger(object os_obj)
 {
     if ((double)this.Delay <= 0.0)
     {
         ((OS)os_obj).netMap.visibleNodes.Clear();
     }
     else
     {
         Computer computer = Programs.getComputer((OS)os_obj, this.DelayHost);
         if (computer == null)
         {
             throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
         }
         float delay = this.Delay;
         this.Delay = -1f;
         DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
     }
 }
コード例 #14
0
        public override void Trigger(object os_obj)
        {
            Computer computer = Programs.getComputer((OS)os_obj, this.TargetComp);

            if (computer == null)
            {
                throw new NullReferenceException("Computer " + this.TargetComp + " could not be found for SAAddIRCMessage Function, adding message: " + this.Message);
            }
            IRCDaemon daemon1 = computer.getDaemon(typeof(IRCDaemon)) as IRCDaemon;
            IRCSystem ircSystem;

            if (daemon1 != null)
            {
                ircSystem = daemon1.System;
            }
            else
            {
                DLCHubServer daemon2 = computer.getDaemon(typeof(DLCHubServer)) as DLCHubServer;
                if (daemon2 == null)
                {
                    throw new NullReferenceException("Computer " + this.TargetComp + " does not contain an IRC server daemon for SAAddIRCMessage function adding message: " + this.Message);
                }
                ircSystem = daemon2.IRCSystem;
            }
            if ((double)this.Delay <= 0.0)
            {
                if ((double)Math.Abs(this.Delay) < 1.0 / 1000.0)
                {
                    ircSystem.AddLog(this.Author, this.Message, (string)null);
                }
                else
                {
                    DateTime dateTime  = DateTime.Now - TimeSpan.FromSeconds((double)this.Delay);
                    string   timestamp = dateTime.Hour.ToString("00") + ":" + dateTime.Minute.ToString("00");
                    ircSystem.AddLog(this.Author, this.Message, timestamp);
                }
            }
            else
            {
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #15
0
ファイル: SASwitchToTheme.cs プロジェクト: hochladen/Hacknet
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                OSTheme result = OSTheme.Custom;
                if (!Enum.TryParse <OSTheme>(this.ThemePathOrName, out result))
                {
                    result = OSTheme.Custom;
                }
                try
                {
                    os.EffectsUpdater.StartThemeSwitch(this.FlickerInDuration, result, (object)os, result == OSTheme.Custom ? this.ThemePathOrName : (string)null);
                }
                catch (Exception ex)
                {
                    os.write(" ");
                    os.write("---------------------- ");
                    os.write("ERROR LOADING X-SERVER");
                    os.write(ex.ToString());
                    os.write(ex.Message);
                    string filename = ExtensionLoader.ActiveExtensionInfo.FolderPath + "/xserver_error.txt";
                    Utils.writeToFile("x-server load error for theme : " + this.ThemePathOrName + "\r\n." + Utils.GenerateReportFromException(ex), filename);
                    os.write("---------------------- ");
                    os.write("Full report saved to " + filename);
                    os.write("---------------------- ");
                    os.write(" ");
                }
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #16
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                NetmapSortingAlgorithm sortingAlgorithm = NetmapSortingAlgorithm.Grid;
                switch (this.Method.ToLower())
                {
                case "scatter":
                    sortingAlgorithm = NetmapSortingAlgorithm.Scatter;
                    break;

                case "grid":
                    sortingAlgorithm = NetmapSortingAlgorithm.Grid;
                    break;

                case "chaos":
                    sortingAlgorithm = NetmapSortingAlgorithm.Chaos;
                    break;

                case "scangrid":
                case "seqgrid":
                case "sequencegrid":
                case "sequence grid":
                    sortingAlgorithm = NetmapSortingAlgorithm.LockGrid;
                    break;
                }
                os.netMap.SortingAlgorithm = sortingAlgorithm;
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #17
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                os.EffectsUpdater.CancelScreenBleedEffect();
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #18
0
ファイル: SASetLock.cs プロジェクト: hochladen/Hacknet
        public override void Trigger(object os_obj)
        {
            if ((double)this.Delay <= 0.0)
            {
                OS os = (OS)os_obj;
                switch (this.Module.ToLower())
                {
                case "terminal":
                    os.terminal.inputLocked = this.IsLocked;
                    os.terminal.visible     = !this.IsHidden;
                    break;

                case "netmap":
                    os.netMap.inputLocked = this.IsLocked;
                    os.netMap.visible     = !this.IsHidden;
                    break;

                case "ram":
                    os.ram.inputLocked = this.IsLocked;
                    os.ram.visible     = !this.IsHidden;
                    break;

                case "display":
                    os.display.inputLocked = this.IsLocked;
                    os.display.visible     = !this.IsHidden;
                    break;
                }
            }
            else
            {
                Computer computer = Programs.getComputer((OS)os_obj, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #19
0
        public override void Trigger(object os_obj)
        {
            OS os = (OS)os_obj;

            if ((double)this.Delay <= 0.0)
            {
                string flagStartingWith1 = os.Flags.GetFlagStartingWith("_changeAlertIconType:");
                string flagStartingWith2 = os.Flags.GetFlagStartingWith("_changeAlertIconTarget:");
                if (flagStartingWith1 != null)
                {
                    os.Flags.RemoveFlag(flagStartingWith1);
                }
                if (flagStartingWith2 != null)
                {
                    os.Flags.RemoveFlag(flagStartingWith2);
                }
                os.Flags.AddFlag("_changeAlertIconType:" + this.Type);
                os.Flags.AddFlag("_changeAlertIconTarget:" + this.Target);
                if (!os.Flags.HasFlag("_alertIconChanged"))
                {
                    os.Flags.AddFlag("_alertIconChanged");
                }
                SAChangeAlertIcon.UpdateAlertIcon((object)os);
            }
            else
            {
                Computer computer = Programs.getComputer(os, this.DelayHost);
                if (computer == null)
                {
                    throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
                }
                float delay = this.Delay;
                this.Delay = -1f;
                DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
            }
        }
コード例 #20
0
 public override void Trigger(object os_obj)
 {
     if ((double)this.Delay <= 0.0)
     {
         Computer computer1 = Programs.getComputer((OS)os_obj, this.SourceComp);
         Computer computer2 = Programs.getComputer((OS)os_obj, this.TargetComp);
         if (this.RequireLogsOnSource)
         {
             if (computer1 == null)
             {
                 throw new NullReferenceException("Launch Hacker Script Error: Source comp " + this.SourceComp + " does not exist");
             }
             if (computer2 == null)
             {
                 throw new NullReferenceException("Launch Hacker Script Error: Target comp " + this.TargetComp + " does not exist");
             }
             Folder folder1 = computer1.files.root.searchForFolder("log");
             bool   flag1   = false;
             for (int index = 0; index < folder1.files.Count; ++index)
             {
                 if (TrackerCompleteSequence.CompShouldStartTrackerFromLogs(os_obj, computer1, computer2.ip))
                 {
                     flag1 = true;
                     break;
                 }
             }
             if (!flag1)
             {
                 return;
             }
             if (this.RequireSourceIntact)
             {
                 Folder folder2 = computer1.files.root.searchForFolder("sys");
                 bool   flag2   = false;
                 for (int index = 0; index < folder2.files.Count; ++index)
                 {
                     if (folder2.files[index].name == "netcfgx.dll" && folder2.files[index].data.Contains("1") && folder2.files[index].data.Contains("0"))
                     {
                         flag2 = true;
                         break;
                     }
                 }
                 if (!flag2)
                 {
                     return;
                 }
             }
         }
         HackerScriptExecuter.runScript(this.Filepath, os_obj, this.SourceComp, this.TargetComp);
     }
     else
     {
         Computer computer = Programs.getComputer((OS)os_obj, this.DelayHost);
         if (computer == null)
         {
             throw new NullReferenceException("Computer " + (object)computer + " could not be found as DelayHost for Function");
         }
         float delay = this.Delay;
         this.Delay = -1f;
         DelayableActionSystem.FindDelayableActionSystemOnComputer(computer).AddAction((SerializableAction)this, delay);
     }
 }