Race customization and data saving

This commit is contained in:
AbstractConcept 2022-09-24 02:17:40 -05:00
parent 2f3f807911
commit d3b676df06
456 changed files with 6388 additions and 419 deletions

View file

@ -18,6 +18,37 @@ namespace RimWorldAnimationStudio
public void Start()
{
LoadCustomArrays();
/*AlienRaceDef human = new AlienRaceDef();
human.Initialize("Human");
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head0.png"), CardinalDirection.North);
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head1.png"), CardinalDirection.East);
human.SetHeadGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Heads/Head2.png"), CardinalDirection.South);
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male0.png"), CardinalDirection.North, "Male");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male1.png"), CardinalDirection.East, "Male");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Male2.png"), CardinalDirection.South, "Male");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female0.png"), CardinalDirection.North, "Female");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female1.png"), CardinalDirection.East, "Female");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Female2.png"), CardinalDirection.South, "Female");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat0.png"), CardinalDirection.North, "Fat");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat1.png"), CardinalDirection.East, "Fat");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Fat2.png"), CardinalDirection.South, "Fat");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk0.png"), CardinalDirection.North, "Hulk");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk1.png"), CardinalDirection.East, "Hulk");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Hulk2.png"), CardinalDirection.South, "Hulk");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin0.png"), CardinalDirection.North, "Thin");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin1.png"), CardinalDirection.East, "Thin");
human.SetBodyTypeGraphicPath(Path.Combine(Application.streamingAssetsPath, "Textures/Humanlike/Bodies/Thin2.png"), CardinalDirection.South, "Thin");*/
//AlienRaceDefs.allDefs.Add(human);
LoadAlienRaceDefs();
}
public void TryToCloseApplication()
@ -139,7 +170,6 @@ namespace RimWorldAnimationStudio
CustomTagsHelper helper = new CustomTagsHelper();
helper.defNames = CustomTags.defNames;
helper.bodyParts = CustomTags.bodyParts;
helper.bodyDefTypes = CustomTags.bodyDefTypes;
helper.sexTypes = CustomTags.sexTypes;
@ -158,7 +188,6 @@ namespace RimWorldAnimationStudio
CustomTagsHelper helper = XmlUtility.ReadXML<CustomTagsHelper>(path);
CustomTags.defNames = helper.defNames;
CustomTags.bodyParts = helper.bodyParts;
CustomTags.bodyDefTypes = helper.bodyDefTypes;
CustomTags.sexTypes = helper.sexTypes;
@ -168,7 +197,6 @@ namespace RimWorldAnimationStudio
public void UpdateCustomArrays(AnimationDef animationDef)
{
CustomTags.defNames.AddRangeDistinct(animationDef.actors.SelectMany(x => x.defNames).Except(Tags.defNames));
CustomTags.bodyParts.AddRangeDistinct(animationDef.actors.SelectMany(x => x.requiredGenitals).Except(Tags.bodyParts));
CustomTags.bodyDefTypes.AddRangeDistinct(animationDef.actors.SelectMany(x => x.bodyDefTypes).Except(Tags.bodyDefTypes));
CustomTags.sexTypes.AddRangeDistinct(animationDef.sexTypes.Except(Tags.sexTypes));
@ -177,5 +205,23 @@ namespace RimWorldAnimationStudio
SaveCustomArrays();
}
public void LoadAlienRaceDefs()
{
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
if (File.Exists(path) == false)
{ SaveAlienRaceDefs(); return; }
AlienRaceDefs.allDefs = XmlUtility.ReadXML<List<AlienRaceDef>>(path);
AlienRaceDefs.OnLoad();
}
public void SaveAlienRaceDefs()
{
var path = Path.Combine(Application.streamingAssetsPath, "alienRaceDefs.xml");
XmlUtility.WriteXML(AlienRaceDefs.allDefs, path);
}
}
}