using System.Collections; using System.Collections.Generic; using UnityEngine; public class TextureSet { public List Skins { get; } = new List(); public TexturePair PrimaryTextures => Skins.Count > 0 && Skins[0].Frames.Count > 0 ? Skins[0].Frames[0] : null; public bool Import(GameAssets assets, QGLTexture[][] textures, QGLTexture[][] fullBrights) { if (textures == null) return false; for (int skinIndex = 0; skinIndex < textures.Length; skinIndex++) { if (textures[skinIndex] == null) break; var skin = new TextureSkin(); if (skin.Import(assets, textures[skinIndex], fullBrights != null && skinIndex < fullBrights.Length ? fullBrights[skinIndex] : null)) { Skins.Add(skin); } } return true; } } public class TextureSkin { public List Frames { get; } = new List(); public bool Import(GameAssets assets, QGLTexture[] textures, QGLTexture[] fullBrights) { if (textures == null) return false; for (int frameIndex = 0; frameIndex < textures.Length; frameIndex++) { if (textures[frameIndex] == null) break; var frame = new TexturePair(); if (frame.Import(assets, textures[frameIndex], fullBrights != null && frameIndex < fullBrights.Length ? fullBrights[frameIndex] : null)) { Frames.Add(frame); } } return true; } } public class TexturePair { public Texture2D MainTexture { get; private set; } public Texture2D FullBrightTexture { get; private set; } public bool Import(GameAssets assets, QGLTexture texture, QGLTexture fullBright) { if (texture == null) return false; if (assets.TryGetTexture(texture.texNum, out var mainTexture)) { MainTexture = mainTexture; } if (fullBright != null && assets.TryGetTexture(fullBright.texNum, out var fullBrightTexture)) { FullBrightTexture = fullBrightTexture; } return true; } }