forked from JakeStanger/csm-exportelectricity
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExportable.cs
More file actions
294 lines (248 loc) · 7.99 KB
/
Exportable.cs
File metadata and controls
294 lines (248 loc) · 7.99 KB
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
using System;
namespace Exportable
{
public static class Ids
{
public const string CREMATION = "C";
public const string ELEMENTARY = "ED1";
public const string HIGH_SCHOOL = "ED2";
public const string UNIVERSITY = "ED3";
public const string ELECTRICITY = "E";
public const string HEALTH = "H";
public const string HEAT = "HT";
public const string INCINERATION = "I";
public const string JAIL = "J";
public const string SEWAGE = "S";
public const string WATER = "W";
}
abstract public class Exportable
{
public string Id;
public string Description;
public double LastWeeklyEarning;
private bool Enabled;
private ExportableManager Expm;
private double Rate;
public Exportable(ExportableManager inExpm, string inId, string inDescription, double inRate)
{
Id = inId;
Description = inDescription;
Enabled = false;
Rate = inRate;
Expm = inExpm;
LastWeeklyEarning = 0.0;
Expm.AddExportable(this);
}
public void Log(String msg)
{
ExportElectricityMod.Debugger.Write(msg);
}
public void SetEnabled(bool e)
{
SetEnabled(e, true);
}
public void SetEnabled(bool e, bool doSave)
{
Enabled = e;
if (doSave)
{
Expm.StoreSettings();
}
}
public bool GetEnabled()
{
return Enabled;
}
public double CalculateIncome(District d, double weekPortion)
{
double capacity = 0.0;
double consumption = 0.0;
double income = 0.0;
double incomeShown = 0.0;
capacity = ((double)this.GetCapacity(d));
consumption = ((double)this.GetConsumption(d));
if (capacity > consumption)
{
incomeShown = weekPortion * Rate * (capacity - consumption);
// 100.0 because money is represented as cents
income = 100.0 * incomeShown;
}
Log(Id + " capacity " + capacity.ToString() + " consumption " + consumption.ToString() + " income " + incomeShown.ToString());
LastWeeklyEarning = income / weekPortion;
return income;
}
abstract public double GetCapacity(District d);
abstract public double GetConsumption(District d);
}
public class ExportableCremation : Exportable
{
public ExportableCremation(ExportableManager man) : base(man, Ids.CREMATION, "Cremation", 0.0)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return d.GetCremateCapacity();
}
public override double GetConsumption(District d)
{
// TODO - figure out how these relate, also, how are cemeteries involved?
d.GetDeadAmount();
d.GetDeadCapacity();
return 0.0;
}
}
public class ExportableElementary : Exportable
{
public ExportableElementary(ExportableManager man) : base(man, Ids.ELEMENTARY, "Education - Elementary", 0.43)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetEducation1Capacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetEducation1Need();
}
}
public class ExportableHighSchool : Exportable
{
public ExportableHighSchool(ExportableManager man) : base(man, Ids.HIGH_SCHOOL, "Education - High School", 0.45)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetEducation2Capacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetEducation2Need();
}
}
public class ExportableUniversity : Exportable
{
public ExportableUniversity(ExportableManager man) : base(man, Ids.UNIVERSITY, "Education - University", 0.34)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetEducation3Capacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetEducation3Need();
}
}
public class ExportableElectricity : Exportable
{
public ExportableElectricity(ExportableManager man) : base(man, Ids.ELECTRICITY, "Electricity", 0.005)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetElectricityCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetElectricityConsumption();
}
}
public class ExportableHealth : Exportable
{
public ExportableHealth(ExportableManager man) : base(man, Ids.HEALTH, "Health Care", 3.8)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetHealCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetSickCount();
}
}
public class ExportableHeat : Exportable
{
public ExportableHeat(ExportableManager man) : base(man, Ids.HEAT, "Heat", 0.0048)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetHeatingCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetHeatingConsumption();
}
}
public class ExportableIncineration : Exportable
{
public ExportableIncineration(ExportableManager man) : base(man, Ids.INCINERATION, "Incineration (Garbage)", 0.0)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetIncinerationCapacity();
}
public override double GetConsumption(District d)
{
// TODO - figure out how these relate, also, how are landfills involved?
d.GetGarbageAmount();
d.GetGarbageCapacity();
return 0.0;
}
}
public class ExportableJail : Exportable
{
public ExportableJail(ExportableManager man) : base(man, Ids.JAIL, "Jail Space", 3.0)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetCriminalCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetCriminalAmount();
}
}
public class ExportableSewage : Exportable
{
public ExportableSewage(ExportableManager man) : base(man, Ids.SEWAGE, "Sewage Treatment", 0.0032)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetSewageCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetSewageAccumulation();
}
}
public class ExportableWater : Exportable
{
public ExportableWater(ExportableManager man) : base(man, Ids.WATER, "Water", 0.0016)
{
// add more here if needed
}
public override double GetCapacity(District d)
{
return (double)d.GetWaterCapacity();
}
public override double GetConsumption(District d)
{
return (double)d.GetWaterConsumption();
}
}
}