-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDFHackModClasses.cs
More file actions
79 lines (70 loc) · 2.14 KB
/
Copy pathDFHackModClasses.cs
File metadata and controls
79 lines (70 loc) · 2.14 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ModHearth
{
/// <summary>
/// Object matching how dfhack handles mods internally.
/// Only stores ID and Version.
/// Acts like a value type.
/// </summary>
public class DFHMod
{
public string id { get; set; }
public int version { get; set; }
// For display and hash function.
public override string ToString()
{
return id + "|" + version;
}
// Simple check if they represent the same mod or not.
public static bool operator ==(DFHMod lhs, DFHMod rhs)
{
if (ReferenceEquals(lhs, rhs)) return true;
if (ReferenceEquals(lhs, null)) return false;
if (ReferenceEquals(rhs, null)) return false;
return lhs.ToString() == rhs.ToString();
}
public static bool operator !=(DFHMod lhs, DFHMod rhs)
{
return !(lhs == rhs);
}
// Simple hash code generation using tostring.
public override int GetHashCode()
{
return ToString().GetHashCode();
}
// Just use ==.
public override bool Equals(Object? other)
{
if(other is DFHMod dfother)
return this == dfother;
return false;
}
public DFHMod(string id, int version)
{
this.id = id;
this.version = version;
}
}
/// <summary>
/// Object matching how dfhack handles modpacks internally.
/// Only stores if it's the default modpack, a list of mods, and a name.
/// Ordering is strange but matches the dfhack json file.
/// </summary>
public class DFHModpack
{
public bool @default { get; set; }
public List<DFHMod> modlist { get; set; }
public string name { get; set; }
public DFHModpack(bool @default, List<DFHMod> modlist, string name)
{
this.@default = @default;
this.modlist = modlist;
this.name = name;
}
}
}