Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
VanillaContentValidator.cs
Go to the documentation of this file.
2using System.Linq;
6
8
10{
11 private struct TextureMetaData
12 {
13 public int Width;
14
15 public int Height;
16
18 {
19 if (texture.Width != Width || texture.Height != Height)
20 {
22 return false;
23 }
24 rejectReason = null;
25 return true;
26 }
27 }
28
30
32
34 {
35 string[] array = Regex.Split(Utils.ReadEmbeddedResource(infoFilePath), "\r\n|\r|\n");
36 foreach (string text in array)
37 {
38 if (!text.StartsWith("//"))
39 {
40 string[] array2 = text.Split('\t');
41 if (array2.Length >= 3 && int.TryParse(array2[1], out var result) && int.TryParse(array2[2], out var result2))
42 {
43 string key = array2[0].Replace('/', '\\');
44 _info[key] = new TextureMetaData
45 {
46 Width = result,
47 Height = result2
48 };
49 }
50 }
51 }
52 }
53
54 public bool AssetIsValid<T>(T content, string contentPath, out IRejectionReason rejectReason) where T : class
55 {
57 rejectReason = null;
58 if (texture2D != null)
59 {
61 {
62 return true;
63 }
64 return value.Matches(texture2D, out rejectReason);
65 }
66 return true;
67 }
68
73}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
static string[] Split(string input, string pattern)
Definition Regex.cs:656
Dictionary< string, TextureMetaData > _info
bool AssetIsValid< T >(T content, string contentPath, out IRejectionReason rejectReason)
static string ReadEmbeddedResource(string path)
Definition Utils.cs:1957
bool Matches(Texture2D texture, out IRejectionReason rejectReason)