-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #152 from RimWorldCCLTeam/development
v0.14.2 - Get your outfit ready!
- Loading branch information
Showing
94 changed files
with
3,275 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Verse; | ||
using CommunityCoreLibrary.Detour; | ||
|
||
namespace CommunityCoreLibrary | ||
{ | ||
|
||
public class OutfitDef : Def | ||
{ | ||
#region XML Data | ||
|
||
public ThingFilter filter = new ThingFilter(); | ||
|
||
#endregion | ||
|
||
public static OutfitDef Named(string defName) | ||
{ | ||
return DefDatabase<OutfitDef>.GetNamed(defName); | ||
} | ||
|
||
public override void ResolveReferences() | ||
{ | ||
base.ResolveReferences(); | ||
|
||
_OutfitDatabase.OutfitDefs.Add(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using RimWorld; | ||
using System.Collections.Generic; | ||
using Verse; | ||
|
||
namespace CommunityCoreLibrary.Detour | ||
{ | ||
internal static class _OutfitDatabase | ||
{ | ||
public static List<OutfitDef> OutfitDefs = new List<OutfitDef>(); | ||
|
||
internal static void _GenerateStartingOutfits(this OutfitDatabase outfitDatabase) | ||
{ | ||
outfitDatabase.MakeNewOutfit().label = "Anything"; | ||
|
||
Outfit outfit = outfitDatabase.MakeNewOutfit(); | ||
outfit.label = "Nothing"; | ||
outfit.filter.SetDisallowAll(); | ||
|
||
Outfit outfit1 = outfitDatabase.MakeNewOutfit(); | ||
outfit1.label = "Worker"; | ||
outfit1.filter.SetDisallowAll(); | ||
foreach (ThingDef allDef in DefDatabase<ThingDef>.AllDefs) | ||
{ | ||
if (allDef.apparel != null && allDef.apparel.defaultOutfitTags != null && allDef.apparel.defaultOutfitTags.Contains("Worker")) | ||
outfit1.filter.SetAllow(allDef, true); | ||
} | ||
|
||
Outfit outfit2 = outfitDatabase.MakeNewOutfit(); | ||
outfit2.label = "Soldier"; | ||
outfit2.filter.SetDisallowAll(); | ||
foreach (ThingDef allDef in DefDatabase<ThingDef>.AllDefs) | ||
{ | ||
if (allDef.apparel != null && allDef.apparel.defaultOutfitTags != null && allDef.apparel.defaultOutfitTags.Contains("Soldier")) | ||
outfit2.filter.SetAllow(allDef, true); | ||
} | ||
|
||
Outfit outfit3 = outfitDatabase.MakeNewOutfit(); | ||
outfit3.label = "Nudist"; | ||
outfit3.filter.SetDisallowAll(); | ||
foreach (ThingDef allDef in DefDatabase<ThingDef>.AllDefs) | ||
{ | ||
if (allDef.apparel != null && !allDef.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) && !allDef.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) | ||
outfit3.filter.SetAllow(allDef, true); | ||
} | ||
|
||
// do my stuff here | ||
foreach (OutfitDef outfitDef in OutfitDefs) | ||
{ | ||
Outfit newOutfit = outfitDatabase.MakeNewOutfit(); | ||
newOutfit.label = outfitDef.label; | ||
newOutfit.filter = outfitDef.filter; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
using System.Reflection; | ||
using System.Linq; | ||
|
||
using RimWorld; | ||
using Verse; | ||
using UnityEngine; | ||
|
||
namespace CommunityCoreLibrary.Detour | ||
{ | ||
|
||
internal static class _Pawn_RelationsTracker | ||
{ | ||
|
||
internal static LifeStageDef MechanoidFullyFormed = DefDatabase<LifeStageDef>.GetNamed( "MechanoidFullyFormed" ); | ||
|
||
internal static FieldInfo _pawn; | ||
|
||
internal static Pawn GetPawn( this Pawn_RelationsTracker _this ) | ||
{ | ||
if( _pawn == null ) | ||
{ | ||
_pawn = typeof( Pawn_RelationsTracker ).GetField( "pawn", BindingFlags.Instance | BindingFlags.NonPublic ); | ||
if( _pawn == null ) | ||
{ | ||
Log.ErrorOnce( "Unable to reflect Pawn_RelationsTracker.pawn!", 0x12348765 ); | ||
} | ||
} | ||
return (Pawn)_pawn.GetValue( _this ); | ||
} | ||
|
||
internal static bool PawnsAreValidMatches( Pawn pawn1, Pawn pawn2 ) | ||
{ | ||
/* | ||
Log.Message( | ||
string.Format( | ||
"PawnsAreValidMatches( {0}, {1} )\n\t{0} is human like: {2}\n\t{1} is human like: {3}\n\t{0} gender: {4}\n\t{1} gender: {5}\n\t{0} is gay: {6}\n\t{1} is gay: {7}\n\t{0} PawnKindDef: {8}\n\t{1} PawnKindDef: {9}", | ||
pawn1.LabelShort, | ||
pawn2.LabelShort, | ||
pawn1.RaceProps.Humanlike, | ||
pawn2.RaceProps.Humanlike, | ||
pawn1.gender, | ||
pawn2.gender, | ||
pawn1.story.traits.HasTrait(TraitDefOf.Gay), | ||
pawn2.story.traits.HasTrait(TraitDefOf.Gay), | ||
pawn1.kindDef.defName, | ||
pawn2.kindDef.defName | ||
) ); | ||
*/ | ||
if( | ||
( !pawn1.RaceProps.Humanlike )|| | ||
( | ||
( pawn1.RaceProps.Humanlike )&& | ||
( !pawn2.RaceProps.Humanlike ) | ||
)|| | ||
( pawn1 == pawn2 )|| | ||
( pawn1.RaceProps.fleshType != FleshType.Normal )|| | ||
( pawn2.RaceProps.fleshType != FleshType.Normal ) | ||
/*|| | ||
( | ||
( !pawn1.RaceProps.lifeStageAges.NullOrEmpty() )&& | ||
( pawn1.RaceProps.lifeStageAges.Any( stage => stage.def == MechanoidFullyFormed ) ) | ||
)|| | ||
( | ||
( !pawn2.RaceProps.lifeStageAges.NullOrEmpty() )&& | ||
( pawn2.RaceProps.lifeStageAges.Any( stage => stage.def == MechanoidFullyFormed ) ) | ||
)*/ | ||
) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
internal static float _CompatibilityWith( this Pawn_RelationsTracker _this, Pawn otherPawn ) | ||
{ | ||
var pawn = _this.GetPawn(); | ||
if( !PawnsAreValidMatches( pawn, otherPawn ) ) | ||
{ | ||
return 0f; | ||
} | ||
return Mathf.Clamp( GenMath.LerpDouble( 0.0f, 20f, 0.45f, -0.45f, Mathf.Abs( pawn.ageTracker.AgeBiologicalYearsFloat - otherPawn.ageTracker.AgeBiologicalYearsFloat ) ), -0.45f, 0.45f) + _this.ConstantPerPawnsPairCompatibilityOffset( otherPawn.thingIDNumber ); | ||
} | ||
|
||
internal static float _AttractionTo( this Pawn_RelationsTracker _this, Pawn otherPawn ) | ||
{ | ||
var pawn = _this.GetPawn(); | ||
|
||
if( !PawnsAreValidMatches( pawn, otherPawn ) ) | ||
{ | ||
return 0f; | ||
} | ||
float num = 1f; | ||
float num2 = 1f; | ||
float ageBiologicalYearsFloat = pawn.ageTracker.AgeBiologicalYearsFloat; | ||
float ageBiologicalYearsFloat2 = otherPawn.ageTracker.AgeBiologicalYearsFloat; | ||
if( pawn.gender == Gender.Male ) | ||
{ | ||
if( | ||
( pawn.RaceProps.Humanlike )&& | ||
( pawn.story.traits.HasTrait( TraitDefOf.Gay ) ) | ||
) | ||
{ | ||
if( otherPawn.gender == Gender.Female ) | ||
{ | ||
return 0f; | ||
} | ||
} | ||
else if( otherPawn.gender == Gender.Male ) | ||
{ | ||
return 0f; | ||
} | ||
num2 = GenMath.FlatHill( 16f, 20f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 15f, ageBiologicalYearsFloat2 ); | ||
} | ||
else if( pawn.gender == Gender.Female ) | ||
{ | ||
if( | ||
( pawn.RaceProps.Humanlike )&& | ||
( pawn.story.traits.HasTrait( TraitDefOf.Gay ) ) | ||
) | ||
{ | ||
if( otherPawn.gender == Gender.Male ) | ||
{ | ||
return 0f; | ||
} | ||
} | ||
else if( otherPawn.gender == Gender.Female ) | ||
{ | ||
num = 0.15f; | ||
} | ||
if( ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 10f ) | ||
{ | ||
return 0f; | ||
} | ||
if( ageBiologicalYearsFloat2 < ageBiologicalYearsFloat - 3f ) | ||
{ | ||
num2 = Mathf.InverseLerp( ageBiologicalYearsFloat - 10f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat2 ) * 0.2f; | ||
} | ||
else | ||
{ | ||
num2 = GenMath.FlatHill( 0.2f, ageBiologicalYearsFloat - 3f, ageBiologicalYearsFloat, ageBiologicalYearsFloat + 10f, ageBiologicalYearsFloat + 40f, 0.1f, ageBiologicalYearsFloat2 ); | ||
} | ||
} | ||
float num3 = 1f; | ||
num3 *= Mathf.Lerp( 0.2f, 1f, otherPawn.health.capacities.GetEfficiency( PawnCapacityDefOf.Talking ) ); | ||
num3 *= Mathf.Lerp( 0.2f, 1f, otherPawn.health.capacities.GetEfficiency( PawnCapacityDefOf.Manipulation ) ); | ||
num3 *= Mathf.Lerp( 0.2f, 1f, otherPawn.health.capacities.GetEfficiency( PawnCapacityDefOf.Moving ) ); | ||
float num4 = 1f; | ||
foreach( PawnRelationDef current in pawn.GetRelations( otherPawn ) ) | ||
{ | ||
num4 *= current.attractionFactor; | ||
} | ||
int num5 = 0; | ||
if( otherPawn.RaceProps.Humanlike ) | ||
{ | ||
num5 = otherPawn.story.traits.DegreeOfTrait( TraitDefOf.Beauty ); | ||
} | ||
float num6 = 1f; | ||
if( num5 < 0 ) | ||
{ | ||
num6 = 0.3f; | ||
} | ||
else if( num5 > 0 ) | ||
{ | ||
num6 = 2.3f; | ||
} | ||
float num7 = Mathf.InverseLerp( 15f, 18f, ageBiologicalYearsFloat ); | ||
float num8 = Mathf.InverseLerp( 15f, 18f, ageBiologicalYearsFloat2 ); | ||
return num * num2 * num3 * num4 * num7 * num8 * num6; | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.