Skip to content

Commit

Permalink
Updated to support latest HAR version
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeracronius committed Jan 30, 2024
1 parent f9a2f7e commit dac7c9e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 56 deletions.
22 changes: 0 additions & 22 deletions Schemas/MorphDef.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -136,27 +136,6 @@
<xs:element name="revertedMemoryBP" type="xs:string" minOccurs="0" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="TraitSettings">
<xs:sequence>
<xs:element name="forcedTraits" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="li" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="chance" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="commonalityMale" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="commonalityFemale" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="defName" type="xs:string" maxOccurs="1" minOccurs="1" />
<xs:element name="degree" type="xs:int" maxOccurs="1" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="AddedAspect">
<xs:sequence>
<xs:element name="def" type="xs:string" minOccurs="1" maxOccurs="1" />
Expand Down Expand Up @@ -273,7 +252,6 @@
<xs:element name="statModifiers" type="StatModifiersList" minOccurs="0" maxOccurs="1" />
<xs:element name="thoughtSettings" type="HybridThoughtSettings" maxOccurs="1" minOccurs="0" />
<xs:element name="graphicsSettings" type="GraphicsSettings" minOccurs="0" maxOccurs="1" />
<xs:element name="traitSettings" type="TraitSettings" minOccurs="0" maxOccurs="1" />

<xs:element name="explicitHybridRace" type="xs:string" minOccurs="0" maxOccurs="1">
<xs:annotation>
Expand Down
Binary file modified Source/Dependencies/AlienRace.dll
Binary file not shown.
17 changes: 0 additions & 17 deletions Source/Pawnmorphs/Esoteria/Hybrids/HybridRaceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class HybridRaceSettings
public RaceRestrictionSettings restrictionSettings;
/// <summary>The graphics settings</summary>
public GraphicsSettings graphicsSettings;
/// <summary>The trait settings</summary>
public TraitSettings traitSettings;

/// <summary>
/// The explicit hybrid race
Expand Down Expand Up @@ -252,21 +250,6 @@ public class FoodSettings
public List<FoodCategoryOverride> foodOverrides = new List<FoodCategoryOverride>();
}

//should this be deprecated?
/// <summary>
/// obsolete
/// </summary>
[Obsolete]
public class TraitSettings
{
/// <summary>
///
/// </summary>
//should this be deprecated?
public List<AlienChanceEntry<TraitDef>> forcedTraits;
//public List<string> disallowedTraits; removing traits not supported right now, rimworld doesn't like it when you remove them
}

/// <summary>
/// generate AlienRace thought settings with the given morph def
/// </summary>
Expand Down
19 changes: 10 additions & 9 deletions Source/Pawnmorphs/Esoteria/Hybrids/RaceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,10 @@ private static void CreateImplicitMeshes(ThingDef_AlienRace race)
/// <returns></returns>
private static GeneralSettings GenerateHybridGeneralSettings(GeneralSettings human, MorphDef morph, ThingDef_AlienRace impliedRace)
{
var traitSettings = morph.raceSettings.traitSettings;
return new GeneralSettings
{
alienPartGenerator = GenerateHybridGenerator(human.alienPartGenerator, morph, impliedRace),
humanRecipeImport = true,
forcedRaceTraitEntries = traitSettings?.forcedTraits
// Black list is not currently supported, Rimworld doesn't like it when you remove traits.
humanRecipeImport = true
};
}

