From e65e99578d8f434d83412d4d5130f18c474ab40d Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 29 Jun 2017 09:14:39 -0400 Subject: Implement the Virus Scanner. --- ShiftOS_TheReturn/VirusManager.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'ShiftOS_TheReturn/VirusManager.cs') diff --git a/ShiftOS_TheReturn/VirusManager.cs b/ShiftOS_TheReturn/VirusManager.cs index 56767e6..f4a7fc6 100644 --- a/ShiftOS_TheReturn/VirusManager.cs +++ b/ShiftOS_TheReturn/VirusManager.cs @@ -96,5 +96,25 @@ namespace ShiftOS.Engine throw new Exception("Cannot create virus."); } + + public static void Disinfect(string id) + { + foreach(var virus in ActiveInfections.ToArray()) + { + var type = virus.GetType(); + var attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is VirusAttribute) as VirusAttribute; + if(attrib != null) + { + if (attrib.ID == id) + { + ActiveInfections.Remove(virus); + var inf = SaveSystem.CurrentSave.ViralInfections.FirstOrDefault(x => x.ID == id); + if (inf != null) + SaveSystem.CurrentSave.ViralInfections.Remove(inf); + virus.Disinfect(); + } + } + } + } } } -- cgit v1.2.3