aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS_TheReturn')
-rw-r--r--ShiftOS_TheReturn/Hacking.cs94
-rw-r--r--ShiftOS_TheReturn/LoginManager.cs5
-rw-r--r--ShiftOS_TheReturn/SaveSystem.cs1
-rw-r--r--ShiftOS_TheReturn/Server.cs4
-rw-r--r--ShiftOS_TheReturn/ShiftOS.Engine.csproj1
5 files changed, 101 insertions, 4 deletions
diff --git a/ShiftOS_TheReturn/Hacking.cs b/ShiftOS_TheReturn/Hacking.cs
new file mode 100644
index 0000000..db47f66
--- /dev/null
+++ b/ShiftOS_TheReturn/Hacking.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ShiftOS.Engine
+{
+ public static class Hacking
+ {
+ private static List<HackableSystem> _activeConnections = new List<HackableSystem>();
+ private static List<Objects.Hackable> Hackables = new List<Objects.Hackable>();
+
+ public static Objects.Hackable[] AvailableToHack
+ {
+ get
+ {
+ return Hackables.Where(x => Shiftorium.UpgradeInstalled(x.Dependencies) && !Shiftorium.UpgradeInstalled(x.ID)).ToArray();
+ }
+ }
+
+
+ public static HackableSystem[] ActiveConnections
+ {
+ get
+ {
+ return _activeConnections.ToArray();
+ }
+ }
+
+ public static HackableSystem[] PwnedConnections
+ {
+ get
+ {
+ return _activeConnections.Where(x => x.IsPwn3d).ToArray();
+ }
+ }
+
+ public static HackableSystem[] TimedConnections
+ {
+ get
+ {
+ return _activeConnections.Where(x => x.Data.ConnectionTimeoutLevel > 0&&!x.IsPwn3d).ToArray();
+ }
+ }
+
+ public static void Initiate()
+ {
+ foreach(var type in ReflectMan.Types.Where(x => x.GetInterfaces().Contains(typeof(IHackableProvider))))
+ {
+ var @interface = (IHackableProvider)Activator.CreateInstance(type, null);
+ Hackables.AddRange(@interface.GetHackables());
+
+ }
+
+ var hackable = Hackables.FirstOrDefault(x => Hackables.Where(y => x.SystemName == y.SystemName).Count() > 1);
+ if(hackable != null)
+ {
+ throw new DataConflictException("Data conflict encountered while initiating the hacking engine. Two or more hackables were found with the same hostname \"" + hackable.SystemName + "\". This is a direct violation of the ShiftOS save system and Shiftorium backend.");
+ }
+ }
+ }
+
+ public class DataConflictException : Exception
+ {
+ public DataConflictException(string message) : base(message)
+ {
+
+ }
+ }
+
+ public interface IHackableProvider
+ {
+ Objects.Hackable[] GetHackables();
+ }
+
+ public class HackableSystem
+ {
+ public Objects.Hackable Data { get; set; }
+ public List<Port> PortsToUnlock { get; set; }
+ public bool FirewallCracked { get; set; }
+ public Objects.ShiftFS.Directory Filesystem { get; set; }
+ public int MillisecondsCountdown { get; set; }
+ public bool IsPwn3d { get; set; }
+ }
+
+ public class Port
+ {
+ public string Name { get; set; }
+ public int Value { get; set; }
+ public int Difficulty { get; set; }
+ public bool Cracked { get; set; }
+ }
+}
diff --git a/ShiftOS_TheReturn/LoginManager.cs b/ShiftOS_TheReturn/LoginManager.cs
index d326f2c..de30cf1 100644
--- a/ShiftOS_TheReturn/LoginManager.cs
+++ b/ShiftOS_TheReturn/LoginManager.cs
@@ -35,7 +35,8 @@ namespace ShiftOS.Engine
}
}
- public static event Action<ClientSave> LoginComplete;
+ [Obsolete("Old code.")]
+ public static event Action<dynamic> LoginComplete;
}
/// <summary>
@@ -57,7 +58,7 @@ namespace ShiftOS.Engine
/// <summary>
/// Occurs when the login is complete.
/// </summary>
- event Action<ClientSave> LoginComplete;
+ event Action<dynamic> LoginComplete;
diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs
index 292af41..99d1868 100644
--- a/ShiftOS_TheReturn/SaveSystem.cs
+++ b/ShiftOS_TheReturn/SaveSystem.cs
@@ -90,7 +90,6 @@ namespace ShiftOS.Engine
{
var root = new ShiftOS.Objects.ShiftFS.Directory();
root.Name = "System";
- root.permissions = UserPermissions.Guest;
System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root));
}
diff --git a/ShiftOS_TheReturn/Server.cs b/ShiftOS_TheReturn/Server.cs
index ddbd15b..6edef9e 100644
--- a/ShiftOS_TheReturn/Server.cs
+++ b/ShiftOS_TheReturn/Server.cs
@@ -7,15 +7,17 @@ using ShiftOS.Objects;
namespace ShiftOS.Engine
{
+ [Obsolete("Old code.")]
public interface Server
{
/// <summary>
/// Occurs when someone sends a message to the server.
/// </summary>
/// <param name="msg">The message from the client.</param>
- void MessageReceived(ServerMessage msg);
+ void MessageReceived(dynamic msg);
}
+ [Obsolete("Old code.")]
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)]
public class ServerAttribute : Attribute
{
diff --git a/ShiftOS_TheReturn/ShiftOS.Engine.csproj b/ShiftOS_TheReturn/ShiftOS.Engine.csproj
index 02a5eeb..27d54cc 100644
--- a/ShiftOS_TheReturn/ShiftOS.Engine.csproj
+++ b/ShiftOS_TheReturn/ShiftOS.Engine.csproj
@@ -133,6 +133,7 @@
</Compile>
<Compile Include="Desktop.cs" />
<Compile Include="FileSkimmerBackend.cs" />
+ <Compile Include="Hacking.cs" />
<Compile Include="IFileHandler.cs" />
<Compile Include="Infobox.cs" />
<Compile Include="IShiftOSWindow.cs" />