-
Notifications
You must be signed in to change notification settings - Fork 1
/
MapObj.cs
400 lines (359 loc) · 11.6 KB
/
MapObj.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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HazeronMapper
{
[Serializable]
public class Galaxy
{
List<SectorObj> Sectors_list = new List<SectorObj>();
List<WormHoleObj> Wormholes_list = new List<WormHoleObj>();
Dictionary<string, SectorObj> Sectors_dictionary = new Dictionary<string, SectorObj>();
public Galaxy()
{
}
public void add_sector(string location, SectorObj sector)
{
if (!this.Sectors_dictionary.Keys.Contains(location))
{
//this.Sectors_list.Add(sector);
this.Sectors_dictionary.Add(location, sector);
}
else
{
//this.Sectors_dictionary[location] = sector;
}
}
/// <summary>
/// forces an update of the galaxy sectors list from the dictionary_list
/// </summary>
/// <param name="depth">depth of iteration, default 0, ie depth = 1 will update the sectors systemlists</param>
public void listupdate_sectors(int depth = 0)
{
List<SectorObj> sectors_list = new List<SectorObj>();
foreach (KeyValuePair<string, SectorObj> sector in this.Sectors_dictionary)
{
if (depth > 0)
{
sector.Value.listupdate_systems(depth - 1);
}
sectors_list.Add(sector.Value);
}
this.Sectors_list = sectors_list;
}
public List<SectorObj> sectors_list
{
get { return this.Sectors_list; }
}
public Dictionary<string, SectorObj> sectors_dictionary
{
get { return this.Sectors_dictionary; }
}
/// <summary>
/// creates and returns dictionary by iterating through the galaxy.sectors_dictonary and sectors.systems_dictionary
/// </summary>
/// <returns></returns>
public Dictionary<string, SystemObj> systems_dictionary()
{
Dictionary<string, SystemObj> systemdict = new Dictionary<string, SystemObj>();
foreach (KeyValuePair<string, SectorObj> kvp_sector in this.sectors_dictionary)
{
foreach (KeyValuePair<string,SystemObj> kvp_system in kvp_sector.Value.systems_dictionary)
{
if (!systemdict.ContainsKey(kvp_system.Key))
{
systemdict.Add(kvp_system.Key, kvp_system.Value);
}
}
}
return systemdict;
}
/// <summary>
/// creates a list of systems by itterating through the galaxy.sectors_list and sectors.systems_list - fix this to just add those lists together... or creating it from the dictionary.
/// </summary>
/// <returns></returns>
/// <remarks>consider calling galaxy.listupdate_sectors(1) first. may be slow. or using galaxy.system_dictionary</remarks>
public List<SystemObj> systems_list()
{
List<SystemObj> syslist = new List<SystemObj>();
foreach (SectorObj sector in this.Sectors_list)
{
foreach (SystemObj system in sector.systems_list)
{
syslist.Add(system);
}
}
return syslist;
}
/// <summary>
/// this should not be here in galaxy. move later.
/// </summary>
/// <param name="wormhole"></param>
public void add_WH(WormHoleObj wormhole)
{
if (!this.Wormholes_list.Contains(wormhole))
{
this.Wormholes_list.Add(wormhole);
}
}
public List<WormHoleObj> wormholes
{
get { return this.Wormholes_list; }
}
}
[Serializable]
public class SectorObj
{
string SectorName;
//List<int> sectorLoc = new List<int>();
string sectorlocS;
List<SystemObj> Systems_list = new List<SystemObj>();
Dictionary<string, SystemObj> Systems_dictionary = new Dictionary<string, SystemObj>();
public SectorObj(string sectorloc, string SectorName, Galaxy galaxy)
{
this.sectorlocS = sectorloc;
this.SectorName = SectorName;
galaxy.add_sector(sectorlocS, this);
}
public void add_system(string systemloc, SystemObj system)
{
if (!system.sector.Systems_dictionary.Keys.Contains(systemloc))
{
system.sector.Systems_dictionary.Add(systemloc, system);
}
else
{
//system.sector.Systems_dictionary[systemloc] = system;
}
}
public string name
{
get { return this.SectorName; }
}
public string location
{
get { return this.sectorlocS; }
}
/// <summary>
/// forces an update of this sectors system list
/// </summary>
public void listupdate_systems(int depth = 0)
{
List<SystemObj> systems_list = new List<SystemObj>();
foreach (KeyValuePair<string, SystemObj> system in this.Systems_dictionary)
{
systems_list.Add(system.Value);
}
this.Systems_list = systems_list;
}
/// <summary>
/// returns list of systems for this sector, note: no garentee the list is complete, use listupdate_systems first if unsure.
/// </summary>
public List<SystemObj> systems_list
{
get { return this.Systems_list; }
}
public Dictionary<string, SystemObj> systems_dictionary
{
get { return this.Systems_dictionary; }
}
public override string ToString()
{
return this.SectorName;
}
}
[Serializable]
public class SystemObj
{
string sysName;
List<int> sysLoc = new List<int>();
string sysLocS;
SectorObj parentSector;
//UserControl_System systemicon;
List<WormHoleObj> Wormholes_list = new List<WormHoleObj>();
List<SystemBodyObj> systemBodys_list = new List<SystemBodyObj>();
string sysNotes;
System.Drawing.Point sysMapLoc;
public SystemObj(string sysloc, string systemname, SectorObj sector)
{
this.sysLocS = sysloc;
this.sysName = systemname;
this.parentSector = sector;
sector.add_system(sysloc, this);
}
public void add_WH(WormHoleObj WHName)
{
if (!this.Wormholes_list.Contains(WHName))
{
this.Wormholes_list.Add(WHName);
}
}
public string name
{
get { return this.sysName; }
}
//public string sector
//{
// get { return this.sectorName.name; }
//}
public SectorObj sector
{
get { return this.parentSector; }
}
public string location
{
get { return this.sysLocS; }
}
//public UserControl_System usrctrl
//{
// get { return this.systemicon; }
// set { this.systemicon = value; }
//}
//public List<int> loc
//{
// get { return this.sysLoc; }
// set { this.sysLoc = value; }
//}
public string notes
{
get { return this.sysNotes; }
set { this.sysNotes = value; }
}
public List<WormHoleObj> Wormholes
{
get { return this.Wormholes_list; }
}
public System.Drawing.Point maploc
{
get { return this.sysMapLoc; }
set { this.sysMapLoc = value; }
}
public override string ToString()
{
return this.sysName;
}
}
[Serializable]
public class SystemBodyObj
{
string name;
string orbzone;
SystemObj system;
int diameter;
string atmosphere;
string ocean;
List<ResourceZoneObj> resourceZoneList = new List<ResourceZoneObj>();
public SystemBodyObj(string name, string orbitzone, SystemObj system)
{
this.name = name;
this.orbzone = orbitzone;
this.system = system;
}
public void add_resourcezone(ResourceZoneObj zone)
{
if (!this.resourceZoneList.Contains(zone))// fix this. this needs to check the zone num.
{
this.resourceZoneList.Add(zone);
}
}
}
[Serializable]
public class ResourceZoneObj
{
int zoneNum;
SystemBodyObj parentBody;
List<ResourceObj> resourcesList = new List<ResourceObj>();
public ResourceZoneObj(int zoneNum, SystemBodyObj sysbody)
{
this.zoneNum = zoneNum;
this.parentBody = sysbody;
}
public void add_resource(ResourceObj resource)
{
if (!this.resourcesList.Contains(resource))
{
this.resourcesList.Add(resource);
}
}
public List<ResourceObj> resource_list
{
get { return this.resourcesList; }
}
}
[Serializable]
public class ResourceObj
{
string resource;
int quality;
int amount;
ResourceZoneObj parentRzone;
public ResourceObj(string resource, int quality, int amount, ResourceZoneObj rzone)
{
this.resource = resource;
this.quality = quality;
this.amount = amount;
this.parentRzone = rzone;
}
}
[Serializable]
public class WormHoleObj
{
string WHName;
bool WHPolarity = false; //false = negitive true = positive
List<SystemObj> SystemsLinked = new List<SystemObj>(2);
public WormHoleObj(string WHName, bool WHPolarity, SystemObj System, Galaxy galaxy)
{
this.WHName = WHName;
this.WHPolarity = WHPolarity;
makelink(System);
//galaxy.add_WH(this);
System.add_WH(this);
}
public void makelink(SystemObj System1, SystemObj System2 = null)
{
if (!this.SystemsLinked.Contains(System1))
{
this.SystemsLinked.Add(System1);
}
if (System2 != null)
{
if (!this.SystemsLinked.Contains(System2))
{
this.SystemsLinked.Add(System2);
}
}
}
public bool polarity
{
get { return WHPolarity; }
}
/// <summary>
///
/// </summary>
/// <param name="thissystem"></param>
/// <returns>the sytem that 'thissystem' links to</returns>
public SystemObj getlink(SystemObj thissystem)
{
SystemObj linkedsys;
if (this.SystemsLinked[0] == thissystem)
{
linkedsys = SystemsLinked[1];
}
else if (this.SystemsLinked[1] == thissystem)
{
linkedsys = SystemsLinked[0];
}
else
{
throw new System.ArgumentException("System does not exsist in this link");
}
return linkedsys;
}
public List<SystemObj> getlinks
{
get { return SystemsLinked; }
}
}
}