You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.2 KiB
82 lines
2.2 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class TextureSet
|
|
{
|
|
public List<TextureSkin> Skins { get; } = new List<TextureSkin>();
|
|
|
|
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<TexturePair> Frames { get; } = new List<TexturePair>();
|
|
|
|
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;
|
|
}
|
|
}
|