forked from hajsdfgj/modular-overhaul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VanillaProfession.cs
338 lines (282 loc) · 15.2 KB
/
VanillaProfession.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
#region global using directives
#pragma warning disable SA1200 // Using directives should be placed correctly
global using Profession = DaLion.Overhaul.Modules.Professions.VanillaProfession;
#pragma warning restore SA1200 // Using directives should be placed correctly
#endregion global using directives
namespace DaLion.Overhaul.Modules.Professions;
#region using directives
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Ardalis.SmartEnum;
using DaLion.Overhaul.Modules.Professions.Extensions;
using DaLion.Shared.Extensions;
using Microsoft.Xna.Framework;
using static System.String;
#endregion using directives
/// <summary>Represents a vanilla profession.</summary>
/// <remarks>
/// Includes unused <see cref="Ardalis.SmartEnum"/> entries for professions offered by the
/// <see cref="LuckSkill"/> as a fail-safe, since those are handled as <see cref="CustomProfession"/>s.
/// </remarks>
public sealed class VanillaProfession : SmartEnum<Profession>, IProfession
{
#region enum entries
/// <summary>The Rancher profession, available at <see cref="VanillaSkill.Farming"/> level 5.</summary>
public static readonly Profession Rancher = new("Rancher", Farmer.rancher, 5);
/// <summary>The Harvester profession, available at <see cref="VanillaSkill.Farming"/> level 5.</summary>
public static readonly Profession Harvester = new("Harvester", Farmer.tiller, 5);
/// <summary>The Breeder profession, available at <see cref="VanillaSkill.Farming"/> level 10.</summary>
public static readonly Profession Breeder = new("Breeder", Farmer.butcher, 10);
/// <summary>The Producer profession, available at <see cref="VanillaSkill.Farming"/> level 10.</summary>
public static readonly Profession Producer = new("Producer", Farmer.shepherd, 10);
/// <summary>The Artisan profession, available at <see cref="VanillaSkill.Farming"/> level 10.</summary>
public static readonly Profession Artisan = new("Artisan", Farmer.artisan, 10);
/// <summary>The Agriculturist profession, available at <see cref="VanillaSkill.Farming"/> level 10.</summary>
public static readonly Profession Agriculturist = new("Agriculturist", Farmer.agriculturist, 10);
/// <summary>The Fisher profession, available at <see cref="VanillaSkill.Fishing"/> level 5.</summary>
public static readonly Profession Fisher = new("Fisher", Farmer.fisher, 5);
/// <summary>The Trapper profession, available at <see cref="VanillaSkill.Fishing"/> level 5.</summary>
public static readonly Profession Trapper = new("Trapper", Farmer.trapper, 5);
/// <summary>The Angler profession, available at <see cref="VanillaSkill.Fishing"/> level 10.</summary>
public static readonly Profession Angler = new("Angler", Farmer.angler, 10);
/// <summary>The Aquarist profession, available at <see cref="VanillaSkill.Fishing"/> level 10.</summary>
public static readonly Profession Aquarist = new("Aquarist", Farmer.pirate, 10);
/// <summary>The Luremaster profession, available at <see cref="VanillaSkill.Fishing"/> level 10.</summary>
public static readonly Profession Luremaster = new("Luremaster", Farmer.baitmaster, 10);
/// <summary>The Conservationist profession, available at <see cref="VanillaSkill.Fishing"/> level 10.</summary>
public static readonly Profession Conservationist = new("Conservationist", Farmer.mariner, 10);
/// <summary>The Lumberjack profession, available at <see cref="VanillaSkill.Foraging"/> level 5.</summary>
public static readonly Profession Lumberjack = new("Lumberjack", Farmer.forester, 5);
/// <summary>The Forager profession, available at <see cref="VanillaSkill.Foraging"/> level 5.</summary>
public static readonly Profession Forager = new("Forager", Farmer.gatherer, 5);
/// <summary>The Arborist profession, available at <see cref="VanillaSkill.Foraging"/> level 10.</summary>
public static readonly Profession Arborist = new("Arborist", Farmer.lumberjack, 10);
/// <summary>The Trapper profession, available at <see cref="VanillaSkill.Foraging"/> level 10.</summary>
public static readonly Profession Tapper = new("Tapper", Farmer.tapper, 10);
/// <summary>The Ecologist profession, available at <see cref="VanillaSkill.Foraging"/> level 10.</summary>
public static readonly Profession Ecologist = new("Ecologist", Farmer.botanist, 10);
/// <summary>The Scavenger profession, available at <see cref="VanillaSkill.Foraging"/> level 10.</summary>
public static readonly Profession Scavenger = new("Scavenger", Farmer.tracker, 10);
/// <summary>The Miner profession, available at <see cref="VanillaSkill.Mining"/> level 5.</summary>
public static readonly Profession Miner = new("Miner", Farmer.miner, 5);
/// <summary>The Blaster profession, available at <see cref="VanillaSkill.Mining"/> level 5.</summary>
public static readonly Profession Blaster = new("Blaster", Farmer.geologist, 5);
/// <summary>The Spelunker profession, available at <see cref="VanillaSkill.Mining"/> level 10.</summary>
public static readonly Profession Spelunker = new("Spelunker", Farmer.blacksmith, 10);
/// <summary>The Prospector profession, available at <see cref="VanillaSkill.Mining"/> level 10.</summary>
public static readonly Profession Prospector = new("Prospector", Farmer.burrower, 10);
/// <summary>The Demolitionist profession, available at <see cref="VanillaSkill.Mining"/> level 10.</summary>
public static readonly Profession Demolitionist = new("Demolitionist", Farmer.excavator, 10);
/// <summary>The Gemologist profession, available at <see cref="VanillaSkill.Mining"/> level 10.</summary>
public static readonly Profession Gemologist = new("Gemologist", Farmer.gemologist, 10);
/// <summary>The Fighter profession, available at <see cref="VanillaSkill.Combat"/> level 5.</summary>
public static readonly Profession Fighter = new("Fighter", Farmer.fighter, 5);
/// <summary>The Rascal profession, available at <see cref="VanillaSkill.Combat"/> level 5.</summary>
public static readonly Profession Rascal = new("Rascal", Farmer.scout, 5);
/// <summary>The Brute profession, available at <see cref="VanillaSkill.Combat"/> level 10.</summary>
public static readonly Profession Brute = new("Brute", Farmer.brute, 10);
/// <summary>The Poacher profession, available at <see cref="VanillaSkill.Combat"/> level 10.</summary>
public static readonly Profession Poacher = new("Poacher", Farmer.defender, 10);
/// <summary>The Piper profession, available at <see cref="VanillaSkill.Combat"/> level 10.</summary>
public static readonly Profession Piper = new("Piper", Farmer.acrobat, 10);
/// <summary>The Desperado profession, available at <see cref="VanillaSkill.Combat"/> level 10.</summary>
public static readonly Profession Desperado = new("Desperado", Farmer.desperado, 10);
#endregion enum entries
#region buff indices
internal const int BruteRageSheetIndex = 36;
internal const int DesperadoQuickshotSheetIndex = 39;
internal const int SpelunkerStreakSheetIndex = 40;
internal const int DemolitionistExcitedSheetIndex = 41;
#endregion buff indices
/// <summary>Initializes a new instance of the <see cref="Profession"/> class.</summary>
/// <param name="name">The profession name.</param>
/// <param name="value">The profession index.</param>
/// <param name="level">The level at which the profession is offered (either 5 or 10).</param>
private VanillaProfession(string name, int value, int level)
: base(name, value)
{
this.Level = level;
this.SourceSheetRect = new Rectangle((value % 6) * 16, (value / 6) * 16, 16, 16);
this.TargetSheetRect = new Rectangle((value % 6) * 16, ((value / 6) * 16) + 624, 16, 16);
}
/// <inheritdoc />
public string StringId => this.Name;
/// <inheritdoc />
public int Id => this.Value;
/// <inheritdoc />
public string Title => this.GetTitle(this.IsPrestiged);
/// <inheritdoc />
public string Description => this.GetDescription(this.IsPrestiged);
/// <summary>Gets a <see cref="Rectangle"/> representing the coordinates of the <see cref="Profession"/>'s icon in the mod's Professions spritesheet.</summary>
public Rectangle SourceSheetRect { get; }
/// <summary>Gets a <see cref="Rectangle"/> representing the coordinates of the <see cref="Profession"/>'s icon in the vanilla Cursors spritesheet.</summary>
public Rectangle TargetSheetRect { get; }
/// <inheritdoc />
public int Level { get; }
/// <inheritdoc />
public ISkill ParentSkill => Skill.FromValue(this.Value / 6);
/// <summary>Gets a value indicating whether the local player has Prestiged this <see cref="Profession"/>.</summary>
public bool IsPrestiged => Game1.player.HasProfession(this, true);
/// <summary>Gets the <see cref="Profession"/> with the specified localized name.</summary>
/// <param name="name">A localized profession name.</param>
/// <param name="ignoreCase">Whether to ignore capitalization.</param>
/// <param name="result">The corresponding profession.</param>
/// <returns><see langword="true"/> if a matching profession was found, otherwise <see langword="false"/>.</returns>
public static bool TryFromLocalizedName(string name, bool ignoreCase, [NotNullWhen(true)] out Profession? result)
{
var stringComparison = ignoreCase
? StringComparison.InvariantCultureIgnoreCase
: StringComparison.InvariantCulture;
result = null;
if (string.Equals(name, Rancher.Title.TrimAll(), stringComparison))
{
result = Rancher;
}
else if (string.Equals(name, Harvester.Title.TrimAll(), stringComparison))
{
result = Harvester;
}
else if (string.Equals(name, Breeder.Title.TrimAll(), stringComparison))
{
result = Breeder;
}
else if (string.Equals(name, Producer.Title.TrimAll(), stringComparison))
{
result = Producer;
}
else if (string.Equals(name, Artisan.Title.TrimAll(), stringComparison))
{
result = Artisan;
}
else if (string.Equals(name, Agriculturist.Title.TrimAll(), stringComparison))
{
result = Agriculturist;
}
else if (string.Equals(name, Fisher.Title.TrimAll(), stringComparison))
{
result = Fisher;
}
else if (string.Equals(name, Trapper.Title.TrimAll(), stringComparison))
{
result = Trapper;
}
else if (string.Equals(name, Angler.Title.TrimAll(), stringComparison))
{
result = Angler;
}
else if (string.Equals(name, Aquarist.Title.TrimAll(), stringComparison))
{
result = Aquarist;
}
else if (string.Equals(name, Luremaster.Title.TrimAll(), stringComparison))
{
result = Luremaster;
}
else if (string.Equals(name, Conservationist.Title.TrimAll(), stringComparison))
{
result = Conservationist;
}
else if (string.Equals(name, Lumberjack.Title.TrimAll(), stringComparison))
{
result = Lumberjack;
}
else if (string.Equals(name, Forager.Title.TrimAll(), stringComparison))
{
result = Forager;
}
else if (string.Equals(name, Arborist.Title.TrimAll(), stringComparison))
{
result = Arborist;
}
else if (string.Equals(name, Tapper.Title.TrimAll(), stringComparison))
{
result = Tapper;
}
else if (string.Equals(name, Ecologist.Title.TrimAll(), stringComparison))
{
result = Ecologist;
}
else if (string.Equals(name, Scavenger.Title.TrimAll(), stringComparison))
{
result = Scavenger;
}
else if (string.Equals(name, Miner.Title.TrimAll(), stringComparison))
{
result = Miner;
}
else if (string.Equals(name, Blaster.Title.TrimAll(), stringComparison))
{
result = Blaster;
}
else if (string.Equals(name, Spelunker.Title.TrimAll(), stringComparison))
{
result = Spelunker;
}
else if (string.Equals(name, Prospector.Title.TrimAll(), stringComparison))
{
result = Prospector;
}
else if (string.Equals(name, Demolitionist.Title.TrimAll(), stringComparison))
{
result = Demolitionist;
}
else if (string.Equals(name, Gemologist.Title.TrimAll(), stringComparison))
{
result = Gemologist;
}
else if (string.Equals(name, Fighter.Title.TrimAll(), stringComparison))
{
result = Fighter;
}
else if (string.Equals(name, Rascal.Title.TrimAll(), stringComparison))
{
result = Rascal;
}
else if (string.Equals(name, Brute.Title.TrimAll(), stringComparison))
{
result = Brute;
}
else if (string.Equals(name, Poacher.Title.TrimAll(), stringComparison))
{
result = Poacher;
}
else if (string.Equals(name, Piper.Title.TrimAll(), stringComparison))
{
result = Piper;
}
else if (string.Equals(name, Desperado.Title.TrimAll(), stringComparison))
{
result = Desperado;
}
return result is not null;
}
/// <summary>Enumerate the range of indices corresponding to all vanilla professions.</summary>
/// <param name="prestige">Whether to enumerate prestige professions instead.</param>
/// <returns>A <see cref="IEnumerable{T}"/> of all vanilla profession indices.</returns>
public static IEnumerable<int> GetRange(bool prestige = false)
{
return Enumerable.Range(prestige ? 100 : 0, 30);
}
/// <summary>Gets the localized and gendered title for this profession.</summary>
/// <param name="prestiged">Whether to get the prestiged or normal variant.</param>
/// <returns>A human-readable <see cref="string"/> title for the profession.</returns>
public string GetTitle(bool? prestiged = null)
{
prestiged ??= this.IsPrestiged;
return LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en
? this.Level == 10
? _I18n.Get(this.Name.ToLower() + ".title." + (prestiged.Value ? "prestiged." : Empty) +
(Game1.player.IsMale ? "male" : "female"))
: (prestiged.Value ? I18n.Prestiged_Title() : Empty) +
_I18n.Get(this.Name.ToLower() + ".title." + (Game1.player.IsMale ? "male" : "female"))
: _I18n.Get(this.Name.ToLower() + ".title." + (Game1.player.IsMale ? "male" : "female"));
}
/// <summary>Gets the localized description text for this profession.</summary>
/// <param name="prestiged">Whether to get the prestiged or normal variant.</param>
/// <returns>A human-readable <see cref="string"/> description of the profession.</returns>
public string GetDescription(bool prestiged = false)
{
return _I18n.Get(this.Name.ToLowerInvariant() + ".desc" + (prestiged ? ".prestiged" : Empty));
}
}