-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFaction.cs
187 lines (172 loc) · 4.75 KB
/
Faction.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
using System;
using System.Xml;
using Hacknet.Factions;
namespace Hacknet
{
// Token: 0x02000074 RID: 116
public class Faction
{
// Token: 0x06000244 RID: 580 RVA: 0x00021338 File Offset: 0x0001F538
public Faction(string _name, int _neededValue)
{
this.playerValue = 0;
this.neededValue = _neededValue;
this.name = _name;
}
// Token: 0x06000245 RID: 581 RVA: 0x00021388 File Offset: 0x0001F588
public virtual void addValue(int value, object os)
{
int num = this.playerValue;
this.playerValue += value;
if (this.playerValue >= this.neededValue && !this.playerHasPassedValue)
{
this.playerPassedValue(os);
}
}
// Token: 0x06000246 RID: 582 RVA: 0x000213D4 File Offset: 0x0001F5D4
public void contractAbbandoned(object osIn)
{
OS os = (OS)osIn;
if (this.PlayerLosesValueOnAbandon)
{
this.playerValue -= 10;
if (this.playerValue < 0)
{
this.playerValue = 0;
}
}
string subject = LocaleTerms.Loc("Contract Abandoned");
string body = string.Format(Utils.readEntireFile("Content/LocPost/ContractAbandonedEmail.txt"), this.getRank(), this.getMaxRank(), this.name);
string sender = this.name + " ReplyBot";
string mail = MailServer.generateEmail(subject, body, sender);
MailServer mailServer = (MailServer)os.netMap.mailServer.getDaemon(typeof(MailServer));
mailServer.addMail(mail, os.defaultUser.name);
}
// Token: 0x06000247 RID: 583 RVA: 0x000214AC File Offset: 0x0001F6AC
public int getRank()
{
float num = Math.Min((float)this.playerValue, (float)this.neededValue);
return Math.Max(1, Math.Abs((int)((1f - num / (float)this.neededValue) * (float)this.getMaxRank())));
}
// Token: 0x06000248 RID: 584 RVA: 0x000214F8 File Offset: 0x0001F6F8
public virtual string getSaveString()
{
string text = "Faction";
if (this is EntropyFaction)
{
text = "EntropyFaction";
}
if (this is HubFaction)
{
text = "HubFaction";
}
if (this is CustomFaction)
{
text = "CustomFaction";
}
return string.Concat(new object[]
{
"<",
text,
" name=\"",
this.name,
"\" id=\"",
this.idName,
"\" neededVal=\"",
this.neededValue,
"\" playerVal=\"",
this.playerValue,
"\" playerHasPassed=\"",
this.playerHasPassedValue,
"\" />"
});
}
// Token: 0x06000249 RID: 585 RVA: 0x000215DC File Offset: 0x0001F7DC
public int getMaxRank()
{
return 100;
}
// Token: 0x0600024A RID: 586 RVA: 0x000215F0 File Offset: 0x0001F7F0
public virtual void playerPassedValue(object os)
{
this.playerHasPassedValue = true;
}
// Token: 0x0600024B RID: 587 RVA: 0x000215FC File Offset: 0x0001F7FC
public static Faction loadFromSave(XmlReader xmlRdr)
{
string text = "UNKNOWN";
string id = "";
bool playerHasPassed = false;
int num = 100;
int playerVal = 0;
while (xmlRdr.Name != "Faction" && xmlRdr.Name != "CustomFaction" && xmlRdr.Name != "EntropyFaction" && xmlRdr.Name != "HubFaction")
{
xmlRdr.Read();
}
string text2 = xmlRdr.Name;
if (xmlRdr.MoveToAttribute("name"))
{
text = xmlRdr.ReadContentAsString();
}
if (xmlRdr.MoveToAttribute("id"))
{
id = xmlRdr.ReadContentAsString();
}
if (xmlRdr.MoveToAttribute("neededVal"))
{
num = xmlRdr.ReadContentAsInt();
}
if (xmlRdr.MoveToAttribute("playerVal"))
{
playerVal = xmlRdr.ReadContentAsInt();
}
if (xmlRdr.MoveToAttribute("playerHasPassed"))
{
playerHasPassed = (xmlRdr.ReadContentAsString().ToLower() == "true");
}
string text3 = text2;
Faction faction;
if (text3 != null && !(text3 == "Faction"))
{
if (text3 == "HubFaction")
{
faction = new HubFaction(text, num);
goto IL_182;
}
if (text3 == "EntropyFaction")
{
faction = new EntropyFaction(text, num);
goto IL_182;
}
if (text3 == "CustomFaction")
{
faction = CustomFaction.DeserializeFromXmlReader(xmlRdr, text, id, playerVal, playerHasPassed);
goto IL_182;
}
}
faction = new Faction(text, num);
IL_182:
faction.playerValue = playerVal;
faction.idName = id;
faction.playerHasPassedValue = playerHasPassed;
return faction;
}
// Token: 0x0600024C RID: 588 RVA: 0x000217AC File Offset: 0x0001F9AC
public bool valuePassedPoint(int oldValue, int neededValue)
{
return this.playerValue >= neededValue && oldValue < neededValue;
}
// Token: 0x040002BF RID: 703
public int playerValue;
// Token: 0x040002C0 RID: 704
public int neededValue;
// Token: 0x040002C1 RID: 705
public string name = "unknown";
// Token: 0x040002C2 RID: 706
public string idName = "";
// Token: 0x040002C3 RID: 707
public bool playerHasPassedValue = false;
// Token: 0x040002C4 RID: 708
public bool PlayerLosesValueOnAbandon = false;
}
}