2022-08-14 20:46:19 +00:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
using RimWorld ;
using Verse ;
using HarmonyLib ;
using UnityEngine ;
using rjw ;
namespace SizedApparel
{
2023-04-04 01:47:49 +00:00
public class BodyTypeAndPath
{
public string BodyType ;
public string Path ;
}
public class ApparelData
{
public string WornPath ;
public List < BodyTypeAndPath > Data ;
}
public class PreDefinedApparelDate : Def
{
public string HediffName ;
public bool IsBreasts = false ;
public List < BodyTypeAndPath > Data ;
}
public class PreDefinedBodyPartGraphicDate : Def
{
}
2022-08-14 20:46:19 +00:00
public static class SizedApparelsDatabase
{
public struct BodyGraphicKey
{
}
2023-04-04 01:47:49 +00:00
public static void LoadPreDefinedData ( )
{
}
2022-08-14 20:46:19 +00:00
public struct SizedApparelDatabaseKey
{
public string pathWithoutSizeIndex ; // Do Not Include Size Data to path! bodytype could be included
public string raceName ;
public string bodyTypeName ;
2023-04-04 01:47:48 +00:00
public Gender gender ;
2022-08-14 20:46:19 +00:00
public string hediffName ;
public int targetSize ;
public bool isHorny ;
public string customPose ;
public string variation ;
2023-04-04 01:47:48 +00:00
public SizedApparelDatabaseKey ( string path , string race , string bodyType = null , Gender genderInput = Gender . None , string hediff = null , int size = - 1 , bool horny = false , string customPose = null , string variation = null )
2022-08-14 20:46:19 +00:00
{
this . pathWithoutSizeIndex = path ;
this . raceName = race ;
this . bodyTypeName = bodyType ;
2023-04-04 01:47:48 +00:00
this . gender = genderInput ;
2022-08-14 20:46:19 +00:00
this . hediffName = hediff ;
this . targetSize = size ;
this . isHorny = horny ;
this . customPose = customPose ;
this . variation = variation ;
}
}
public struct SizedApparelDatabaseKeyComparer : IEqualityComparer < SizedApparelDatabaseKey >
{
public bool Equals ( SizedApparelDatabaseKey x , SizedApparelDatabaseKey y )
{
if ( x . targetSize ! = y . targetSize )
return false ;
2023-04-04 01:47:48 +00:00
return true & & ( x . pathWithoutSizeIndex = = y . pathWithoutSizeIndex ) & & ( x . bodyTypeName = = y . bodyTypeName ) & & ( x . raceName = = y . raceName ) & & ( x . gender = = y . gender ) & & ( x . hediffName = = y . hediffName ) & & ( x . isHorny = = y . isHorny ) & & ( x . customPose = = y . customPose ) & & ( x . variation = = y . variation ) ;
2022-08-14 20:46:19 +00:00
}
public int GetHashCode ( SizedApparelDatabaseKey obj )
{
return obj . GetHashCode ( ) ;
}
}
public struct BodyPartDatabaseKey
{
public string raceName ;
public string bodyTypeName ;
public string hediffName ;
public string folderPath ;
2023-04-04 01:47:48 +00:00
public Gender gender ;
2022-08-14 20:46:19 +00:00
public int targetSize ;
public bool isHorny ;
public string customPose ; // null custom pose as default pose
public string variation ; // null variation as default graphic
2023-04-04 01:47:48 +00:00
public BodyPartDatabaseKey ( string race , string bodyType = null , string hediff = null , string path = null , Gender pawnGender = Gender . None , int size = - 1 , bool horny = false , string customPose = null , string variation = null )
2022-08-14 20:46:19 +00:00
{
this . raceName = race ;
this . bodyTypeName = bodyType ;
this . hediffName = hediff ;
this . folderPath = path ;
2023-04-04 01:47:48 +00:00
this . gender = pawnGender ;
2022-08-14 20:46:19 +00:00
this . targetSize = size ;
this . isHorny = horny ;
this . customPose = customPose ;
this . variation = variation ;
}
}
public struct BodyPartDatabaseKeyComparer : IEqualityComparer < BodyPartDatabaseKey >
{
public bool Equals ( BodyPartDatabaseKey x , BodyPartDatabaseKey y )
{
if ( x . targetSize ! = y . targetSize )
return false ;
2023-04-04 01:47:48 +00:00
return true & & ( x . raceName = = y . raceName ) & & ( x . bodyTypeName = = y . bodyTypeName ) & & ( x . hediffName = = y . hediffName ) & & ( x . folderPath = = y . folderPath ) & & ( x . gender = = y . gender ) & & ( x . isHorny = = y . isHorny ) & & ( x . customPose = = y . customPose ) & & ( x . variation = = y . variation ) ;
2022-08-14 20:46:19 +00:00
}
public int GetHashCode ( BodyPartDatabaseKey obj )
{
return obj . GetHashCode ( ) ;
}
}
public struct PathAndSize
{
public string pathWithSizeIndex ;
public int size ;
public bool isUnsupportedHumanlikePath ;
public bool isCustomPose ;
public string hediffName ;
2023-04-04 01:47:50 +00:00
public string bodyType ; // useful for bodypart Graphic (body addons).
2023-04-04 01:48:55 +00:00
public string raceName ; // for check is Human or Alien or Alien as Human.
2023-04-04 01:47:49 +00:00
public SizedApparelTexturePointDef points ;
2022-08-14 20:46:19 +00:00
2023-04-04 01:48:55 +00:00
public PathAndSize ( string path , int index , bool unsupportedHumanlike = false , bool customPose = false , string hediff = null , string bodytype = null , string raceName = null , SizedApparelTexturePointDef pointsInput = null )
2022-08-14 20:46:19 +00:00
{
this . pathWithSizeIndex = path ;
this . size = index ;
this . isUnsupportedHumanlikePath = unsupportedHumanlike ;
this . isCustomPose = customPose ;
this . hediffName = hediff ;
2023-04-04 01:47:50 +00:00
this . bodyType = bodytype ;
2022-08-14 20:46:19 +00:00
this . points = pointsInput ;
2023-04-04 01:48:55 +00:00
this . raceName = raceName ;
2022-08-14 20:46:19 +00:00
}
}
2023-04-04 01:47:48 +00:00
private static Dictionary < Pawn , ApparelRecorderComp > ApparelRecordersCache = new Dictionary < Pawn , ApparelRecorderComp > ( ) ;
2022-08-14 20:46:19 +00:00
private static Dictionary < BodyGraphicKey , Graphic > SizedApparelBodyGraphic = new Dictionary < BodyGraphicKey , Graphic > ( ) ; // TODO
private static Dictionary < SizedApparelDatabaseKey , PathAndSize > SupportedApparelResultPath = new Dictionary < SizedApparelDatabaseKey , PathAndSize > ( new SizedApparelDatabaseKeyComparer ( ) ) ;
private static Dictionary < BodyPartDatabaseKey , PathAndSize > SupportedBodyPartResultPath = new Dictionary < BodyPartDatabaseKey , PathAndSize > ( new BodyPartDatabaseKeyComparer ( ) ) ;
private static Dictionary < string , string > SupportedApparelOriginalPath = new Dictionary < string , string > ( ) ;
//AlienRace AllowHumanlike. Need to Restart or Clear cache to change options
2023-04-04 01:47:48 +00:00
public static ApparelRecorderComp GetApparelCompFast ( Pawn pawn )
{
if ( ApparelRecordersCache . ContainsKey ( pawn ) )
return ApparelRecordersCache [ pawn ] ;
ApparelRecorderComp comp = pawn . GetComp < ApparelRecorderComp > ( ) ; // comp can be null
ApparelRecordersCache . Add ( pawn , comp ) ;
return comp ;
}
2022-08-14 20:46:19 +00:00
public static Dictionary < string , bool > AlienRaceUseHumanlike = new Dictionary < string , bool > ( ) ;
private static void ResetAlienRaceUseHumanlike ( )
{
AlienRaceUseHumanlike . Clear ( ) ;
IEnumerable < ThingDef > HumanlikeRaces ;
HumanlikeRaces = DefDatabase < ThingDef > . AllDefs . Where ( b = > b . race ? . Humanlike = = true ) ;
foreach ( ThingDef raceDef in HumanlikeRaces )
{
//Default Value Is True
AlienRaceUseHumanlike . Add ( raceDef . defName , true ) ;
}
}
2023-04-04 01:47:49 +00:00
[Obsolete]
2022-08-14 20:46:19 +00:00
public static bool GetAlienRaceUseHumanlike ( string raceDef )
{
if ( AlienRaceUseHumanlike . NullOrEmpty ( ) )
{
ResetAlienRaceUseHumanlike ( ) ;
}
if ( AlienRaceUseHumanlike . ContainsKey ( raceDef ) )
return AlienRaceUseHumanlike [ raceDef ] ;
return false ;
}
public static List < string > GetAlienRacesDefNames ( )
{
if ( AlienRaceUseHumanlike . NullOrEmpty ( ) )
{
ResetAlienRaceUseHumanlike ( ) ;
}
//It must have one or more elements: human.
return AlienRaceUseHumanlike . Keys . ToList ( ) ;
}
public static void ClearAll ( )
{
SupportedApparelResultPath . Clear ( ) ;
SupportedBodyPartResultPath . Clear ( ) ;
SupportedApparelOriginalPath . Clear ( ) ;
AlienRaceUseHumanlike . Clear ( ) ;
}
//Apparels, Bodyparts can be used
public static PathAndSize GetSupportedApparelSizedPath ( SizedApparelDatabaseKey key )
{
int currentSize = - 1 ;
float currentSeverity = - 1 ;
return GetSupportedApparelSizedPath ( key , out currentSize , out currentSeverity ) ;
}
public static string GetSupportedApparelOriginalPath ( string path )
{
string outString ;
if ( SupportedApparelOriginalPath . TryGetValue ( path , out outString ) )
return outString ;
return null ;
}
public static Dictionary < string , BodyPartPoint > GetGraphicPoints ( string textuerPath )
{
//DefDatabase<>
return null ;
}
public static PathAndSize GetSupportedApparelSizedPath ( SizedApparelDatabaseKey key , out int indexOut , out float currentSeverityOut )
{
if ( SupportedApparelResultPath . ContainsKey ( key ) )
{
if ( SizedApparelSettings . Debug )
Log . Message ( "[Sized Apparel] SizedApparelDataBase::ValidKey: " + key . pathWithoutSizeIndex ) ;
var value = SupportedApparelResultPath . TryGetValue ( key ) ;
indexOut = value . size ;
currentSeverityOut = SizedApparelUtility . BreastSizeIndexToSeverity ( value . size ) ;
if ( SizedApparelSettings . Debug )
Log . Message ( "[Sized Apparel] SizedApparelDataBase::Result Path: " + value . pathWithSizeIndex ) ;
return value ;
}
2023-04-04 01:47:48 +00:00
2022-08-14 20:46:19 +00:00
if ( SizedApparelSettings . Debug )
Log . Message ( " [Sized Apparel] SizedApparelDataBase::Key Not Found: " + key . pathWithoutSizeIndex ) ;
PathAndSize result ;
Graphic sourceGraphic = GraphicDatabase . Get < Graphic_Multi > ( key . pathWithoutSizeIndex ) ;
bool flag ;
bool customPose = true ; //default none pose also custom pose
string hediffResult ;
string targetRaceName ;
//if (GetAlienRaceUseHumanlike(key.raceName))
//TODO. AlienRaceHumanlike
/ *
var pawnDef = DefDatabase < SizedApparelPawnDef > . GetNamed ( key . raceName ) ;
if ( pawnDef ! = null )
{
if ( pawnDef . isHumanlike )
targetRaceName = "Humanlike" ;
}
else
targetRaceName = key . raceName ; * /
2023-04-04 01:48:56 +00:00
AlienRaceSetting raceSetting ;
raceSetting = SizedApparelSettings . alienRaceSettings . FirstOrDefault ( ( AlienRaceSetting s ) = > s . raceName = = key . raceName ) ;
2022-08-14 20:46:19 +00:00
targetRaceName = key . raceName ;
2023-04-04 01:48:56 +00:00
if ( raceSetting ! = null & & raceSetting . allowRaceNamedApparel = = false )
{
targetRaceName = null ;
}
2022-08-14 20:46:19 +00:00
Graphic graphic = null ;
2023-04-04 01:47:48 +00:00
graphic = SizedApparelUtility . GetSizedApparelGraphic ( sourceGraphic , SizedApparelUtility . BreastSizeIndexToSeverity ( key . targetSize ) , out indexOut , out currentSeverityOut , out flag , out hediffResult , targetRaceName , key . hediffName , key . customPose , key . gender ) ; //key.customPose
if ( graphic = = null & & key . gender ! = Gender . None )
{
//try Genderless
graphic = SizedApparelUtility . GetSizedApparelGraphic ( sourceGraphic , SizedApparelUtility . BreastSizeIndexToSeverity ( key . targetSize ) , out indexOut , out currentSeverityOut , out flag , out hediffResult , targetRaceName , key . hediffName , key . customPose , Gender . None ) ; //key.customPose
}
2022-08-14 20:46:19 +00:00
if ( key . customPose ! = null & & graphic = = null )
{
customPose = false ;
2023-04-27 20:02:48 +00:00
graphic = SizedApparelUtility . GetSizedApparelGraphic ( sourceGraphic , SizedApparelUtility . BreastSizeIndexToSeverity ( key . targetSize ) , out indexOut , out currentSeverityOut , out flag , out hediffResult , targetRaceName , key . hediffName , null , key . gender ) ; //Search No Custom Pose
2023-04-04 01:47:48 +00:00
if ( graphic = = null & & key . gender ! = Gender . None )
{
//try Genderless
2023-04-27 20:02:48 +00:00
graphic = SizedApparelUtility . GetSizedApparelGraphic ( sourceGraphic , SizedApparelUtility . BreastSizeIndexToSeverity ( key . targetSize ) , out indexOut , out currentSeverityOut , out flag , out hediffResult , targetRaceName , key . hediffName , null , Gender . None ) ; //Search No Custom Pose
2023-04-04 01:47:48 +00:00
}
2022-08-14 20:46:19 +00:00
}
//Try Find Different Target Size
if ( flag = = true )
{
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , indexOut , false , customPose , hediffResult , key . bodyTypeName , key . raceName ) ;
2022-08-14 20:46:19 +00:00
SupportedApparelResultPath . SetOrAdd ( key , result ) ;
SupportedApparelOriginalPath . SetOrAdd ( result . pathWithSizeIndex , key . pathWithoutSizeIndex ) ;
2023-04-04 01:48:56 +00:00
return result ;
2022-08-14 20:46:19 +00:00
}
else
{
2023-04-04 01:48:56 +00:00
//Try Search Human Apparel. then null
if ( key . raceName ! = "Human" & & key . raceName ! = null ) // null check for avoid infinite loop
{
if ( raceSetting ! = null & & raceSetting . asHuman )
{
var newKey = new SizedApparelDatabaseKey ( key . pathWithoutSizeIndex , "Human" , key . bodyTypeName , key . gender , key . hediffName , key . targetSize , key . isHorny , key . customPose , key . variation ) ;
result = GetSupportedApparelSizedPath ( newKey , out indexOut , out currentSeverityOut ) ;
SupportedApparelResultPath . SetOrAdd ( key , result ) ;
SupportedApparelOriginalPath . SetOrAdd ( key . pathWithoutSizeIndex , key . pathWithoutSizeIndex ) ;
return result ;
}
else
{
var newKey = new SizedApparelDatabaseKey ( key . pathWithoutSizeIndex , null , key . bodyTypeName , key . gender , key . hediffName , key . targetSize , key . isHorny , key . customPose , key . variation ) ;
result = GetSupportedApparelSizedPath ( newKey , out indexOut , out currentSeverityOut ) ;
SupportedApparelResultPath . SetOrAdd ( key , result ) ;
SupportedApparelOriginalPath . SetOrAdd ( key . pathWithoutSizeIndex , key . pathWithoutSizeIndex ) ;
return result ;
}
}
if ( key . raceName = = "Human" )
{
var newKey = new SizedApparelDatabaseKey ( key . pathWithoutSizeIndex , null , key . bodyTypeName , key . gender , key . hediffName , key . targetSize , key . isHorny , key . customPose , key . variation ) ;
result = GetSupportedApparelSizedPath ( newKey , out indexOut , out currentSeverityOut ) ;
SupportedApparelResultPath . SetOrAdd ( key , result ) ;
SupportedApparelOriginalPath . SetOrAdd ( key . pathWithoutSizeIndex , key . pathWithoutSizeIndex ) ;
return result ;
}
2022-08-14 20:46:19 +00:00
result = new PathAndSize ( null , - 1 ) ;
SupportedApparelResultPath . SetOrAdd ( key , result ) ;
SupportedApparelOriginalPath . SetOrAdd ( key . pathWithoutSizeIndex , key . pathWithoutSizeIndex ) ;
2023-04-04 01:48:56 +00:00
return result ;
2022-08-14 20:46:19 +00:00
}
return result ;
}
2023-04-04 01:47:48 +00:00
public static PathAndSize GetSupportedBodyPartPath ( BodyPartDatabaseKey key , bool isBreast , string folderName , string defaultHediffName )
2022-08-14 20:46:19 +00:00
{
2023-04-04 01:47:49 +00:00
2022-08-14 20:46:19 +00:00
PathAndSize result ;
if ( SupportedBodyPartResultPath . ContainsKey ( key ) )
return SupportedBodyPartResultPath . TryGetValue ( key ) ;
int currentSize = - 1 ;
2023-04-27 20:02:48 +00:00
string hediffResult = null ;
2022-08-14 20:46:19 +00:00
Graphic graphic = null ;
2023-04-04 01:47:49 +00:00
//Find Points from result's path
//TODO: Build SizedApparel DataBase separate?
2022-08-14 20:46:19 +00:00
if ( key . customPose ! = null )
{
2023-04-04 01:47:48 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , key . bodyTypeName , key . hediffName , isBreast , key . targetSize , folderName + "/CustomPose/" + key . customPose , defaultHediffName , out currentSize , out hediffResult , key . isHorny , null , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , false , true , hediffResult , key . bodyTypeName , key . raceName ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2022-08-14 20:46:19 +00:00
return result ;
}
if ( key . bodyTypeName ! = null )
2023-04-04 01:47:48 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , null , key . hediffName , isBreast , key . targetSize , folderName + "/CustomPose/" + key . customPose , defaultHediffName , out currentSize , out hediffResult , key . isHorny , null , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , false , true , hediffResult , null , key . raceName ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2022-08-14 20:46:19 +00:00
return result ;
}
}
2023-04-04 01:47:48 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , key . bodyTypeName , key . hediffName , isBreast , key . targetSize , folderName , defaultHediffName , out currentSize , out hediffResult , key . isHorny , null , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , false , key . customPose = = null ? true : false , hediffResult , key . bodyTypeName , key . raceName ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
2023-04-04 01:47:49 +00:00
2022-08-14 20:46:19 +00:00
return result ;
}
if ( key . bodyTypeName ! = null )
2023-04-04 01:47:48 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , null , key . hediffName , isBreast , key . targetSize , folderName , defaultHediffName , out currentSize , out hediffResult , key . isHorny , null , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , false , key . customPose = = null ? true : false , hediffResult , null , key . raceName ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
//SizedApparelMod.CheckAndLoadAlienRaces();
//HumanLike Search
2023-04-04 01:48:55 +00:00
AlienRaceSetting raceSetting ;
raceSetting = SizedApparelSettings . alienRaceSettings . FirstOrDefault ( ( AlienRaceSetting s ) = > s . raceName = = key . raceName ) ;
2023-04-27 20:02:48 +00:00
if ( raceSetting ! = null & & ( key . raceName = = "Human" | | ! raceSetting . asHuman ) ) //old: !SizedApparelSettings.UnsupportedRaceToUseHumanlike
2022-08-14 20:46:19 +00:00
{
//Cannot find Any result
result = new PathAndSize ( null , - 1 ) ;
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
if ( key . customPose ! = null )
{
2023-04-04 01:47:49 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , key . bodyTypeName , key . hediffName , isBreast , key . targetSize , folderName + "/CustomPose/" + key . customPose , defaultHediffName , out currentSize , out hediffResult , key . isHorny , "Human" , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:47:50 +00:00
result = new PathAndSize ( graphic . path , currentSize , true , true , hediffResult , key . bodyTypeName ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
if ( key . bodyTypeName ! = null )
2023-04-04 01:47:49 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , null , key . hediffName , isBreast , key . targetSize , folderName + "/CustomPose/" + key . customPose , defaultHediffName , out currentSize , out hediffResult , key . isHorny , "Human" , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:47:50 +00:00
result = new PathAndSize ( graphic . path , currentSize , true , true , hediffResult , null ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
}
2023-04-04 01:47:49 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , key . bodyTypeName , key . hediffName , isBreast , key . targetSize , folderName , defaultHediffName , out currentSize , out hediffResult , key . isHorny , "Human" , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , true , key . customPose = = null ? true : false , hediffResult , key . bodyTypeName , "Human" ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
if ( key . bodyTypeName ! = null )
2023-04-04 01:47:49 +00:00
graphic = SizedApparelUtility . GetBodyPartGraphic ( key . raceName , null , key . hediffName , isBreast , key . targetSize , folderName , defaultHediffName , out currentSize , out hediffResult , key . isHorny , "Human" , key . variation , key . gender ) ;
2022-08-14 20:46:19 +00:00
if ( graphic ! = null )
{
2023-04-04 01:47:49 +00:00
//SizedApparelTexturePointDef PointsDef = DefDatabase<SizedApparelTexturePointDef>.AllDefs.FirstOrDefault((SizedApparelTexturePointDef s) => s.Path == graphic.path);
//if (SizedApparelSettings.Debug && PointsDef != null)
//{
// Log.Message("[SizedApparel] : Points Def Found : " + PointsDef.defName);
//}
2023-04-04 01:48:55 +00:00
result = new PathAndSize ( graphic . path , currentSize , true , key . customPose = = null ? true : false , hediffResult , null , "Human" ) ;
2022-08-14 20:46:19 +00:00
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
//Cannot find Any result
result = new PathAndSize ( null , - 1 ) ;
SupportedBodyPartResultPath . SetOrAdd ( key , result ) ;
return result ;
}
2023-04-04 01:47:48 +00:00
public static void RandomPreCacheForBodyParts ( )
{
//variationDef = DefDatabase<SizedApparelBodyPartVariationDef>.AllDefsListForReading;
BodyPartDatabaseKey key ;
for ( int i = 0 ; i < 11 ; i + + )
{
key = new BodyPartDatabaseKey ( "Human" , "Female" , "Breasts" , "Breasts" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , true , "Breasts" , "Breasts" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Breasts" , "Breasts" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , true , "Breasts" , "Breasts" ) ;
}
for ( int i = 0 ; i < 6 ; i + + )
{
key = new BodyPartDatabaseKey ( "Human" , "Female" , "Vagina" , "Vagina" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , false , "Vagina" , "Vagina" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Vagina" , "Vagina" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , false , "Vagina" , "Vagina" ) ;
}
for ( int i = 0 ; i < 6 ; i + + )
{
key = new BodyPartDatabaseKey ( "Human" , "Female" , "Anus" , "Anus" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , false , "Anus" , "Anus" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Anus" , "Anus" , Gender . Female , i ) ;
GetSupportedBodyPartPath ( key , false , "Anus" , "Anus" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Male" , "Anus" , "Anus" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Anus" , "Anus" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Anus" , "Anus" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Anus" , "Anus" ) ;
}
for ( int i = 0 ; i < 6 ; i + + )
{
key = new BodyPartDatabaseKey ( "Human" , "Male" , "Penis" , "Penis" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Male" , "Penis" , "Penis/Balls" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Penis" , "Penis" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Thin" , "Penis" , "Penis/Balls" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Fat" , "Penis" , "Penis" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Fat" , "Penis" , "Penis/Balls" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Hulk" , "Penis" , "Penis" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
key = new BodyPartDatabaseKey ( "Human" , "Hulk" , "Penis" , "Penis/Balls" , Gender . Male , i ) ;
GetSupportedBodyPartPath ( key , false , "Penis" , "Penis" ) ;
}
}
public static void RandomPreCacheForApparels ( )
{
//random precache should be useful. so it target female and thin body only.
//don't target male because the male doesn't need breasts textures usually.
List < string > bodyTypes = new List < string > ( ) ;
bodyTypes . Add ( "Female" ) ;
bodyTypes . Add ( "Thin" ) ;
// DefDatabase<BodyTypeDef>.AllDefsListForReading
foreach ( ThingDef thingDef in DefDatabase < ThingDef > . AllDefsListForReading )
{
if ( thingDef . IsApparel & & ! thingDef . apparel . wornGraphicPath . NullOrEmpty ( ) )
{
for ( int i = 0 ; i < 11 ; i + + )
{
var key = new SizedApparelDatabaseKey ( thingDef . apparel . wornGraphicPath , "Human" , "Female" , Gender . Female , "Breasts" , i ) ;
GetSupportedApparelSizedPath ( key ) ;
key = new SizedApparelDatabaseKey ( thingDef . apparel . wornGraphicPath , "Human" , "Thin" , Gender . Female , "Breasts" , i ) ;
GetSupportedApparelSizedPath ( key ) ;
//need Humanlike Cache?
}
}
}
}
2022-08-14 20:46:19 +00:00
}
}