-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShipTemplate.cs
264 lines (233 loc) · 6.96 KB
/
ShipTemplate.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
/*******************************************************************************
*
* Space Trader for Windows 1.00
*
* Copyright (C) 2016 Keith Banner, All Rights Reserved
*
* Port to Windows by David Pierron & Jay French
* Original coding by Pieter Spronck, Sam Anderson, Samuel Goldstein, Matt Lee
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* If you'd like a copy of the GNU General Public License, go to
* http://www.gnu.org/copyleft/gpl.html.
*
* You can contact the author at [email protected]
*
******************************************************************************/
using System;
using System.Collections;
using System.Drawing;
namespace SpaceTrader
{
public class ShipTemplate : STSerializableObject, IComparable
{
#region Member Variables
private string _name = null;
private Size _size = Size.Tiny;
private int _imageIndex = (int)ShipType.Custom;
private int _cargoBays = 0;
private int _weaponSlots = 0;
private int _shieldSlots = 0;
private int _gadgetSlots = 0;
private int _crewQuarters = 0;
private int _fuelTanks = 0;
private int _hullStrength = 0;
private Image[] _images = null;
#endregion
#region Methods
public ShipTemplate(Size size, string name)
{
_name = name;
_size = size;
_images = Game.CurrentGame.ParentWindow.CustomShipImages;
}
public ShipTemplate(ShipSpec spec, string name)
{
_name = name;
_size = spec.Size;
_imageIndex = spec.ImageIndex;
_cargoBays = spec.CargoBays;
_weaponSlots = spec.WeaponSlots;
_shieldSlots = spec.ShieldSlots;
_gadgetSlots = spec.GadgetSlots;
_crewQuarters = spec.CrewQuarters;
_fuelTanks = spec.FuelTanks;
_hullStrength = spec.HullStrength;
if (ImageIndex == Consts.ShipImgUseDefault)
_images = Game.CurrentGame.ParentWindow.CustomShipImages;
}
public ShipTemplate(Hashtable hash)
{
_name = (string)GetValueFromHash(hash, "_name", _name);
_size = (Size)GetValueFromHash(hash, "_size", _size);
_imageIndex = (int)GetValueFromHash(hash, "_imageIndex", _imageIndex);
_cargoBays = (int)GetValueFromHash(hash, "_cargoBays", _cargoBays);
_weaponSlots = (int)GetValueFromHash(hash, "_weaponSlots", _weaponSlots);
_shieldSlots = (int)GetValueFromHash(hash, "_shieldSlots", _shieldSlots);
_gadgetSlots = (int)GetValueFromHash(hash, "_gadgetSlots", _gadgetSlots);
_crewQuarters = (int)GetValueFromHash(hash, "_crewQuarters", _crewQuarters);
_fuelTanks = (int)GetValueFromHash(hash, "_fuelTanks", _fuelTanks);
_hullStrength = (int)GetValueFromHash(hash, "_hullStrength", _hullStrength);
_images = (Image[])GetValueFromHash(hash, "_images", _images);
}
public int CompareTo(object value)
{
int compared = 0;
compared = value == null ? 1 : Name.CompareTo(((ShipTemplate)value).Name);
return compared;
}
public override Hashtable Serialize()
{
Hashtable hash = base.Serialize();
hash.Add("_name", _name);
hash.Add("_size", (int)_size);
hash.Add("_imageIndex", _imageIndex);
hash.Add("_cargoBays", _cargoBays);
hash.Add("_weaponSlots", _weaponSlots);
hash.Add("_shieldSlots", _shieldSlots);
hash.Add("_gadgetSlots", _gadgetSlots);
hash.Add("_crewQuarters", _crewQuarters);
hash.Add("_fuelTanks", _fuelTanks);
hash.Add("_hullStrength", _hullStrength);
if (_images != null)
hash.Add("_images", _images);
return hash;
}
public override string ToString()
{
return Name;
}
#endregion
#region Properties
public int CargoBays
{
get
{
return _cargoBays;
}
set
{
_cargoBays = value;
}
}
public int CrewQuarters
{
get
{
return _crewQuarters;
}
set
{
_crewQuarters = value;
}
}
public int FuelTanks
{
get
{
return _fuelTanks;
}
set
{
_fuelTanks = value;
}
}
public int GadgetSlots
{
get
{
return _gadgetSlots;
}
set
{
_gadgetSlots = value;
}
}
public int HullStrength
{
get
{
return _hullStrength;
}
set
{
_hullStrength = value;
}
}
public int ImageIndex
{
get
{
return _imageIndex;
}
set
{
_imageIndex = value;
}
}
public Image[] Images
{
get
{
return _images;
}
set
{
_images = value;
}
}
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public int ShieldSlots
{
get
{
return _shieldSlots;
}
set
{
_shieldSlots = value;
}
}
public Size Size
{
get
{
return _size;
}
set
{
_size = value;
}
}
public int WeaponSlots
{
get
{
return _weaponSlots;
}
set
{
_weaponSlots = value;
}
}
#endregion
}
}