rimworld-animation-studio/Assets/Scripts/DefParents/PawnRaceDefs.cs
AbstractConcept 757badf4f6 Code refactor
2022-10-27 00:56:04 -05:00

53 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RimWorldAnimationStudio
{
public static class PawnRaceDefs
{
public static List<PawnRaceDef> allDefs = new List<PawnRaceDef>();
public static PawnRaceDef GetNamed(string pawnRaceDef)
{
return allDefs.FirstOrDefault(x => x.defName == pawnRaceDef);
}
public static void AddDef(PawnRaceDef pawnRaceDef)
{
if (allDefs.Any(x => x.defName == pawnRaceDef.defName)) return;
allDefs.Add(pawnRaceDef);
}
public static void OnLoad()
{
List<string> allTags = DefaultTags.bodyTypes.Concat(CustomTags.bodyTypes).ToList();
allTags.Add("None");
List<CardinalDirection> facings = new List<CardinalDirection>() { CardinalDirection.North, CardinalDirection.East, CardinalDirection.South };
string path;
foreach (PawnRaceDef pawnRaceDef in allDefs)
{
foreach (CardinalDirection facing in facings)
{
foreach (string bodyType in allTags)
{
path = pawnRaceDef.GetBodyTypeGraphicPath(facing, bodyType);
if (string.IsNullOrEmpty(path) == false)
{ pawnRaceDef.SetBodyTypeGraphicPath(path, facing, bodyType); }
}
path = pawnRaceDef.GetHeadGraphicPath(facing);
if (string.IsNullOrEmpty(path) == false)
{ pawnRaceDef.SetHeadGraphicPath(path, facing); }
}
}
}
}
}