forked from cbluoss/OpenHacknet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Daemon.cs
71 lines (61 loc) · 1.7 KB
/
Daemon.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Hacknet
{
internal class Daemon
{
public Computer comp;
public bool isListed;
public string name;
public OS os;
public Daemon(Computer computer, string serviceName, OS opSystem)
{
name = serviceName;
isListed = true;
comp = computer;
os = opSystem;
}
public virtual void initFiles()
{
}
public virtual void draw(Rectangle bounds, SpriteBatch sb)
{
}
public virtual void navigatedTo()
{
}
public virtual void userAdded(string name, string pass, byte type)
{
}
public virtual string getSaveString()
{
return "";
}
public virtual void loadInit()
{
}
public static bool validUser(byte type)
{
if (type != 1)
return type == 0;
return true;
}
public void registerAsDefaultBootDaemon()
{
if (!comp.AllowsDefaultBootModule)
return;
var fileEntry =
comp.files.root.searchForFolder("sys")
.searchForFile(ComputerTypeInfo.getDefaultBootDaemonFilename(this));
if (fileEntry != null)
{
if (!(fileEntry.data != "[Locked]"))
return;
fileEntry.data = name;
}
else
comp.files.root.searchForFolder("sys")
.files.Add(new FileEntry(name, ComputerTypeInfo.getDefaultBootDaemonFilename(this)));
}
}
}