Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TextureReplace.cs
Go to the documentation of this file.
1using System;
2using System.IO;
3using UnityEngine;
4
5public class TextureReplace
6{
7 public enum Source
8 {
9 User,
10 Mod,
11 Local
12 }
13
14 public DateTime date;
15
16 public Texture2D tex;
17
18 public FileInfo file;
19
21
22 public int index;
23
24 public int w;
25
26 public int h;
27
28 public Source source;
29
31
32 public bool user => source == Source.User;
33
34 public void TryRefresh(bool force)
35 {
36 if (File.Exists(file.FullName))
37 {
38 DateTime lastWriteTime = File.GetLastWriteTime(file.FullName);
39 bool flag = date.Year != 1 && date.Equals(lastWriteTime);
40 if (!flag || force || !tex)
41 {
42 Load(flag);
43 }
44 date = lastWriteTime;
45 }
46 }
47
48 public void Load(bool dateMatched)
49 {
50 if ((bool)tex)
51 {
52 UnityEngine.Object.Destroy(tex);
53 }
54 tex = IO.LoadPNG(file.FullName);
55 w = tex.width;
56 h = tex.height;
57 int dstX = index % 100 * data.tileW;
58 int dstY = data.tex.height - index / 100 * data.tileH - tex.height;
59 Graphics.CopyTexture(tex, 0, 0, 0, 0, tex.width, tex.height, data.tex, 0, 0, dstX, dstY);
60 }
61
62 public void DestoryTex()
63 {
64 UnityEngine.Object.Destroy(tex);
65 }
66}
Texture2D tex
Definition: TextureData.cs:39
TextureData data
void TryRefresh(bool force)
void Load(bool dateMatched)
TextureReplace original