Mirror of 1.4.22 from Lovers Lab

This commit is contained in:
ghostclinic3YTB 2023-04-03 21:48:55 -04:00
parent 5d0da3bc88
commit b501ddfb0f
1119 changed files with 12505 additions and 2543 deletions

View file

@ -11,6 +11,27 @@ using rjw;
namespace SizedApparel
{
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
{
}
public static class SizedApparelsDatabase
{
@ -20,6 +41,12 @@ namespace SizedApparel
}
public static void LoadPreDefinedData()
{
}
public struct SizedApparelDatabaseKey
{
@ -107,18 +134,23 @@ namespace SizedApparel
public bool isUnsupportedHumanlikePath;
public bool isCustomPose;
public string hediffName;
public Dictionary<string, BodyPartPoint> points;
public string bodyType; // useful for bodypart Graphic (body addons).
public string raceName; // for check is Human or Alien or Alien as Human.
public SizedApparelTexturePointDef points;
public PathAndSize(string path, int index, bool unsupportedHumanlike = false, bool customPose = false, string hediff = null ,Dictionary<string, BodyPartPoint> pointsInput = null)
public PathAndSize(string path, int index, bool unsupportedHumanlike = false, bool customPose = false, string hediff = null, string bodytype = null, string raceName = null, SizedApparelTexturePointDef pointsInput = null)
{
this.pathWithSizeIndex = path;
this.size = index;
this.isUnsupportedHumanlikePath = unsupportedHumanlike;
this.isCustomPose = customPose;
this.hediffName = hediff;
this.bodyType = bodytype;
this.points = pointsInput;
this.raceName = raceName;
}
}
private static Dictionary<Pawn, ApparelRecorderComp> ApparelRecordersCache = new Dictionary<Pawn, ApparelRecorderComp>();
private static Dictionary<BodyGraphicKey, Graphic> SizedApparelBodyGraphic = new Dictionary<BodyGraphicKey, Graphic>(); // TODO
private static Dictionary<SizedApparelDatabaseKey, PathAndSize> SupportedApparelResultPath = new Dictionary<SizedApparelDatabaseKey, PathAndSize>(new SizedApparelDatabaseKeyComparer());
@ -128,6 +160,14 @@ namespace SizedApparel
//AlienRace AllowHumanlike. Need to Restart or Clear cache to change options
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;
}
public static Dictionary<string, bool> AlienRaceUseHumanlike = new Dictionary<string, bool>();
private static void ResetAlienRaceUseHumanlike()
@ -142,7 +182,8 @@ namespace SizedApparel
AlienRaceUseHumanlike.Add(raceDef.defName, true);
}
}
[Obsolete]
public static bool GetAlienRaceUseHumanlike(string raceDef)
{
if (AlienRaceUseHumanlike.NullOrEmpty())
@ -255,7 +296,7 @@ namespace SizedApparel
//Try Find Different Target Size
if (flag == true)
{
result = new PathAndSize(graphic.path, indexOut, false, customPose, hediffResult);
result = new PathAndSize(graphic.path, indexOut, false, customPose, hediffResult, key.bodyTypeName, key.raceName);
SupportedApparelResultPath.SetOrAdd(key, result);
SupportedApparelOriginalPath.SetOrAdd(result.pathWithSizeIndex, key.pathWithoutSizeIndex);
}
@ -270,27 +311,43 @@ namespace SizedApparel
public static PathAndSize GetSupportedBodyPartPath(BodyPartDatabaseKey key, bool isBreast, string folderName, string defaultHediffName)
{
PathAndSize result;
if (SupportedBodyPartResultPath.ContainsKey(key))
return SupportedBodyPartResultPath.TryGetValue(key);
int currentSize = -1;
string hediffResult;
Graphic graphic = null;
//Find Points from result's path
//TODO: Build SizedApparel DataBase separate?
if (key.customPose != null)
{
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, false, true, hediffResult);
result = new PathAndSize(graphic.path, currentSize, false, true, hediffResult, key.bodyTypeName, key.raceName);
SupportedBodyPartResultPath.SetOrAdd(key, result);
//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);
//}
return result;
}
if (key.bodyTypeName != null)
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, false, true, hediffResult);
result = new PathAndSize(graphic.path, currentSize, false, true, hediffResult , null, key.raceName);
SupportedBodyPartResultPath.SetOrAdd(key, result);
//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);
//}
return result;
}
@ -298,8 +355,14 @@ namespace SizedApparel
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, false, key.customPose == null ? true : false, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, false, key.customPose == null ? true : false, hediffResult , key.bodyTypeName, key.raceName);
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
@ -307,7 +370,12 @@ namespace SizedApparel
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, null, key.hediffName, isBreast, key.targetSize, folderName, defaultHediffName, out currentSize, out hediffResult, key.isHorny, null, key.variation, key.gender);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, false, key.customPose == null ? true : false, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, false, key.customPose == null ? true : false, hediffResult, null, key.raceName);
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
@ -315,8 +383,9 @@ namespace SizedApparel
//SizedApparelMod.CheckAndLoadAlienRaces();
//HumanLike Search
var raceSetting = SizedApparelSettings.alienRaceSettings.FirstOrDefault((AlienRaceSetting s) => s.raceName == key.raceName);
if (raceSetting !=null && !raceSetting.asHumanlike) //old: !SizedApparelSettings.UnsupportedRaceToUseHumanlike
AlienRaceSetting raceSetting;
raceSetting = SizedApparelSettings.alienRaceSettings.FirstOrDefault((AlienRaceSetting s) => s.raceName == key.raceName);
if (raceSetting !=null && key.raceName == "Human" || !raceSetting.asHuman) //old: !SizedApparelSettings.UnsupportedRaceToUseHumanlike
{
//Cannot find Any result
result = new PathAndSize(null, -1);
@ -326,36 +395,56 @@ namespace SizedApparel
if (key.customPose != null)
{
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, key.bodyTypeName, key.hediffName, isBreast, key.targetSize, folderName + "/CustomPose/" + key.customPose, defaultHediffName, out currentSize, out hediffResult, key.isHorny, "Humanlike", key.variation, key.gender);
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, true, true, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, true, true, hediffResult, key.bodyTypeName);
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
if (key.bodyTypeName != null)
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, null, key.hediffName, isBreast, key.targetSize, folderName + "/CustomPose/" + key.customPose, defaultHediffName, out currentSize, out hediffResult, key.isHorny, "Humanlike", key.variation, key.gender);
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, true, true, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, true, true, hediffResult, null);
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
}
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, key.bodyTypeName, key.hediffName, isBreast, key.targetSize, folderName, defaultHediffName, out currentSize, out hediffResult, key.isHorny, "Humanlike", key.variation, key.gender);
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);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, true, key.customPose == null ? true : false, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, true, key.customPose == null ? true : false, hediffResult, key.bodyTypeName, "Human");
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
if (key.bodyTypeName != null)
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, null, key.hediffName, isBreast, key.targetSize, folderName, defaultHediffName, out currentSize, out hediffResult, key.isHorny, "Humanlike", key.variation, key.gender);
graphic = SizedApparelUtility.GetBodyPartGraphic(key.raceName, null, key.hediffName, isBreast, key.targetSize, folderName, defaultHediffName, out currentSize, out hediffResult, key.isHorny, "Human", key.variation, key.gender);
if (graphic != null)
{
result = new PathAndSize(graphic.path, currentSize, true, key.customPose == null ? true : false, hediffResult);
//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);
//}
result = new PathAndSize(graphic.path, currentSize, true, key.customPose == null ? true : false, hediffResult, null, "Human");
SupportedBodyPartResultPath.SetOrAdd(key, result);
return result;
}
@ -368,5 +457,95 @@ namespace SizedApparel
return result;
}
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?
}
}
}
}
}
}