file-infecting viruses
This commit is contained in:
parent
a1eb4b6699
commit
c7061e8e45
2 changed files with 23 additions and 2 deletions
|
@ -170,7 +170,7 @@ namespace ShiftOS.Objects.ShiftFS
|
|||
public static event Action<string> DirectoryDeleted;
|
||||
public static event Action<string> FileWritten;
|
||||
public static event Action<string> FileDeleted;
|
||||
|
||||
public static event Action<string> FileRead;
|
||||
|
||||
public static void CreateDirectory(string path)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ namespace ShiftOS.Objects.ShiftFS
|
|||
dir = dir.FindDirectoryByName(pathlist[i]);
|
||||
}
|
||||
var file = dir.FindFileByName(pathlist[pathlist.Length - 1]);
|
||||
|
||||
FileRead?.Invoke(path);
|
||||
return file.Data;
|
||||
|
||||
}
|
||||
|
|
|
@ -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<List<ViralInfection>>(headerData);
|
||||
foreach(var virus in viruses)
|
||||
{
|
||||
Infect(virus.ID, virus.ThreatLevel);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
});
|
||||
};
|
||||
ActiveInfections = new List<IVirus>();
|
||||
if (SaveSystem.CurrentSave.ViralInfections == null)
|
||||
SaveSystem.CurrentSave.ViralInfections = new List<ViralInfection>();
|
||||
|
|
Reference in a new issue