public static SerializableAction DeserializeFromReader(XmlReader rdr) { SAChangeAlertIcon saChangeAlertIcon = new SAChangeAlertIcon(); if (rdr.MoveToAttribute("Delay")) { saChangeAlertIcon.Delay = rdr.ReadContentAsFloat(); } if (rdr.MoveToAttribute("DelayHost")) { saChangeAlertIcon.DelayHost = rdr.ReadContentAsString(); } if (rdr.MoveToAttribute("Type")) { saChangeAlertIcon.Type = rdr.ReadContentAsString().ToLower(); } if (rdr.MoveToAttribute("Target")) { saChangeAlertIcon.Target = rdr.ReadContentAsString(); } if (saChangeAlertIcon.Type == null) { throw new FormatException("Type tag for ChangeAlertIconAction not found! Make sure you have written it correctly (capital T)!"); } if (saChangeAlertIcon.Type != "mail" && saChangeAlertIcon.Type != "irc" && saChangeAlertIcon.Type != "board" && saChangeAlertIcon.Type != "irchub") { throw new FormatException("Provided type " + saChangeAlertIcon.Type + " for ChangeAlertIconAction is invalid! Accepted types: mail, irc, board"); } if (saChangeAlertIcon.Type != "mail" && !DLC1SessionUpgrader.HasDLC1Installed) { throw new NotSupportedException("Changing alert icon to something other than mail requires the Hacknet Labyrinths DLC to be installed."); } return((SerializableAction)saChangeAlertIcon); }
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); } }