2024-04-21 15:34:36 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Verse;
|
|
|
|
|
|
|
|
|
|
namespace Rimworld_Animations
|
|
|
|
|
{
|
|
|
|
|
public class PawnRenderNode_GraphicVariants : PawnRenderNode
|
|
|
|
|
{
|
|
|
|
|
|
2024-04-22 17:56:34 +00:00
|
|
|
|
protected new PawnRenderNodeProperties_GraphicVariants props;
|
|
|
|
|
protected Dictionary<int, Graphic> variants;
|
2024-04-21 15:34:36 +00:00
|
|
|
|
|
|
|
|
|
public Graphic getGraphicVariant(int variant)
|
|
|
|
|
{
|
2024-04-22 19:55:46 +00:00
|
|
|
|
if (!variants.ContainsKey(variant))
|
|
|
|
|
{
|
|
|
|
|
Log.ErrorOnce("[Anims] Error: tried to get key from variants that doesn't exist; key = " + variant, 2043428111);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-21 15:34:36 +00:00
|
|
|
|
return variants[variant];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PawnRenderNode_GraphicVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree) {
|
|
|
|
|
|
|
|
|
|
this.props = (PawnRenderNodeProperties_GraphicVariants)props;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void EnsureMaterialsInitialized()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (variants == null)
|
|
|
|
|
{
|
|
|
|
|
variants = GraphicVariantsFor(this.tree.pawn);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.EnsureMaterialsInitialized();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
|
|
|
|
|
{
|
2024-04-22 17:56:34 +00:00
|
|
|
|
|
|
|
|
|
return GenerateVariants(pawn, props.texPathVariantsDef);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Dictionary<int, Graphic> GenerateVariants(Pawn pawn, TexPathVariantsDef texPathVariants)
|
|
|
|
|
{
|
|
|
|
|
|
2024-04-21 15:34:36 +00:00
|
|
|
|
Dictionary<int, Graphic> variantGraphics = new Dictionary<int, Graphic>();
|
|
|
|
|
|
2024-04-22 19:55:46 +00:00
|
|
|
|
if (texPathVariants == null) return variantGraphics;
|
|
|
|
|
|
2024-04-21 15:34:36 +00:00
|
|
|
|
//for each graphic variant
|
2024-04-22 17:56:34 +00:00
|
|
|
|
for (int i = 0; i < texPathVariants.variants.Count; i++)
|
2024-04-21 15:34:36 +00:00
|
|
|
|
{
|
2024-04-22 17:56:34 +00:00
|
|
|
|
|
2024-04-21 15:34:36 +00:00
|
|
|
|
//get new graphic
|
2024-04-22 17:56:34 +00:00
|
|
|
|
Graphic variant = GraphicDatabase.Get<Graphic_Multi>(texPathVariants.variants[i], this.ShaderFor(pawn), Vector2.one, this.ColorFor(pawn));
|
2024-04-21 15:34:36 +00:00
|
|
|
|
|
|
|
|
|
//add it to the variants dictionary; i + 1 for easier readability in logs
|
|
|
|
|
variantGraphics.Add(i + 1, variant);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return variantGraphics;
|
2024-04-22 17:56:34 +00:00
|
|
|
|
|
2024-04-21 15:34:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|