Expand All @@ -310,10 +307,8 @@ private static AlienPartGenerator GenerateHybridGenerator(AlienPartGenerator hum
{
bodyTypes = human.bodyTypes.MakeSafe().ToList(),
headTypes = human.headTypes.MakeSafe().ToList(),
offsetDefaults = human.offsetDefaults.MakeSafe().ToList(),
headOffset = human.headOffset,
headOffsetSpecific = human.headOffsetSpecific,
headOffsetDirectional = human.headOffsetDirectional,
bodyAddons = GenerateBodyAddons(human.bodyAddons, morph),
colorChannels = human.colorChannels,
alienProps = impliedRace
Expand Down Expand Up @@ -497,7 +492,7 @@ private static ThingDef_AlienRace.AlienSettings GenerateHybridAlienSettings(Thin
GeneralSettings generalSettings = GenerateHybridGeneralSettings(human.generalSettings, morph, impliedRace);
return new ThingDef_AlienRace.AlienSettings
{
generalSettings = GenerateHybridGeneralSettings(human.generalSettings, morph, impliedRace),
generalSettings = generalSettings,
graphicPaths = GenerateGraphicPaths(human.graphicPaths, morph, generalSettings),
styleSettings = human.styleSettings,
raceRestriction = GenerateHybridRestrictionSettings(human.raceRestriction, morph),
Expand Down Expand Up @@ -652,7 +647,14 @@ public static void DoHarStuff()
{
foreach (ThingDef_AlienRace race in _raceLookupTable.Keys)
{
DoHarStuff(race);
try
{
DoHarStuff(race);
}
catch (Exception e)
{
Log.Error($"[Pawnmorpher] Failed to properly add {race.defName} to HAR.\n" + e);
}
}
}

Expand Down Expand Up @@ -743,7 +745,6 @@ private static void DoHarStuff(ThingDef_AlienRace ar)
}
ThingCategoryDefOf.CorpsesHumanlike.ResolveReferences();
}
ar.alienRace.generalSettings.alienPartGenerator.GenerateMeshsAndMeshPools();
if (ar.alienRace.generalSettings.humanRecipeImport && ar != ThingDefOf.Human)
{
(ar.recipes ?? (ar.recipes = new List<RecipeDef>())).AddRange(ThingDefOf.Human.recipes.Where((RecipeDef rd) => !rd.targetsBodyPart || rd.appliedOnFixedBodyParts.NullOrEmpty() || rd.appliedOnFixedBodyParts.Any((BodyPartDef bpd) => ar.race.body.AllParts.Any((BodyPartRecord bpr) => bpr.def == bpd))));
Expand Down
10 changes: 5 additions & 5 deletions Source/Pawnmorphs/Esoteria/Hybrids/RaceShiftUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -678,10 +678,10 @@ static void ReRollRaceTraits(Pawn pawn, ThingDef_AlienRace newRace)


var traitsToAdd = allAlienTraits;
foreach (AlienChanceEntry<TraitDef> alienTraitEntry in traitsToAdd)
foreach (AlienChanceEntry<TraitWithDegree> alienTraitEntry in traitsToAdd)
{
var def = alienTraitEntry.defName;
if (traitSet.HasTrait(def)) continue; //don't add traits that are already added
var trait = alienTraitEntry.defName;
if (traitSet.HasTrait(trait.def)) continue; //don't add traits that are already added

var add = (Rand.RangeInclusive(0, 100) <= alienTraitEntry.chance);

Expand All @@ -697,9 +697,9 @@ static void ReRollRaceTraits(Pawn pawn, ThingDef_AlienRace newRace)

if (add)
{
var degree = def.DataAtDegree(alienTraitEntry.degree);
var degree = trait.def.DataAtDegree(trait.degree);

traitSet.GainTrait(new Trait(def, alienTraitEntry.degree, true));
traitSet.GainTrait(new Trait(trait.def, trait.degree, true));
if (degree.skillGains != null)
UpdateSkillsPostAdd(pawn, degree.skillGains); //need to update the skills manually
}
Expand Down
4 changes: 1 addition & 3 deletions Source/Pawnmorphs/Esoteria/PawnmorpherModInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,8 @@ private static void CheckDefaultOffsets([NotNull] ThingDef_AlienRace aRace, [Not

foreach (AlienPartGenerator.OffsetNamed hDefaultOffset in hSettings.offsetDefaults)
{
if (aSettings.offsetDefaults.All(a => a.name != hDefaultOffset.name))
{
if (aSettings.offsetDefaults.Any(a => a.name != hDefaultOffset.name))
aSettings.offsetDefaults.Add(hDefaultOffset);
}
}

}
Expand Down

0 comments on commit dac7c9e

Please sign in to comment.