mirror of
https://git.alee14.me/shiftos-archive/ShiftOS_TheReturn.git
synced 2025-01-22 18:02:16 +00:00
Fix virus manager init bug
This commit is contained in:
parent
27264a559d
commit
a15fc8c28a
1 changed files with 18 additions and 18 deletions
|
@ -13,24 +13,27 @@ namespace ShiftOS.Engine
|
|||
|
||||
public static void Init()
|
||||
{
|
||||
ActiveInfections = new List<IVirus>();
|
||||
if (SaveSystem.CurrentSave.ViralInfections == null)
|
||||
SaveSystem.CurrentSave.ViralInfections = new List<ViralInfection>();
|
||||
foreach(var virusdata in SaveSystem.CurrentSave.ViralInfections)
|
||||
Desktop.InvokeOnWorkerThread(() =>
|
||||
{
|
||||
var virus = CreateVirus(virusdata.ID, virusdata.ThreatLevel);
|
||||
var existing = ActiveInfections.FirstOrDefault(x => x.GetType() == virus.GetType());
|
||||
if(existing != null)
|
||||
ActiveInfections = new List<IVirus>();
|
||||
if (SaveSystem.CurrentSave.ViralInfections == null)
|
||||
SaveSystem.CurrentSave.ViralInfections = new List<ViralInfection>();
|
||||
foreach (var virusdata in SaveSystem.CurrentSave.ViralInfections)
|
||||
{
|
||||
var eIndex = ActiveInfections.IndexOf(existing);
|
||||
ActiveInfections[eIndex] = virus;
|
||||
existing.Disinfect();
|
||||
var virus = CreateVirus(virusdata.ID, virusdata.ThreatLevel);
|
||||
var existing = ActiveInfections.FirstOrDefault(x => x.GetType() == virus.GetType());
|
||||
if (existing != null)
|
||||
{
|
||||
var eIndex = ActiveInfections.IndexOf(existing);
|
||||
ActiveInfections[eIndex] = virus;
|
||||
existing.Disinfect();
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveInfections.Add(virus);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveInfections.Add(virus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Infect(string id, int threatlevel)
|
||||
|
@ -90,9 +93,6 @@ namespace ShiftOS.Engine
|
|||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
throw new Exception("Cannot create virus.");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue