From c7061e8e457a04a9dcecfd7eeb0db7d9e753ee31 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 30 Jun 2017 11:04:27 -0400 Subject: file-infecting viruses --- ShiftOS_TheReturn/VirusManager.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/VirusManager.cs b/ShiftOS_TheReturn/VirusManager.cs index 31152cc..b5c50b7 100644 --- a/ShiftOS_TheReturn/VirusManager.cs +++ b/ShiftOS_TheReturn/VirusManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; using ShiftOS.Objects; namespace ShiftOS.Engine @@ -13,8 +14,28 @@ namespace ShiftOS.Engine public static void Init() { + Desktop.InvokeOnWorkerThread(() => { + ShiftOS.Objects.ShiftFS.Utils.FileRead += (path) => + { + Desktop.InvokeOnWorkerThread(() => + { + var headerData = Objects.ShiftFS.Utils.GetHeaderText(path); + if(headerData != null) + { + try + { + var viruses = JsonConvert.DeserializeObject>(headerData); + foreach(var virus in viruses) + { + Infect(virus.ID, virus.ThreatLevel); + } + } + catch { } + } + }); + }; ActiveInfections = new List(); if (SaveSystem.CurrentSave.ViralInfections == null) SaveSystem.CurrentSave.ViralInfections = new List(); -- cgit v1.2.3