diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8dd4607
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,398 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
\ No newline at end of file
diff --git a/1.4/Assemblies/RJW-Quirks.dll b/1.4/Assemblies/RJW-Quirks.dll
new file mode 100644
index 0000000..0d790aa
Binary files /dev/null and b/1.4/Assemblies/RJW-Quirks.dll differ
diff --git a/1.4/Defs/QuirkDefs/QuirkDef.xml b/1.4/Defs/QuirkDefs/QuirkDef.xml
new file mode 100644
index 0000000..ac2ac01
--- /dev/null
+++ b/1.4/Defs/QuirkDefs/QuirkDef.xml
@@ -0,0 +1,116 @@
+
+
+
+
+ Breeder
+ Breeder
+ {pawn} has given birth so many times that {pawn_possessive} body has adapted to breeding. {pawn_possessive} pregnancies are shorter and produce more offspring.
+ ForcedOnly
+ true
+
+
+ RecordChanged
+ CountOfBirthHuman
+ 10
+
+
+ RecordChanged
+ CountOfBirthAnimal
+ 20
+
+
+ maxLitterOnBirth
+ 2.0
+
+
+
+
+
+ Fertile
+ Fertile
+ {pawn} has unusually high fertility and so is more likely to have children.
+
+ Infertile
+
+
+
+
+ RaceHasNoFertility
+
+
+
+
+ QuirkAddedTo
+ IncreasedFertility
+
+
+ QuirkRemovedFrom
+ IncreasedFertility
+
+
+
+
+
+ Incubator
+ Incubator
+ {pawn} has birthed so many eggs that {pawn_possessive} body has adapted to handling them. {pawn_possessive} egg incubation speed has increased.
+ ForcedOnly
+ true
+
+
+ RecordChanged
+ CountOfBirthEgg
+ 100
+
+
+ maxEggsSize
+ 2.0
+
+
+ maxLitterOnBirth
+ 2.0
+
+
+
+
+
+ Infertile
+ Infertile
+ {pawn} has unusually low fertility and so is unlikely to have children.
+
+ Fertile
+
+
+
+
+ RaceHasNoFertility
+
+
+
+
+ QuirkAddedTo
+ DecreasedFertility
+
+
+ QuirkRemovedFrom
+ DecreasedFertility
+
+
+
+
+
+ Messy
+ Messy
+ {pawn} not only produces copious amounts of fluid during sex but {pawn_pronoun} rarely bothers to clean {pawn_possessive}self afterwards.
+
+
+ cumFilthAmount
+ 2.0
+
+
+ cleanAfterFapChance
+ -0.75
+
+
+
+
\ No newline at end of file
diff --git a/1.4/Defs/QuirkDefs/QuirkDef_Humanlike.xml b/1.4/Defs/QuirkDefs/QuirkDef_Humanlike.xml
new file mode 100644
index 0000000..222ecd3
--- /dev/null
+++ b/1.4/Defs/QuirkDefs/QuirkDef_Humanlike.xml
@@ -0,0 +1,268 @@
+
+
+
+
+
+
+
+ NotHumanlike
+
+
+
+
+
+ Endytophile
+ Endytophile
+ {pawn} prefers to keep {pawn_possessive} clothes on during sex.
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+
+
+
+ Exhibitionist
+ Exhibitionist
+ {pawn} enjoys having sex where others can see.
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+
+
+
+ Gerontophile
+ Gerontophile
+ {pawn} prefers older partners (55+ on a human scale).
+
+ 55
+
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+ ageFactor
+ 1.0
+ First
+
+
+
+
+
+ ImpregnationFetish
+ Impregnation fetish
+ {pawn} really likes the idea of someone becoming pregnant. {pawn_pronoun} prefers partners and sex positions where there is a possibility of pregnancy. {pawn_pronoun} doesn't care if {pawn_pronoun} is getting pregnant or {pawn_possessive} partner is as long as babby is formed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+
+ RecordChanged
+ CountOfBirthHuman
+ 10
+ {pawn} has given birth so many times that {pawn_pronoun} developed a fetish for impregnation
+
+
+ RecordChanged
+ CountOfBirthAnimal
+ 20
+ {pawn} has given birth so many times that {pawn_pronoun} developed a fetish for impregnation
+
+
+ RecordChanged
+ CountOfBirthEgg
+ 100
+ {pawn} has birthed so many eggs that {pawn_pronoun} developed a fetish for impregnation
+
+
+ bodyFactor
+ 1.25
+
+
+
+
+
+ Podophile
+ Podophile
+ {pawn} really likes feet and prefers foot-related sex acts.
+
+ Footjob
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+
+
+ Foot
+ 2.0
+
+
+
+
+
+
+
+ PregnancyFetish
+ Pregnancy fetish
+ {pawn} prefers partners who are visibly pregnant.
+
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+ bodyFactor
+ 1.25
+
+
+
+
+
+ Sapiosexual
+ Sapiosexual
+ {pawn} prefers smart partners.
+
+
+
+ Transhumanist
+
+
+ GreatMemory
+
+
+ TooSmart
+
+
+ RCT_Savant
+
+
+ RCT_Inventor
+
+
+ SYR_CreativeThinker
+
+
+ Intellectual
+ 15
+
+
+
+
+
+ opinionFactor
+ 1.4
+
+
+
+
+
+ Somnophile
+ Somnophile
+ {pawn} prefers {pawn_possessive} partners to be asleep.
+
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+ bodyFactor
+ 1.25
+
+
+
+
+
+ Teratophile
+ Teratophile
+ {pawn} prefers ugly partners. {pawn_pronoun} would also prefer larger and wilder animals if {pawn_pronoun} were into that sort of thing...
+
+
+
+ CreepyBreathing
+
+
+ Beauty
+ -1
+
+
+ Beauty
+ -2
+
+
+ Fat
+
+
+
+ PawnBeauty
+ -0.1
+
+
+
+
+
+ bodyFactor
+ 1.4
+ First
+
+
+
+ wouldFuckAnimalBodySizeMin
+ 0.8
+
+
+ wouldFuckAnimalBodySizeMax
+ 2.0
+
+
+ wouldFuckAnimalWildnessModifier
+ 0.3
+
+
+
+
+
+ Vigorous
+ Vigorous
+ {pawn} is invigorated by sex. {pawn_pronoun} does not get tired as much during sex.
+
+
+ ticksToNextLovin
+ 0.8
+
+
+ reduceRest
+ 0.5
+
+
+
+
\ No newline at end of file
diff --git a/1.4/Defs/QuirkDefs/QuirkDef_RaceTag.xml b/1.4/Defs/QuirkDefs/QuirkDef_RaceTag.xml
new file mode 100644
index 0000000..9579cc9
--- /dev/null
+++ b/1.4/Defs/QuirkDefs/QuirkDef_RaceTag.xml
@@ -0,0 +1,188 @@
+
+
+
+
+
+
+
+
+ Orgasm
+ ThatsMyFetish
+
+
+
+
+
+ ChitinLover
+ Chitin lover
+ {pawn} enjoys the smooth strength of a chitinous exoskeleton. {pawn_pronoun} prefers arachnoid or insectoid partners.
+
+ Chitin
+
+
+
+
+
+
+ Chitin
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ DemonLover
+ Demon lover
+ {pawn} is after the naughty ones. {pawn_pronoun} prefers {pawn_possessive} partners to come from the literal depths of hell, or at least look the part.
+
+ Demon
+
+
+
+
+
+ Demon
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ FeatherLover
+ Feather lover
+ {pawn} loves that downy fluff. {pawn_pronoun} prefers avian or dinosaur partners. Because dinosaurs are birds and have feathers, as {pawn_pronoun} will explain at great length if given a chance.
+
+ Feathers
+
+
+
+
+
+ Feathers
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ FurLover
+ Fur lover
+ {pawn} prefers a partner with a thick, luxurious, snuggly-soft coat of fur.
+
+ Fur
+
+
+
+
+
+ Fur
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ PlantLover
+ Plant lover
+ {pawn} likes watering plants. If you know what I mean.
+
+ Plant
+
+
+
+
+
+ Plant
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ RobotLover
+ Robot lover
+ Which is better, 2D or 3D? {pawn} knows that 3D-printed gives you the best of both worlds.
+
+ Robot
+
+
+
+
+
+ Robot
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ ScaleLover
+ Scale lover
+ Who wouldn't want to fuck a dragon? Definitely not {pawn}. {pawn} wants to fuck a dragon.
+
+ Scales
+
+
+
+
+
+ Scales
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ SkinLover
+ Skin lover
+ {pawn} prefers {pawn_possessive} partners to have smooth sensitive skin without fur or scales getting in the way. Lucky for {pawn_objective} humans are all over the place.
+
+ Skin
+
+
+
+
+
+ Skin
+
+
+ QuirkForOwnRace
+
+
+
+
+
+ SlimeLover
+ Slime lover
+ Because of their slippery and malleable nature slimes are very, very good at sex. As you will hear over and over if you listen to {pawn} talk for any length of time.
+
+ Slime
+
+
+
+
+
+ Slime
+
+
+ QuirkForOwnRace
+
+
+
+
\ No newline at end of file
diff --git a/1.4/Defs/RjwEventDefs/RjwEventDef.xml b/1.4/Defs/RjwEventDefs/RjwEventDef.xml
new file mode 100644
index 0000000..3018066
--- /dev/null
+++ b/1.4/Defs/RjwEventDefs/RjwEventDef.xml
@@ -0,0 +1,43 @@
+
+
+
+
+
+ QuirkAddedTo
+
+ Pawn
+ Quirk
+
+
+
+
+ QuirkRemovedFrom
+
+ Pawn
+ Quirk
+
+
+
+
+ Orgasm
+
+ SexProps
+
+
+
+
+ RecordChanged
+
+ Pawn
+ Record
+
+
+
+
+ PawnSexualized
+
+ Pawn
+
+
+
+
\ No newline at end of file
diff --git a/1.4/Defs/RjwEventHandlerDefs/QuirkHandlers.xml b/1.4/Defs/RjwEventHandlerDefs/QuirkHandlers.xml
new file mode 100644
index 0000000..7bb1fc7
--- /dev/null
+++ b/1.4/Defs/RjwEventHandlerDefs/QuirkHandlers.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+ Quirk
+ rjwquirks.Modules.Quirks.EventHandlers.QuirkRjwEventHandler
+
+ QuirkAddedTo
+ QuirkRemovedFrom
+
+
+
+
+ QuirkSet
+ rjwquirks.Modules.Quirks.EventHandlers.QuirkSetRjwEventHandler
+
+ Orgasm
+
+
+
+
+ QuirkRecordChanged
+ rjwquirks.Modules.Quirks.EventHandlers.RecordChangedRjwEventHandler
+
+ RecordChanged
+
+
+
+
+ QuirkGenerator
+ rjwquirks.Modules.Quirks.EventHandlers.QuirkGenerator
+
+ PawnSexualized
+
+
+
+
\ No newline at end of file
diff --git a/About/About.xml b/About/About.xml
new file mode 100644
index 0000000..bd4a5d3
--- /dev/null
+++ b/About/About.xml
@@ -0,0 +1,34 @@
+
+
+
+ RJW Quirks
+ Rain
+
+
+ 1.4
+
+ rain.quirks
+
+
+ brrainz.harmony
+ Harmony
+ steam://url/CommunityFilePage/2009463077
+ https://github.com/pardeike/HarmonyRimWorld/releases/latest
+
+
+
+ rim.job.world
+
+
+ gregorycurrie.AnimalGenetics
+ EdB.PrepareCarefully
+ EdB.PrepareCarefully.UnofficialPatch
+ Dalrae.GaramRaceAddon
+ IGNI.LostForest
+ Sierra.RT.MedievalTalents
+ com.yayo.raceQuestPawn
+
+
+big peepee sim
+
+
diff --git a/RJW-Quirks/Core.cs b/RJW-Quirks/Core.cs
new file mode 100644
index 0000000..a4abaac
--- /dev/null
+++ b/RJW-Quirks/Core.cs
@@ -0,0 +1,18 @@
+using HarmonyLib;
+using HugsLib;
+using Verse;
+
+namespace rjwquirks
+{
+ public class Core : ModBase
+ {
+ // Originally did not use Hugslib, but due to RJW using hugslib I needed to in order for proper patching at correct times. could probably be done with priorities or something but this was easier
+ /*public Core(ModContentPack pack)
+ {
+ //var harmony = new Harmony("rain.quirks");
+ //harmony.PatchAll();
+ }*/
+
+ public override string ModIdentifier => "quirk";
+ }
+}
diff --git a/RJW-Quirks/Data/RaceTags.cs b/RJW-Quirks/Data/RaceTags.cs
new file mode 100644
index 0000000..bd5cde5
--- /dev/null
+++ b/RJW-Quirks/Data/RaceTags.cs
@@ -0,0 +1,64 @@
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.Data
+{
+ public class RaceTags
+ {
+ private readonly static Dictionary tagDatabase = new Dictionary();
+
+ // I only created tags for RaceGroupDef properties that seemed like keywords (like slime) rather than behavior (like oviPregnancy).
+ public readonly static RaceTags Chitin = new RaceTags("Chitin");
+ public readonly static RaceTags Demon = new RaceTags("Demon");
+ public readonly static RaceTags Feathers = new RaceTags("Feathers");
+ public readonly static RaceTags Fur = new RaceTags("Fur");
+ public readonly static RaceTags Plant = new RaceTags("Plant");
+ public readonly static RaceTags Robot = new RaceTags("Robot");
+ public readonly static RaceTags Scales = new RaceTags("Scales");
+ public readonly static RaceTags Skin = new RaceTags("Skin");
+ public readonly static RaceTags Slime = new RaceTags("Slime");
+
+
+ public string Key { get; }
+
+ private RaceTags(string key)
+ {
+ Key = key;
+ tagDatabase.Add(key, this);
+ }
+
+ public static bool TryParse(string key, out RaceTags raceTag)
+ {
+ return tagDatabase.TryGetValue(key, out raceTag);
+ }
+
+ ///
+ /// For backwards compatability only. Shouldn't add more special cases here.
+ ///
+ public bool DefaultWhenNoRaceGroupDef(Pawn pawn)
+ {
+ if (this == Demon)
+ {
+ return xxx.is_demon(pawn);
+ }
+ else if (this == Slime)
+ {
+ return xxx.is_slime(pawn);
+ }
+ else if (this == Skin)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_CasualSex_Helper.cs b/RJW-Quirks/HarmonyPatches/Patch_CasualSex_Helper.cs
new file mode 100644
index 0000000..57302ae
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_CasualSex_Helper.cs
@@ -0,0 +1,74 @@
+using HarmonyLib;
+using RimWorld;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(CasualSex_Helper), nameof(CasualSex_Helper.GetScore))]
+ public class Patch_CasualSex_Helper
+ {
+ // Edits the "score" of a cell for a pawn to fuck in
+ public static void Postfix(Pawn pawn, IntVec3 cell, Pawn partner, ref int __result)
+ {
+ QuirkSet quirks = pawn.GetQuirks();
+
+ if (quirks.AllQuirks.EnumerableNullOrEmpty())
+ return;
+
+ List all_pawns = pawn.Map.mapPawns.AllPawnsSpawned.Where(x
+ => x.Position.DistanceTo(pawn.Position) < 100
+ && xxx.is_human(x)
+ && x != pawn
+ && x != partner
+ ).ToList();
+
+ // Somnophile code
+ if (partner != null && quirks.Contains(QuirkDefOf.Somnophile))
+ {
+ if (all_pawns.Any(x
+ => !x.Awake()
+ && x.Position.DistanceTo(cell) < 6
+ && GenSight.LineOfSight(cell, x.Position, pawn.Map)
+ ))
+ __result += 50;
+ }
+
+ // Exhibitionist code
+ if (quirks.Contains(QuirkDefOf.Exhibitionist))
+ {
+ bool might_be_seen = CasualSex_Helper.MightBeSeen(all_pawns, cell, pawn, partner);
+ Room room = cell.GetRoom(pawn.Map);
+
+ // Readd the 30 score removed in regular RJW
+ __result += 30;
+ // Readd the 100 score taken from being in a doorway in regular RJW
+ __result += 100;
+
+ if (might_be_seen)
+ __result += 5;
+ else
+ __result -= 10;
+
+ if (room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.PrisonBarracks || room.Role == RoomRoleDefOf.PrisonCell
+ || room.Role == RoomRoleDefOf.Laboratory || room.Role == RoomRoleDefOf.RecRoom
+ || room.Role == RoomRoleDefOf.DiningRoom || room.Role == RoomRoleDefOf.Hospital
+ )
+ __result += 15; // Add 15 instead of 10 to counteract the -5 in regular RJW
+
+ Dictionary cell_doors = new Dictionary();
+
+ var doors = cell_doors.TryGetValue(room.ID);
+
+ if (doors > 1)
+ __result += 7 * doors; // Multiply by 7 instead of 2 to counteract the negative in regular RJW
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_CondomUtility.cs b/RJW-Quirks/HarmonyPatches/Patch_CondomUtility.cs
new file mode 100644
index 0000000..3f3add0
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_CondomUtility.cs
@@ -0,0 +1,37 @@
+using HarmonyLib;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ // Skips condom code entirely if they have pregnation fetish or similar. RJW used to do this with the same quirk.
+ [HarmonyPatch(typeof(CondomUtility))]
+ public class Patch_CondomUtility
+ {
+ [HarmonyPrefix]
+ [HarmonyPatch(nameof(CondomUtility.TryUseCondom))]
+ public static bool UseCondomPrefix(Pawn pawn)
+ {
+ if (xxx.is_human(pawn) && pawn.HasQuirk(QuirkDefOf.ImpregnationFetish))
+ return false;
+
+ return true;
+ }
+
+ [HarmonyPrefix]
+ [HarmonyPatch(nameof(CondomUtility.GetCondomFromRoom))]
+ public static bool GetCondomPrefix(Pawn pawn)
+ {
+ if (xxx.is_human(pawn) && pawn.HasQuirk(QuirkDefOf.ImpregnationFetish))
+ return false;
+
+ return true;
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_Dialog_Sexcard.cs b/RJW-Quirks/HarmonyPatches/Patch_Dialog_Sexcard.cs
new file mode 100644
index 0000000..0e54611
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_Dialog_Sexcard.cs
@@ -0,0 +1,131 @@
+using HarmonyLib;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+using System.Threading.Tasks;
+using UnityEngine;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(Dialog_Sexcard), "SexualityCard")]
+ public static class Patch_Dialog_Sexcard
+ {
+ static IEnumerable Transpiler(IEnumerable instructions)
+ {
+ MethodInfo InsertQuirks = AccessTools.Method(typeof(Patch_Dialog_Sexcard), nameof(DrawQuirks));
+ MethodInfo DrawSexuality = AccessTools.Method(typeof(Dialog_Sexcard), "DrawSexuality");
+ bool found = false;
+
+ // When RJW calls draw sexuality we inject our quirk drawing.
+ foreach (CodeInstruction i in instructions)
+ {
+ if (i.opcode == OpCodes.Call && i.operand as MethodInfo == DrawSexuality)
+ found = true;
+
+ if (found)
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_2);
+ yield return new CodeInstruction(OpCodes.Ldloc_3);
+ yield return new CodeInstruction(OpCodes.Call, InsertQuirks);
+ found = false;
+ }
+
+ yield return i;
+ }
+ }
+
+ public static void DrawQuirks(Pawn pawn, Rect rect)
+ {
+ QuirkSet quirks = pawn.GetQuirks();
+ rect.y += 24;
+
+ if (quirks == null)
+ return;
+
+ var quirkString = quirks.AllQuirks
+ .Select(quirk => quirk.Label)
+ .OrderBy(Label => Label)
+ .ToCommaList();
+
+ if ((Current.ProgramState == ProgramState.Playing &&
+ pawn.IsDesignatedHero() && pawn.IsHeroOwner() || Prefs.DevMode) ||
+ Current.ProgramState == ProgramState.Entry)
+ {
+ if (Widgets.ButtonText(rect, "Quirks".Translate() + quirkString, false))
+ DrawQuirkEditMenu(pawn, quirks);
+ }
+ else
+ Widgets.Label(rect, "Quirks".Translate() + quirkString);
+
+ if (!Mouse.IsOver(rect)) return;
+
+ Widgets.DrawHighlight(rect);
+
+ TooltipHandler.TipRegion(rect, quirks.TipString());
+ }
+
+ static void DrawQuirkEditMenu(Pawn pawn, QuirkSet quirks)
+ {
+ var quirkDefsAll = DefDatabase.AllDefs.OrderBy(def => def.GetLabelFor(pawn));
+
+ var menuOptions = new List();
+
+ if (RJWSettings.DevMode)
+ menuOptions.Add(new FloatMenuOption("[DEV] Forced Reset", () => quirks.Clear(true)));
+
+ menuOptions.Add(new FloatMenuOption("Reset", () => quirks.Clear()));
+
+ foreach (QuirkDef quirkDef in quirkDefsAll)
+ {
+ if (quirkDef.hidden && !RJWSettings.DevMode && !quirks.Contains(quirkDef))
+ continue;
+
+ Quirk quirk = quirks.GetQuirk(quirkDef);
+ FloatMenuOption option;
+
+ if (quirk == null)
+ {
+ AcceptanceReport report = quirks.CanBeAdded(quirkDef);
+ if (report.Accepted)
+ {
+ option = new FloatMenuOption(
+ quirkDef.GetLabelFor(pawn),
+ () => quirks.AddQuirk(quirkDef),
+ mouseoverGuiAction: (Rect rect) => TooltipHandler.TipRegion(rect, quirkDef.GetDescriptionFor(pawn))
+ );
+ }
+ else if (RJWSettings.DevMode)
+ option = new FloatMenuOption($"[DEV]{quirkDef.GetLabelFor(pawn)}: {report.Reason}", () => quirks.AddQuirk(quirkDef, true));
+ else
+ // Game does not call mouseoverGuiAction for the disabled entries
+ option = new FloatMenuOption($"{quirkDef.GetLabelFor(pawn)}: {report.Reason}", null);
+ }
+ else
+ {
+ AcceptanceReport report = quirks.CanBeRemoved(quirkDef);
+ if (report.Accepted)
+ {
+ option = new FloatMenuOption(
+ "- " + quirk.Label,
+ () => quirks.RemoveQuirk(quirk),
+ mouseoverGuiAction: (Rect rect) => TooltipHandler.TipRegion(rect, quirk.Description)
+ );
+ }
+ else if (RJWSettings.DevMode)
+ option = new FloatMenuOption($"- {quirk.Label}: {report.Reason}", () => quirks.RemoveQuirk(quirk, true));
+ else
+ option = new FloatMenuOption($"- {quirk.Label}: {report.Reason}", null);
+ }
+
+ menuOptions.Add(option);
+ }
+ Find.WindowStack.Add(new FloatMenu(menuOptions));
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_DrawNude.cs b/RJW-Quirks/HarmonyPatches/Patch_DrawNude.cs
new file mode 100644
index 0000000..b227131
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_DrawNude.cs
@@ -0,0 +1,24 @@
+using HarmonyLib;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(SexUtility), nameof(SexUtility.DrawNude))]
+ public class Patch_DrawNude
+ {
+ public static bool Prefix(Pawn pawn)
+ {
+ if (pawn.HasQuirk(QuirkDefOf.Endytophile))
+ return false;
+
+ return true;
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_Hediff_BasePregnancy.cs b/RJW-Quirks/HarmonyPatches/Patch_Hediff_BasePregnancy.cs
new file mode 100644
index 0000000..c5268a4
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_Hediff_BasePregnancy.cs
@@ -0,0 +1,35 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ /*[HarmonyPatch(typeof(Hediff_BasePregnancy))]
+ public class Patch_Hediff_BasePregnancy
+ {
+ [HarmonyTranspiler]
+ [HarmonyPatch("GenerateBabies")]
+ public static IEnumerable AdjustMaxLitterSize(IEnumerable instructions)
+ {
+ bool found = false;
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.33333334")
+ found = true;
+
+ if (found && i.opcode == OpCodes.Stloc_S)
+ Log.Warning(i.operand as string);
+
+
+ yield return i;
+ }
+ }
+ }*/
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseArtifical.cs b/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseArtifical.cs
new file mode 100644
index 0000000..b10bc50
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseArtifical.cs
@@ -0,0 +1,43 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(Hediff_PartBaseArtifical))]
+ public class Patch_Hediff_PartBaseArtifical
+ {
+ [HarmonyTranspiler]
+ [HarmonyPatch(nameof(Hediff_PartBaseArtifical.Tick))]
+ public static IEnumerable ChangeMaxEggsSize(IEnumerable instructions)
+ {
+ FieldInfo Pawn = AccessTools.Field(typeof(Hediff_PartBaseArtifical), nameof(Hediff_PartBaseArtifical.pawn));
+ MethodInfo EggSize = AccessTools.Method(typeof(Patch_Hediff_PartBaseArtifical), nameof(EditMaxEggsSize));
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0")
+ {
+ yield return new CodeInstruction(OpCodes.Ldfld, Pawn);
+ yield return new CodeInstruction(OpCodes.Ldloc_3);
+ yield return new CodeInstruction(OpCodes.Call, EggSize);
+ }
+
+ yield return i;
+ }
+ }
+
+ public static void EditMaxEggsSize(Pawn pawn, float eggsSize)
+ {
+ if (pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("maxEggsSize", ref eggsSize);
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseNatural.cs b/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseNatural.cs
new file mode 100644
index 0000000..9818e11
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_Hediff_PartBaseNatural.cs
@@ -0,0 +1,47 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(Hediff_PartBaseNatural))]
+ public class Patch_Hediff_PartBaseNatural
+ {
+ [HarmonyTranspiler]
+ [HarmonyPatch(nameof(Hediff_PartBaseNatural.Tick))]
+ public static IEnumerable ChangeMaxEggsSize(IEnumerable instructions)
+ {
+ FieldInfo Pawn = AccessTools.Field(typeof(Hediff_PartBaseNatural), nameof(Hediff_PartBaseNatural.pawn));
+ MethodInfo EggSize = AccessTools.Method(typeof(Patch_Hediff_PartBaseNatural), nameof(EditMaxEggsSize));
+ bool found = false;
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0" && found)
+ {
+ yield return new CodeInstruction(OpCodes.Ldfld, Pawn);
+ yield return new CodeInstruction(OpCodes.Ldloc_3);
+ yield return new CodeInstruction(OpCodes.Call, EggSize);
+ }
+
+ if (i.opcode == OpCodes.Ldc_R4 && i.operand as string == "0.0")
+ found = true;
+
+ yield return i;
+ }
+ }
+
+ public static void EditMaxEggsSize(Pawn pawn, float eggsSize)
+ {
+ if (pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("maxEggsSize", ref eggsSize);
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs b/RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs
new file mode 100644
index 0000000..03ae20a
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs
@@ -0,0 +1,59 @@
+using HarmonyLib;
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+using rjwquirks.Modules.Quirks;
+
+namespace rjwquirks.HarmonyPatches
+{
+ /*[HarmonyPatch(typeof(JobGiver_Masturbate))]
+ public class Patch_JobGiver_Masturbate
+ {
+ [HarmonyTranspiler]
+ [HarmonyPatch("TryGiveJob")]
+ public static IEnumerable ApplyQuirkToMasturbate(IEnumerable instructions)
+ {
+ MethodInfo Frustrated = AccessTools.Method(typeof(xxx), nameof(xxx.is_frustrated));
+ MethodInfo Apply = AccessTools.Method(typeof(Patch_JobGiver_Masturbate), nameof(ApplyQuirk));
+ var labels = instructions.ElementAt(0).labels.ListFullCopy();
+ Log.Warning(labels.Count.ToString());
+ bool found = false;
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_1);
+ yield return new CodeInstruction(OpCodes.Call, Apply);
+ yield return new CodeInstruction(OpCodes.Brtrue_S, labels[4]);
+ found = true;
+ }
+
+ if (found && i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_1);
+ yield return new CodeInstruction(OpCodes.Call, Apply);
+ yield return new CodeInstruction(OpCodes.Brtrue_S, labels[5]);
+ found = false;
+ }
+
+
+ yield return i;
+ }
+ }
+
+ public static bool ApplyQuirk(Pawn pawn)
+ {
+ if (pawn.GetQuirks() != null)
+ return pawn.HasQuirk(QuirkDefOf.Exhibitionist);
+
+ return false;
+ }
+ }*/
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_QuirkPartPreference.cs b/RJW-Quirks/HarmonyPatches/Patch_QuirkPartPreference.cs
new file mode 100644
index 0000000..ab79fdd
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_QuirkPartPreference.cs
@@ -0,0 +1,28 @@
+using HarmonyLib;
+using rjw.Modules.Interactions.Contexts;
+using rjw.Modules.Interactions.Internals.Implementation;
+using rjw.Modules.Interactions.Rules.PartKindUsageRules;
+using rjwquirks.Modules.Interactions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(PartPreferenceDetectorService), nameof(PartPreferenceDetectorService.DetectPartPreferences))]
+ public class Patch_QuirkPartPreference
+ {
+ public static void Prefix(InteractionContext context, IList ____partKindUsageRules)
+ {
+ if (____partKindUsageRules.Any(x => x.GetType() == typeof(QuirksPartKindUsageRule)) || (context.Internals.Submissive.Pawn.GetQuirks() == null || context.Internals.Dominant.Pawn.GetQuirks() == null))
+ return;
+
+ Log.Warning(____partKindUsageRules.Count().ToString());
+ ____partKindUsageRules.Add(new QuirksPartKindUsageRule());
+ Log.Warning(____partKindUsageRules.Count().ToString());
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_RecordsTracker_NotifyRecordChanged.cs b/RJW-Quirks/HarmonyPatches/Patch_RecordsTracker_NotifyRecordChanged.cs
new file mode 100644
index 0000000..082ea44
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_RecordsTracker_NotifyRecordChanged.cs
@@ -0,0 +1,30 @@
+using HarmonyLib;
+using RimWorld;
+using rjwquirks.Modules.Shared.Events;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ ///
+ /// Patch to generate events on record changes
+ ///
+ [HarmonyPatch(typeof(Pawn_RecordsTracker))]
+ public static class Patch_RecordsTracker_NotifyRecordChanged
+ {
+ [HarmonyPatch(nameof(Pawn_RecordsTracker.Increment))]
+ [HarmonyPostfix]
+ public static void IncrementPostfix(Pawn_RecordsTracker __instance, RecordDef def)
+ {
+ NotifyEvent(__instance.pawn, def);
+ }
+
+ [HarmonyPatch(nameof(Pawn_RecordsTracker.AddTo))]
+ [HarmonyPostfix]
+ public static void AddToPostfix(Pawn_RecordsTracker __instance, RecordDef def)
+ {
+ NotifyEvent(__instance.pawn, def);
+ }
+
+ private static void NotifyEvent(Pawn pawn, RecordDef def) => RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.RecordChanged, pawn.Named(RjwEventArgNames.Pawn), def.Named(RjwEventArgNames.Record)));
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_SexAppraiser.cs b/RJW-Quirks/HarmonyPatches/Patch_SexAppraiser.cs
new file mode 100644
index 0000000..4d23730
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_SexAppraiser.cs
@@ -0,0 +1,64 @@
+using HarmonyLib;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(SexAppraiser))]
+ public class Patch_SexAppraiser
+ {
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(SexAppraiser.GetMinSizePreference))]
+ public static void AdjustMinSize(Pawn pawn, ref float __result)
+ {
+ if (pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalBodySizeMin", ref __result);
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(SexAppraiser.GetMaxSizePreference))]
+ public static void AdjustMaxSize(Pawn pawn, ref float __result)
+ {
+ if (pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalBodySizeMax", ref __result);
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(SexAppraiser.GetMinSizePreference))]
+ public static void AdjustWildnessModifier(Pawn pawn, ref float __result)
+ {
+ if (pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("wouldFuckAnimalWildnessModifier", ref __result);
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch("GetOpinionFactor")]
+ public static void AdjustOpinionFactor(Pawn fucker, Pawn fucked, ref float __result)
+ {
+ if (fucker.GetQuirks() != null)
+ fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "opinionFactor", ref __result);
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch("GetBodyFactor")]
+ public static void AdjustBodyFactor(Pawn fucker, Pawn fucked, ref float __result)
+ {
+ if (fucker.GetQuirks() != null)
+ fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "bodyFactor", ref __result);
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch("GetAgeFactor")]
+ public static void AdjustAgeFactor(Pawn fucker, Pawn fucked, int p_age, ref float __result)
+ {
+ if (fucker.GetQuirks() != null)
+ fucker.GetQuirks().ApplySexAppraisalModifiers(fucked, "ageFactor", ref __result);
+ }
+ }
+}
diff --git a/RJW-Quirks/HarmonyPatches/Patch_SexUtility.cs b/RJW-Quirks/HarmonyPatches/Patch_SexUtility.cs
new file mode 100644
index 0000000..fe3dbd7
--- /dev/null
+++ b/RJW-Quirks/HarmonyPatches/Patch_SexUtility.cs
@@ -0,0 +1,146 @@
+using HarmonyLib;
+using RimWorld;
+using rjw;
+using rjwquirks.Modules.Quirks;
+using rjwquirks.Modules.Shared.Events;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.HarmonyPatches
+{
+ [HarmonyPatch(typeof(SexUtility))]
+ public class Patch_SexUtility
+ {
+ // Increases cum filth generated by pawn
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(SexUtility.CumOutputModifier))]
+ public static void FilthAdder(Pawn pawn, ref float __result)
+ {
+ if(pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("cumFilthAmount", ref __result);
+ }
+
+ // Change how much the pawn wants to clean post sex
+ [HarmonyTranspiler]
+ [HarmonyPatch(nameof(SexUtility.ConsiderCleaning))]
+ static IEnumerable ConsiderCleanup(IEnumerable instructions)
+ {
+ FieldInfo PawnNeeds = AccessTools.Field(typeof(Pawn), nameof(Pawn.needs));
+ MethodInfo Cleanup = AccessTools.Method(typeof(Patch_SexUtility), nameof(CleanupChanceAdjuster));
+
+ bool found = false;
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (found)
+ {
+ yield return i;
+ yield return new CodeInstruction(OpCodes.Ldloc_0);
+ yield return new CodeInstruction(OpCodes.Ldarg_0);
+ yield return new CodeInstruction(OpCodes.Call, Cleanup);
+ found = false;
+ continue;
+ }
+
+ if (i.opcode == OpCodes.Ldfld && i.operand as FieldInfo == PawnNeeds)
+ found = true;
+
+ yield return i;
+ }
+ }
+
+ public static void CleanupChanceAdjuster(float chance, Pawn pawn)
+ {
+ pawn.GetQuirks().ApplyValueModifiers("cleanAfterFapChance", ref chance);
+ }
+
+ // Change satisfaction from sex
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(SexUtility.GetExtraSatisfaction))]
+ public static void Satisfaction(SexProps props, ref float __result)
+ {
+ var quirkCount = props.pawn.GetQuirks().GetSatisfiedBySex(props).Count();
+
+ if (quirkCount > 0)
+ {
+ __result += props.pawn.GetQuirks().GetSatisfiedBySex(props).Count() * 0.20f;
+ RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.Orgasm, props.Named(RjwEventArgNames.SexProps), __result.Named(RjwEventArgNames.Satisfaction)));
+ }
+ }
+
+ // Change ticks to next lovin
+ [HarmonyTranspiler]
+ [HarmonyPatch(nameof(SexUtility.GenerateMinTicksToNextLovin))]
+ public static IEnumerable ChangeTicksToNextLovin(IEnumerable instructions)
+ {
+ MethodInfo SexDrive = AccessTools.Method(typeof(xxx), nameof(xxx.get_sex_drive));
+ MethodInfo AdjustTicks = AccessTools.Method(typeof(Patch_SexUtility), nameof(AdjustTicksToNextLovin));
+ bool found = false;
+
+ foreach (var i in instructions)
+ {
+ if (found)
+ {
+ yield return i;
+ yield return new CodeInstruction(OpCodes.Ldloc_0);
+ yield return new CodeInstruction(OpCodes.Ldarg_0);
+ yield return new CodeInstruction(OpCodes.Call, AdjustTicks);
+ found = false;
+ continue;
+ }
+
+ if (i.opcode == OpCodes.Call && i.operand as MethodInfo == SexDrive)
+ found = true;
+
+ yield return i;
+ }
+ }
+
+ public static void AdjustTicksToNextLovin(float ticks, Pawn pawn)
+ {
+ if (pawn.GetQuirks() != null)
+ {
+ pawn.GetQuirks().ApplyValueModifiers("ticksToNextLovin", ref ticks);
+ }
+ }
+
+ // Rest adjustments
+ [HarmonyTranspiler]
+ [HarmonyPatch(nameof(SexUtility.reduce_rest))]
+ public static IEnumerable AdjustRest(IEnumerable instructions)
+ {
+ MethodInfo Adjustment = AccessTools.Method(typeof(Patch_SexUtility), nameof(AdjustRestFromQuirk));
+ bool found = false;
+ bool completed = false;
+
+ foreach (CodeInstruction i in instructions)
+ {
+ if (found && !completed)
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_0);
+ yield return new CodeInstruction(OpCodes.Ldarg_1);
+ yield return new CodeInstruction(OpCodes.Call, Adjustment);
+ completed = true;
+ found = false;
+ }
+
+ if (i.opcode == OpCodes.Dup)
+ found = true;
+
+ yield return i;
+ }
+ }
+
+ public static void AdjustRestFromQuirk(Pawn pawn, float x)
+ {
+ if(pawn.GetQuirks() != null)
+ pawn.GetQuirks().ApplyValueModifiers("reduceRest", ref x);
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Interactions/QuirksPartKindUsageRule.cs b/RJW-Quirks/Modules/Interactions/QuirksPartKindUsageRule.cs
new file mode 100644
index 0000000..42ec7b3
--- /dev/null
+++ b/RJW-Quirks/Modules/Interactions/QuirksPartKindUsageRule.cs
@@ -0,0 +1,71 @@
+using rjw.Modules.Interactions.Contexts;
+using rjw.Modules.Interactions.Enums;
+using rjw.Modules.Interactions.Objects;
+using rjw.Modules.Interactions.Rules.PartKindUsageRules;
+using rjw.Modules.Shared;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.Modules.Interactions
+{
+ public class QuirksPartKindUsageRule : IPartPreferenceRule
+ {
+ public IEnumerable> ModifiersForDominant(InteractionContext context)
+ {
+ return Enumerable.Concat(
+ ModifierFromPawnQuirks(context.Internals.Dominant, context.Internals.Submissive),
+ ModifierFromPartnerQuirks(context.Internals.Submissive, context.Internals.Dominant)
+ );
+
+ }
+
+ public IEnumerable> ModifiersForSubmissive(InteractionContext context)
+ {
+ return Enumerable.Concat(
+ ModifierFromPawnQuirks(context.Internals.Submissive, context.Internals.Dominant),
+ ModifierFromPartnerQuirks(context.Internals.Dominant, context.Internals.Submissive)
+ );
+ }
+
+ ///
+ /// What pawn wants to use because of quirks
+ ///
+ private IEnumerable> ModifierFromPawnQuirks(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ foreach (var comp in GetQuirkComps(quirkOwner.Pawn))
+ {
+ foreach (var rule in comp.GetModifiersForPawn(quirkOwner, partner))
+ {
+ yield return rule;
+ }
+ }
+ }
+
+ ///
+ /// What pawn want from partner because of pawn's quirks
+ ///
+ private IEnumerable> ModifierFromPartnerQuirks(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ foreach (var comp in GetQuirkComps(quirkOwner.Pawn))
+ {
+ foreach (var rule in comp.GetModifiersForPartner(quirkOwner, partner))
+ {
+ yield return rule;
+ }
+ }
+ }
+
+ private IEnumerable GetQuirkComps(Pawn pawn)
+ {
+ foreach (var comp in pawn.GetQuirks().AllQuirks.SelectMany(quirk => quirk.def.GetComps()))
+ {
+ yield return comp;
+ }
+ }
+ }
+
+}
diff --git a/RJW-Quirks/Modules/Quirks/CompProperties_QuirkSet.cs b/RJW-Quirks/Modules/Quirks/CompProperties_QuirkSet.cs
new file mode 100644
index 0000000..5d9cc0f
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/CompProperties_QuirkSet.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks
+{
+ public class CompProperties_QuirkSet : CompProperties
+ {
+ public CompProperties_QuirkSet()
+ {
+ compClass = typeof(QuirkSet);
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/Adder.cs b/RJW-Quirks/Modules/Quirks/Comps/Adder.cs
new file mode 100644
index 0000000..54f3350
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/Adder.cs
@@ -0,0 +1,53 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Base class for the comps that add quirks to the pawns
+ ///
+ public abstract class Adder : QuirkComp
+ {
+ ///
+ /// For def load only. Use
+ ///
+ public string message;
+ public MessageTypeDef messageType;
+
+ protected string MessageTemplate => message ?? parent.description;
+
+ public MessageTypeDef MessageType => messageType ?? MessageTypeDefOf.NeutralEvent;
+
+ ///
+ /// Get adjusted message text to be shown to the user when adding a quirk
+ ///
+ public string GetMessageFor(Pawn pawn) => MessageTemplate.Formatted(pawn.Named("pawn")).AdjustedFor(pawn).Resolve();
+
+ ///
+ /// Add quirk of comp parent def to the pawn
+ ///
+ protected void AddQuirkTo(Pawn pawn)
+ {
+ Quirk addedQuirk = pawn.GetQuirks().AddQuirk(parent);
+
+ if (addedQuirk != null)
+ {
+ Messages.Message(GetMessageFor(pawn), pawn, MessageType);
+ }
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (eventDef == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/Adder_OnRecordExceeding.cs b/RJW-Quirks/Modules/Quirks/Comps/Adder_OnRecordExceeding.cs
new file mode 100644
index 0000000..d6f540d
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/Adder_OnRecordExceeding.cs
@@ -0,0 +1,52 @@
+using RimWorld;
+using rjw;
+using rjwquirks;
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Comp to add a quirk when crosses
+ ///
+ public class Adder_OnRecordExceeding : Adder
+ {
+ public RecordDef record;
+ public float value;
+
+ protected override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.Pawn, out Pawn pawn))
+ {
+ ModLog.Error($"{GetType()}.HandleEvent: No pawn in the event");
+ return;
+ }
+
+ float recordValue = pawn.records?.GetValue(record) ?? 0f;
+
+ if (recordValue >= value && !pawn.HasQuirk(parent))
+ {
+ AddQuirkTo(pawn);
+ }
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (record == null)
+ {
+ yield return " is empty";
+ }
+
+ if (value == 0f)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/CompAdder.cs b/RJW-Quirks/Modules/Quirks/Comps/CompAdder.cs
new file mode 100644
index 0000000..4e9c93b
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/CompAdder.cs
@@ -0,0 +1,25 @@
+using rjw;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ // Adds quirk comp to all races
+ [StaticConstructorOnStartup]
+ public static class CompAdder
+ {
+ static CompAdder()
+ {
+ foreach (ThingDef thingDef in DefDatabase.AllDefs.Where(thingDef =>
+ thingDef.race != null && !thingDef.race.Animal ))
+ {
+ thingDef.comps.Add(new CompProperties_QuirkSet());
+
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/HediffAdder.cs b/RJW-Quirks/Modules/Quirks/Comps/HediffAdder.cs
new file mode 100644
index 0000000..d11a867
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/HediffAdder.cs
@@ -0,0 +1,44 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Comp to add an to the pawn on RJW event
+ ///
+ public class HediffAdder : QuirkComp
+ {
+ public HediffDef hediff;
+
+ protected override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.Pawn, out Pawn pawn))
+ {
+ ModLog.Error($"{GetType()}.HandleEvent: No pawn in the event");
+ return;
+ }
+
+ pawn.health?.AddHediff(hediff);
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (hediff == null)
+ {
+ yield return " is empty";
+ }
+
+ if (eventDef == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/HediffRemover.cs b/RJW-Quirks/Modules/Quirks/Comps/HediffRemover.cs
new file mode 100644
index 0000000..b8b4788
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/HediffRemover.cs
@@ -0,0 +1,48 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Comp to remove an to the pawn on RJW event
+ ///
+ public class HediffRemover : QuirkComp
+ {
+ public HediffDef hediff;
+
+ protected override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.Pawn, out Pawn pawn))
+ {
+ ModLog.Error($"{GetType()}.HandleEvent: No pawn in the event");
+ return;
+ }
+
+ Hediff existingHediff = pawn.health?.hediffSet?.GetFirstHediffOfDef(hediff);
+ if (existingHediff != null)
+ {
+ pawn.health.RemoveHediff(existingHediff);
+ }
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (hediff == null)
+ {
+ yield return " is empty";
+ }
+
+ if (eventDef == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules.cs b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules.cs
new file mode 100644
index 0000000..7386b0f
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules.cs
@@ -0,0 +1,27 @@
+using rjw.Modules.Interactions.Enums;
+using rjw.Modules.Interactions.Objects;
+using rjw.Modules.Shared;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// QuirkComp to affect body part selection when choosing sex interaction
+ ///
+ public abstract class PartKindUsageRules : QuirkComp
+ {
+ ///
+ /// Returns body parts that pawn prefers because of the quirk
+ ///
+ /// Quirk owner
+ /// Quirk owner's sex partner
+ public abstract IEnumerable> GetModifiersForPawn(InteractionPawn quirkOwner, InteractionPawn partner);
+
+ ///
+ /// Returns body parts that pawn wants partner to use
+ ///
+ /// Quirk owner
+ /// Quirk owner's sex partner
+ public abstract IEnumerable> GetModifiersForPartner(InteractionPawn quirkOwner, InteractionPawn partner);
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_ImpregnationFetish.cs b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_ImpregnationFetish.cs
new file mode 100644
index 0000000..9e11d1c
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_ImpregnationFetish.cs
@@ -0,0 +1,42 @@
+using rjw.Modules.Interactions.Enums;
+using rjw.Modules.Interactions.Objects;
+using rjw.Modules.Shared;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class PartKindUsageRules_ImpregnationFetish : PartKindUsageRules
+ {
+ ///
+ /// Add desire to use penis if partner has vagina and vise-verse.
+ /// Check of partner's parts is to avoid boosting vagina on futa when partner is female.
+ /// No check of pawn's parts because interaction framework will filter it anyway
+ ///
+ public override IEnumerable> GetModifiersForPawn(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ if (!partner.BlockedParts.Contains(LewdablePartKind.Vagina))
+ {
+ yield return new Weighted(Multipliers.Doubled, LewdablePartKind.Penis);
+ }
+ if (!partner.BlockedParts.Contains(LewdablePartKind.Penis))
+ {
+ yield return new Weighted(Multipliers.Doubled, LewdablePartKind.Vagina);
+ }
+ }
+
+ ///
+ /// Ask partner to use penis if quirk owner has vagina and provide vagina if owner has penis.
+ ///
+ public override IEnumerable> GetModifiersForPartner(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ if (!quirkOwner.BlockedParts.Contains(LewdablePartKind.Vagina))
+ {
+ yield return new Weighted(Multipliers.Doubled, LewdablePartKind.Penis);
+ }
+ if (!quirkOwner.BlockedParts.Contains(LewdablePartKind.Penis))
+ {
+ yield return new Weighted(Multipliers.Doubled, LewdablePartKind.Vagina);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_Static.cs b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_Static.cs
new file mode 100644
index 0000000..e3e143a
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/PartKindUsageRules_Static.cs
@@ -0,0 +1,45 @@
+using rjw.Modules.Interactions.Enums;
+using rjw.Modules.Interactions.Objects;
+using rjw.Modules.Shared;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class PartKindUsageRules_Static : PartKindUsageRules
+ {
+ // rjw.Modules.Shared can't be loaded directly because it uses properties.
+ // Probably should change that, but it'll cause more ripples then I'm willing to handle rn
+ public class WeightedDef
+ {
+ public LewdablePartKind partKind;
+ public float weightMultiplier;
+ }
+
+ public List self = new List();
+ public List partner = new List();
+
+ public override IEnumerable> GetModifiersForPawn(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ return self.ConvertAll(ruleDef => new Weighted(ruleDef.weightMultiplier, ruleDef.partKind));
+ }
+
+ public override IEnumerable> GetModifiersForPartner(InteractionPawn quirkOwner, InteractionPawn partner)
+ {
+ return this.partner.ConvertAll(ruleDef => new Weighted(ruleDef.weightMultiplier, ruleDef.partKind));
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (self.NullOrEmpty() && partner.NullOrEmpty())
+ {
+ yield return "Both and can not be empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/QuirkComp.cs b/RJW-Quirks/Modules/Quirks/Comps/QuirkComp.cs
new file mode 100644
index 0000000..3ecb168
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/QuirkComp.cs
@@ -0,0 +1,32 @@
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public abstract class QuirkComp
+ {
+ public QuirkDef parent;
+ public RjwEventDef eventDef;
+
+ ///
+ /// Notify quirk comp about the RJW event
+ ///
+ public void NotifyEvent(RjwEvent ev)
+ {
+ if (eventDef != null && ev.def == eventDef)
+ {
+ HandleEvent(ev);
+ }
+ }
+
+ ///
+ /// Handle an RJW event. This method called only for events of
+ ///
+ protected virtual void HandleEvent(RjwEvent ev) { }
+
+ public virtual IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ yield break;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier.cs b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier.cs
new file mode 100644
index 0000000..cb73240
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier.cs
@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public abstract class SexAppraisalModifier : QuirkComp
+ {
+ public string factorName;
+ public QuirkModifierPriority priority = QuirkModifierPriority.Normal;
+
+ public void TryModifyValue(Pawn quirkOwner, Pawn partner, string factorName, ref float value)
+ {
+ if (this.factorName != factorName)
+ {
+ return;
+ }
+
+ if (parent.partnerPreference?.PartnerSatisfies(quirkOwner, partner) != true)
+ {
+ return;
+ }
+
+ ModifyValue(quirkOwner, partner, ref value);
+ }
+
+ public abstract void ModifyValue(Pawn quirkOwner, Pawn partner, ref float value);
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (factorName.NullOrEmpty())
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_ApplyMultiplier.cs b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_ApplyMultiplier.cs
new file mode 100644
index 0000000..80153e6
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_ApplyMultiplier.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class SexAppraisalModifier_ApplyMultiplier : SexAppraisalModifier
+ {
+ public float multiplier = 1f;
+
+ public override void ModifyValue(Pawn quirkOwner, Pawn partner, ref float value)
+ {
+ value *= multiplier;
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (multiplier == 1f)
+ {
+ yield return " is empty or is 1";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_SetValue.cs b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_SetValue.cs
new file mode 100644
index 0000000..c1acf10
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/SexAppraisalModifier_SetValue.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class SexAppraisalModifier_SetValue : SexAppraisalModifier
+ {
+ public float value;
+
+ public override void ModifyValue(Pawn quirkOwner, Pawn partner, ref float value)
+ {
+ value = this.value;
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (value <= 0f)
+ {
+ yield return " must be > 0";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder.cs b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder.cs
new file mode 100644
index 0000000..bf55ac9
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder.cs
@@ -0,0 +1,37 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Base class for the comps that add thoughts to the pawn
+ ///
+ public abstract class ThoughtAdder : QuirkComp
+ {
+ public ThoughtDef thought;
+
+ ///
+ /// Add to the
+ ///
+ public void ApplyThought(Pawn pawn, Pawn partner) => pawn.needs?.mood?.thoughts?.memories?.TryGainMemory(thought, partner);
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (thought == null)
+ {
+ yield return " is empty";
+ }
+
+ if (eventDef == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent.cs b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent.cs
new file mode 100644
index 0000000..19ee3a2
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent.cs
@@ -0,0 +1,30 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ ///
+ /// Base class for the comps that add thoughts on RJW event with SexProps argument
+ ///
+ public abstract class ThoughtAdder_OnSexEvent : ThoughtAdder
+ {
+ ///
+ /// Check if thought should be applied
+ ///
+ public abstract bool ShouldApplyThought(SexProps props);
+
+ protected override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.SexProps, out SexProps props))
+ {
+ ModLog.Error($"{GetType()}.HandleEvent: No SexProps in the event");
+ return;
+ }
+
+ if (ShouldApplyThought(props))
+ {
+ ApplyThought(props.pawn, props.partner);
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_NonPreferred.cs b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_NonPreferred.cs
new file mode 100644
index 0000000..fe95839
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_NonPreferred.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class ThoughtAdder_OnSexEvent_NonPreferred : ThoughtAdder_OnSexEvent
+ {
+ public override bool ShouldApplyThought(SexProps props) => !parent.IsSatisfiedBySex(props);
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_Preferred.cs b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_Preferred.cs
new file mode 100644
index 0000000..a0c7748
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ThoughtAdder_OnSexEvent_Preferred.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class ThoughtAdder_OnSexEvent_Preferred : ThoughtAdder_OnSexEvent
+ {
+ public override bool ShouldApplyThought(SexProps props) => parent.IsSatisfiedBySex(props);
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ValueModifier.cs b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier.cs
new file mode 100644
index 0000000..a84b232
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier.cs
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public abstract class ValueModifier : QuirkComp
+ {
+ public string valueName;
+ public QuirkModifierPriority priority = QuirkModifierPriority.Normal;
+
+ public void TryModifyValue(string valueName, ref float value)
+ {
+ if (this.valueName != valueName)
+ {
+ return;
+ }
+
+ ModifyValue(ref value);
+ }
+
+ public abstract void ModifyValue(ref float value);
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (valueName.NullOrEmpty())
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyMultiplier.cs b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyMultiplier.cs
new file mode 100644
index 0000000..9171312
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyMultiplier.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class ValueModifier_ApplyMultiplier : ValueModifier
+ {
+ public float multiplier = 1f;
+
+ public override void ModifyValue(ref float value)
+ {
+ value *= multiplier;
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (multiplier == 1f)
+ {
+ yield return " is empty or is 1";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyOffset.cs b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyOffset.cs
new file mode 100644
index 0000000..157e89e
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Comps/ValueModifier_ApplyOffset.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.Comps
+{
+ public class ValueModifier_ApplyOffset : ValueModifier
+ {
+ public float offset;
+
+ public override void ModifyValue(ref float value)
+ {
+ value += offset;
+ }
+
+ public override IEnumerable ConfigErrors(QuirkDef parent)
+ {
+ foreach (string error in base.ConfigErrors(parent))
+ {
+ yield return error;
+ }
+
+ if (offset == 0f)
+ {
+ yield return " is empty or is 0";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkGenerator.cs b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkGenerator.cs
new file mode 100644
index 0000000..bd21668
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkGenerator.cs
@@ -0,0 +1,111 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using System.Linq;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.EventHandlers
+{
+ public class QuirkGenerator : RjwEventHandler
+ {
+ public override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.Pawn, out Pawn pawn))
+ {
+ ModLog.Error($"QuirkGenerator recieved {ev.def}, but event has no '{RjwEventArgNames.Pawn}' argument");
+ return;
+ }
+
+ Generate(pawn);
+ }
+
+ ///
+ /// Generate quirks for the pawn.
+ /// Caution: Does not clears existing quirks
+ ///
+ public static void Generate(Pawn pawn)
+ {
+ if (!pawn.RaceHasSexNeed() || (pawn.kindDef.race.defName.ToLower().Contains("droid") && !AndroidsCompatibility.IsAndroid(pawn)))
+ {
+ return;
+ }
+
+ QuirkSet quirks = pawn.GetQuirks();
+
+ if (pawn.IsAnimal())
+ {
+ GenerateForAnimal(quirks);
+ }
+ else
+ {
+ GenerateForHumanlike(quirks);
+ }
+ }
+
+ ///
+ /// Rolls an X number between 0 and max quirks setting.
+ /// Tries to add random quirks to the QuirkSet until X are added or out of available quirks.
+ ///
+ static void GenerateForHumanlike(QuirkSet quirks)
+ {
+ var count = Rand.RangeInclusive(0, RJWPreferenceSettings.MaxQuirks);
+ var availableQuirks = DefDatabase.AllDefsListForReading
+ .Where(def => def.rarity != QuirkRarity.ForcedOnly) // Have to earn these
+ .ToArray(); // ToArray to get a shuffleable copy
+ availableQuirks.Shuffle();
+
+ // Some quirks may be hard for a given pawn to indulge in.
+ // For example a female homosexual will have a hard time satisfying an impregnation fetish.
+ // But rimworld is a weird place and you never know what the pawn will be capable of in the future.
+ // We still don't want straight up contradictory results like fertile + infertile.
+ foreach (var quirkDef in availableQuirks)
+ {
+ if (count == 0)
+ {
+ break;
+ }
+
+ if (!quirks.CanBeAdded(quirkDef))
+ {
+ continue;
+ }
+
+ count--;
+ quirks.AddQuirk(quirkDef);
+ }
+ }
+
+ ///
+ /// Original method rolled 10% chance on 3 hardcoded animal quirks.
+ /// This implementation takes MaxQuirks (3 by default) number of quirks from
+ /// available for animals and rolls 10% chance for each
+ ///
+ static void GenerateForAnimal(QuirkSet quirks)
+ {
+ int count = RJWPreferenceSettings.MaxQuirks;
+ var availableQuirks = DefDatabase.AllDefsListForReading
+ .Where(def => def.rarity != QuirkRarity.ForcedOnly)
+ .ToArray();
+ availableQuirks.Shuffle();
+
+ foreach (var quirkDef in availableQuirks)
+ {
+ if (count == 0)
+ {
+ break;
+ }
+
+ if (!quirks.CanBeAdded(quirkDef))
+ {
+ continue;
+ }
+
+ count--;
+
+ if (Rand.Chance(0.1f))
+ {
+ quirks.AddQuirk(quirkDef);
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkRjwEventHandler.cs b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkRjwEventHandler.cs
new file mode 100644
index 0000000..d71731c
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkRjwEventHandler.cs
@@ -0,0 +1,22 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+
+namespace rjwquirks.Modules.Quirks.EventHandlers
+{
+ ///
+ /// Handler that passes RJW events to a single quirk
+ ///
+ public class QuirkRjwEventHandler : RjwEventHandler
+ {
+ public override void HandleEvent(RjwEvent ev)
+ {
+ if (!ev.args.TryGetArg(RjwEventArgNames.Quirk, out Quirk quirk))
+ {
+ ModLog.Error($"QuirkRjwEventHandler recieved {ev.def}, but event has no '{RjwEventArgNames.Quirk}' argument");
+ return;
+ }
+
+ quirk.NotifyEvent(ev);
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkSetRjwEventHandler.cs b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkSetRjwEventHandler.cs
new file mode 100644
index 0000000..ef49139
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/EventHandlers/QuirkSetRjwEventHandler.cs
@@ -0,0 +1,30 @@
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.EventHandlers
+{
+ ///
+ /// Handler that passes RJW events to all quirks of a pawn
+ ///
+ public class QuirkSetRjwEventHandler : RjwEventHandler
+ {
+ public override void HandleEvent(RjwEvent ev)
+ {
+ ev.args.TryGetArg(RjwEventArgNames.Pawn, out Pawn pawn);
+
+ if (pawn == null && ev.args.TryGetArg(RjwEventArgNames.SexProps, out SexProps props))
+ {
+ pawn = props.pawn;
+ }
+
+ if (pawn == null)
+ {
+ ModLog.Error($"QuirkSetRjwEventHandler recieved {ev.def}, but event has neither '{RjwEventArgNames.Pawn}' or '{RjwEventArgNames.SexProps}' argument");
+ return;
+ }
+
+ pawn.GetQuirks().NotifyEvent(ev);
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/EventHandlers/RecordChangedRjwEventHandler.cs b/RJW-Quirks/Modules/Quirks/EventHandlers/RecordChangedRjwEventHandler.cs
new file mode 100644
index 0000000..da503cd
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/EventHandlers/RecordChangedRjwEventHandler.cs
@@ -0,0 +1,72 @@
+using RimWorld;
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks.EventHandlers
+{
+ ///
+ /// Handler that passes RJW events a particular comps of an unassigned QuirkDef
+ ///
+ public class RecordChangedRjwEventHandler : RjwEventHandler
+ {
+ ///
+ /// Records that have associated quirk adder def comps.
+ /// Used to quickly filter out updates of irrelevant records.
+ ///
+ private static Dictionary> _recordsWithAdder;
+
+ public override void HandleEvent(RjwEvent ev)
+ {
+ if (ev.def != RjwEventDefOf.RecordChanged)
+ {
+ ModLog.Warning($"RecordChangedRjwEventHandler recieved {ev.def}, but it only handles RecordChanged event");
+ return;
+ }
+
+ if (_recordsWithAdder == null)
+ {
+ BuildAdderCache();
+ }
+
+ if (!ev.args.TryGetArg(RjwEventArgNames.Record, out RecordDef recordDef))
+ {
+ ModLog.Error($"RecordChangedRjwEventHandler recieved {ev.def}, but event has no '{RjwEventArgNames.Record}' argument");
+ return;
+ }
+
+ if (!_recordsWithAdder.TryGetValue(recordDef, out var comps))
+ {
+ return;
+ }
+
+ foreach (var comp in comps)
+ {
+ // Send message to the def comps directly because the quirk is not assigned to a pawn yet
+ comp.NotifyEvent(ev);
+ }
+ }
+
+ ///
+ /// Builds _recordsWithAdder dictionary
+ ///
+ private static void BuildAdderCache()
+ {
+ _recordsWithAdder = new Dictionary>();
+
+ foreach (var comp in DefDatabase.AllDefs.SelectMany(def => def.GetComps()))
+ {
+ if (_recordsWithAdder.TryGetValue(comp.record, out var comps))
+ {
+ comps.Add(comp);
+ }
+ else
+ {
+ _recordsWithAdder[comp.record] = new List() { comp };
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/OwnerRequirement.cs b/RJW-Quirks/Modules/Quirks/OwnerRequirement.cs
new file mode 100644
index 0000000..33e2c44
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/OwnerRequirement.cs
@@ -0,0 +1,58 @@
+using rjwquirks.Modules.Shared.PawnSelectors;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks
+{
+ ///
+ /// Class to check if quirk can be assigned to a pawn
+ ///
+ public class OwnerRequirement
+ {
+ ///
+ /// Requirement conditions
+ ///
+ public IPawnSelector pawnSelector;
+
+ ///
+ /// Translation key for a displayed reason why quirk can't be assigned to a pawn
+ ///
+ [NoTranslate]
+ public string rejectionReason;
+
+ ///
+ /// Check if pawn satisfies requirement conditions
+ ///
+ public AcceptanceReport CheckBeforeAdd(Pawn pawn)
+ {
+ if (pawnSelector?.PawnSatisfies(pawn) == true)
+ {
+ return AcceptanceReport.WasAccepted;
+ }
+ else
+ {
+ return new AcceptanceReport(rejectionReason.Translate());
+ }
+ }
+
+ public IEnumerable ConfigErrors()
+ {
+ if (pawnSelector == null)
+ {
+ yield return " is empty";
+ }
+ else
+ {
+ foreach (string error in pawnSelector.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+
+ if (rejectionReason.NullOrEmpty())
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/Quirk.cs b/RJW-Quirks/Modules/Quirks/Quirk.cs
new file mode 100644
index 0000000..433ff1b
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/Quirk.cs
@@ -0,0 +1,71 @@
+using rjwquirks.Modules.Shared.Events;
+using System.Text;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks
+{
+ public class Quirk : IExposable
+ {
+ public QuirkDef def;
+ public Pawn pawn;
+
+ ///
+ /// Adjusted for the owner and cached quirk description
+ ///
+ public string Description
+ {
+ get
+ {
+ if (descriptionCache == null)
+ {
+ // Description bulding is a fairly pricy operation
+ descriptionCache = def.GetDescriptionFor(pawn);
+ }
+ return descriptionCache;
+ }
+ }
+
+ ///
+ /// Gender specific quirk label
+ ///
+ public string Label => def.GetLabelFor(pawn);
+
+ protected string descriptionCache;
+
+ ///
+ /// For save loading only
+ ///
+ public Quirk() { }
+
+ public Quirk(QuirkDef def, Pawn pawn)
+ {
+ this.def = def;
+ this.pawn = pawn;
+ }
+
+ ///
+ /// Pass RJW event to all comps of this quirk's def
+ ///
+ public void NotifyEvent(RjwEvent ev) => def.comps.ForEach(comp => comp.NotifyEvent(ev));
+
+ public string TipString()
+ {
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.AppendLine(Label.Colorize(UnityEngine.Color.yellow));
+ stringBuilder.Append(Description);
+ return stringBuilder.ToString();
+ }
+
+ public void ExposeData()
+ {
+ Scribe_Defs.Look(ref def, "def");
+
+ if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs && def == null)
+ {
+ def = DefDatabase.GetRandom();
+ }
+ }
+
+ public override string ToString() => $"Quirk({def})";
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/QuirkDef.cs b/RJW-Quirks/Modules/Quirks/QuirkDef.cs
new file mode 100644
index 0000000..e4a0da4
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/QuirkDef.cs
@@ -0,0 +1,147 @@
+using RimWorld;
+using rjw;
+using rjwquirks.Modules.Quirks.Comps;
+using rjwquirks.Modules.Quirks.SexSelectors;
+using rjwquirks.Modules.Shared.PawnSelectors;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks
+{
+ public class QuirkDef : Def
+ {
+ [MustTranslate]
+ public string labelMale;
+ [MustTranslate]
+ public string labelFemale;
+ public QuirkRarity rarity = QuirkRarity.Common;
+ public bool hidden;
+ public IPartnerSelector partnerPreference;
+ public ISexSelector sexPreference;
+ public List ownerRequirements = new List();
+ public List comps = new List();
+ public List conflictingQuirks = new List();
+ public List conflictingTraits = new List();
+ public List exclusionTags = new List();
+
+ public string GetLabelFor(Gender gender)
+ {
+ if (gender == Gender.Male && !labelMale.NullOrEmpty())
+ {
+ return labelMale;
+ }
+
+ if (gender == Gender.Female && !labelFemale.NullOrEmpty())
+ {
+ return labelFemale;
+ }
+
+ return label;
+ }
+
+ public string GetLabelFor(Pawn pawn) => GetLabelFor(pawn?.gender ?? Gender.None);
+
+ public IEnumerable GetComps() where T : QuirkComp
+ {
+ for (int i = 0; i < comps.Count; i++)
+ {
+ if (comps[i] is T compT)
+ yield return compT;
+ }
+ }
+
+ public bool IsSatisfiedBySex(SexProps props) => sexPreference?.SexSatisfies(props) == true;
+
+ public bool ConflictsWith(QuirkDef other)
+ {
+ if (other.conflictingQuirks?.Contains(this) == true || conflictingQuirks?.Contains(other) == true)
+ {
+ return true;
+ }
+ if (exclusionTags != null && other.exclusionTags != null)
+ {
+ for (int i = 0; i < exclusionTags.Count; i++)
+ {
+ if (other.exclusionTags.Contains(exclusionTags[i]))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public bool ConflictsWith(TraitDef traitDef)
+ {
+ if (/*traitDef.conflictingQuirks?.Contains(this) == true || */conflictingTraits?.Contains(traitDef) == true)
+ {
+ return true;
+ }
+ if (exclusionTags != null && traitDef.exclusionTags != null)
+ {
+ for (int i = 0; i < exclusionTags.Count; i++)
+ {
+ if (traitDef.exclusionTags.Contains(exclusionTags[i]))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public string GetDescriptionFor(Pawn pawn) => description.Formatted(pawn.Named("pawn")).AdjustedFor(pawn).Resolve();
+
+ public override void PostLoad()
+ {
+ base.PostLoad();
+
+ foreach (QuirkComp comp in comps)
+ {
+ comp.parent = this;
+ }
+
+ sexPreference?.SetParent(this);
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (partnerPreference != null)
+ {
+ foreach (string error in partnerPreference.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+
+ if (sexPreference != null)
+ {
+ foreach (string error in sexPreference.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+
+ foreach (OwnerRequirement req in ownerRequirements)
+ {
+ foreach (string error in req.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+
+ foreach (QuirkComp comp in comps)
+ {
+ foreach (string error in comp.ConfigErrors(this))
+ {
+ yield return $"{comp.GetType()}: {error}";
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/QuirkDefOf.cs b/RJW-Quirks/Modules/Quirks/QuirkDefOf.cs
new file mode 100644
index 0000000..14c590c
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/QuirkDefOf.cs
@@ -0,0 +1,15 @@
+using RimWorld;
+
+namespace rjwquirks.Modules.Quirks
+{
+ [DefOf]
+ public static class QuirkDefOf
+ {
+ public static readonly QuirkDef Breeder;
+ public static readonly QuirkDef Endytophile;
+ public static readonly QuirkDef Exhibitionist;
+ public static readonly QuirkDef ImpregnationFetish;
+ public static readonly QuirkDef Incubator;
+ public static readonly QuirkDef Somnophile;
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/QuirkModifierPriority.cs b/RJW-Quirks/Modules/Quirks/QuirkModifierPriority.cs
new file mode 100644
index 0000000..c6739fc
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/QuirkModifierPriority.cs
@@ -0,0 +1,11 @@
+namespace rjwquirks.Modules.Quirks
+{
+ public enum QuirkModifierPriority
+ {
+ First,
+ High,
+ Normal,
+ Low,
+ Last
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/QuirkRarity.cs b/RJW-Quirks/Modules/Quirks/QuirkRarity.cs
new file mode 100644
index 0000000..fceef45
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/QuirkRarity.cs
@@ -0,0 +1,8 @@
+namespace rjwquirks.Modules.Quirks
+{
+ public enum QuirkRarity
+ {
+ ForcedOnly,
+ Common
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/QuirkSet.cs b/RJW-Quirks/Modules/Quirks/QuirkSet.cs
new file mode 100644
index 0000000..1af847c
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/QuirkSet.cs
@@ -0,0 +1,339 @@
+using RimWorld;
+using rjw;
+using rjwquirks.Modules.Shared.Events;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Verse;
+
+namespace rjwquirks.Modules.Quirks
+{
+ ///
+ /// A collection/tracker of pawn's quirks
+ ///
+ public class QuirkSet : ThingComp
+ {
+ protected Pawn pawn;
+ protected List quirks = new List();
+
+ public QuirkSet() { }
+
+ public override void PostSpawnSetup(bool respawningAfterLoad)
+ {
+ base.PostSpawnSetup(respawningAfterLoad);
+
+ pawn = parent as Pawn;
+
+ /*if (pawn.kindDef.race.defName.Contains("AIRobot") // No genitalia/sexuality for roombas.
+ || pawn.kindDef.race.defName.Contains("AIPawn") // ...nor MAI.
+ || pawn.kindDef.race.defName.Contains("RPP_Bot")
+ || pawn.kindDef.race.defName.Contains("PRFDrone") // Project RimFactory Revived drones
+ ) return;*/
+
+ if (Scribe.mode == LoadSaveMode.LoadingVars && quirks == null)
+ {
+ // Try to restore quirks from old save
+ string quirksave = string.Empty;
+ Scribe_Values.Look(ref quirksave, "RJW_Quirks");
+ if (!quirksave.NullOrEmpty()) // May be pawn really has no quirks
+ {
+ ParseQuirkSave(quirksave);
+ }
+ }
+ else if (quirks.NullOrEmpty())
+ {
+ //add random quirk gen and shit later/last
+ AddQuirk(QuirkDefOf.Incubator);
+ }
+ }
+
+ ///
+ /// QuirkSet owner
+ ///
+ public Pawn Pawn => pawn;
+ ///
+ /// Read-only collection of pawn quirks
+ ///
+ public IReadOnlyCollection AllQuirks => quirks.AsReadOnly();
+
+ ///
+ /// Try to add a quirk of to the pawn
+ ///
+ /// Def of quirk to add
+ /// Ignore all restrictions and "just do it"
+ /// Added quirk or null if addiction failed
+ public Quirk AddQuirk(QuirkDef quirkDef, bool ignoreChecks = false)
+ {
+ Quirk quirk = new Quirk(quirkDef, pawn);
+
+ if (AddQuirk(quirk, ignoreChecks).Accepted)
+ {
+ return quirk;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ ///
+ /// Try to add the to the pawn
+ ///
+ /// Quirk to add
+ /// Ignore all restrictions and "just do it"
+ /// AcceptanceReport
+ protected AcceptanceReport AddQuirk(Quirk quirk, bool ignoreChecks = false)
+ {
+ if (!ignoreChecks)
+ {
+ AcceptanceReport report = CanBeAdded(quirk.def);
+ if (!report.Accepted)
+ {
+ return report;
+ }
+ }
+
+ quirks.Add(quirk);
+ RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.QuirkAddedTo, pawn.Named(RjwEventArgNames.Pawn), quirk.Named(RjwEventArgNames.Quirk)));
+ return AcceptanceReport.WasAccepted;
+ }
+
+ ///
+ /// Try to remove the from the pawn
+ ///
+ /// Quirk to remove
+ /// Ignore all restrictions and "just do it"
+ /// AcceptanceReport
+ public AcceptanceReport RemoveQuirk(Quirk quirk, bool ignoreChecks = false)
+ {
+ if (!ignoreChecks)
+ {
+ AcceptanceReport report = CanBeRemoved(quirk.def);
+ if (!report.Accepted)
+ {
+ return report;
+ }
+ }
+
+ bool result = quirks.Remove(quirk);
+
+ if (!result)
+ {
+ if (quirks.Contains(quirk))
+ {
+ ModLog.Warning($"Tried to remove {quirk.Label} quirk from {pawn} but failed.");
+ }
+ else
+ {
+ ModLog.Warning($"Trying to remove {quirk.Label} quirk but {pawn} doesn't have it.");
+ }
+ return AcceptanceReport.WasRejected;
+ }
+
+ RjwEventManager.NotifyEvent(new RjwEvent(RjwEventDefOf.QuirkRemovedFrom, pawn.Named(RjwEventArgNames.Pawn), quirk.Named(RjwEventArgNames.Quirk)));
+ return AcceptanceReport.WasAccepted;
+ }
+
+ ///
+ /// Check if a quirk of can be added to the pawn
+ ///
+ public AcceptanceReport CanBeAdded(QuirkDef quirkDef)
+ {
+ if (Contains(quirkDef))
+ {
+ return AcceptanceReport.WasRejected;
+ }
+
+ foreach (OwnerRequirement req in quirkDef.ownerRequirements)
+ {
+ AcceptanceReport report = req.CheckBeforeAdd(pawn);
+ if (!report.Accepted)
+ {
+ return report;
+ }
+ }
+
+ if (quirks.Find(quirk => quirk.def.ConflictsWith(quirkDef)) is Quirk quirked)
+ {
+ return new AcceptanceReport("ConflictsWithQuirk".Translate(quirked.Label));
+ }
+
+ if (Pawn?.story?.traits?.allTraits is List traits)
+ {
+ foreach (Trait trait in traits)
+ {
+ if (quirks.Find(quirk => quirk.def.ConflictsWith(trait.def)) != null)
+ {
+ return new AcceptanceReport("ConflictsWithTrait".Translate(trait.LabelCap));
+ }
+ }
+ }
+
+ return AcceptanceReport.WasAccepted;
+ }
+
+ ///
+ /// Check if a quirk of can be removed from the pawn
+ ///
+ public AcceptanceReport CanBeRemoved(QuirkDef quirkDef)
+ {
+ if (!Contains(quirkDef))
+ {
+ return AcceptanceReport.WasRejected;
+ }
+
+ if (quirkDef.rarity == QuirkRarity.ForcedOnly)
+ {
+ return new AcceptanceReport("CannotRemoveForced".Translate());
+ }
+
+ return AcceptanceReport.WasAccepted;
+ }
+
+ ///
+ /// Check if the pawn has a quirk of
+ ///
+ public bool Contains(QuirkDef quirkDef)
+ {
+ for (int i = 0; i < quirks.Count; i++)
+ {
+ if (quirks[i].def == quirkDef)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ ///
+ /// Get a quirk of
+ ///
+ public Quirk GetQuirk(QuirkDef quirkDef)
+ {
+ for (int i = 0; i < quirks.Count; i++)
+ {
+ if (quirks[i].def == quirkDef)
+ {
+ return quirks[i];
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Remove all quirks from the pawn
+ ///
+ /// even quirks that can't be removed normaly
+ public void Clear(bool ignoreChecks = false) => new List(quirks).ForEach(quirk => RemoveQuirk(quirk, ignoreChecks));
+
+ ///
+ /// Get a collection of quirks that are satified by a particular sex act
+ ///
+ public IEnumerable GetSatisfiedBySex(SexProps props) => quirks.Where(quirk => quirk.def.IsSatisfiedBySex(props));
+
+ ///
+ /// Pass the RJW event to every quirk of the pawn
+ ///
+ public void NotifyEvent(RjwEvent ev) => quirks.ForEach(quirk => quirk.NotifyEvent(ev));
+
+ public void ApplySexAppraisalModifiers(Pawn partner, string factorName, ref float value)
+ {
+ foreach (var comp in quirks.SelectMany(quirk => quirk.def.GetComps())
+ .Where(comp => comp.factorName == factorName)
+ .OrderBy(comp => comp.priority))
+ {
+ comp.TryModifyValue(pawn, partner, factorName, ref value);
+ }
+ }
+
+ public void ApplyValueModifiers(string valueName, ref float value)
+ {
+ foreach (var comp in quirks.SelectMany(quirk => quirk.def.GetComps())
+ .Where(comp => comp.valueName == valueName)
+ .OrderBy(comp => comp.priority))
+ {
+ comp.TryModifyValue(valueName, ref value);
+ }
+ }
+
+ public void ApplyValueModifiers(string valueName, ref int value)
+ {
+ float valueF = value;
+ ApplyValueModifiers(valueName, ref valueF);
+ value = (int)valueF;
+ }
+
+ public override void PostExposeData()
+ {
+ base.PostExposeData();
+
+ Scribe_Collections.Look(ref quirks, "allQuirks", LookMode.Deep);
+
+ if (Scribe.mode == LoadSaveMode.LoadingVars)
+ {
+ if (quirks.RemoveAll((x) => x == null) != 0)
+ {
+ Log.Error("Some quirks were null after loading.");
+ }
+ if (quirks.RemoveAll((x) => x.def == null) != 0)
+ {
+ Log.Error("Some quirks had null def after loading.");
+ }
+ for (int i = 0; i < quirks.Count; i++)
+ {
+ quirks[i].pawn = pawn;
+ }
+ }
+ }
+
+ public string TipString()
+ {
+ if (quirks.Count == 0)
+ {
+ return "NoQuirks".Translate();
+ }
+
+ StringBuilder stringBuilder = new StringBuilder();
+ foreach (var quirk in quirks.OrderBy(q => q.Label))
+ {
+ stringBuilder.AppendLine(quirk.TipString());
+ stringBuilder.AppendLine("");
+ }
+
+ return stringBuilder.ToString().TrimEndNewlines();
+ }
+
+ ///
+ /// Fill the QuirkSet from a legacy save string
+ ///
+ public void ParseQuirkSave(string quirksave)
+ {
+ if (quirksave == "None")
+ {
+ return;
+ }
+
+ foreach (string name in quirksave.Split(','))
+ {
+ if (name.NullOrEmpty())
+ continue;
+
+ string defName = name.Trim();
+
+ // Old keys doubled as labels. But we can't rely on that becaule def.label can be localized
+ if (defName.Contains(" "))
+ {
+ // To PascalCase
+ defName = defName.Split(' ').Select(part => part.CapitalizeFirst()).Aggregate((x, y) => x + y);
+ }
+
+ QuirkDef def = DefDatabase.GetNamed(defName);
+
+ if (def == null)
+ continue;
+
+ quirks.Add(new Quirk(def, pawn));
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/BySextype.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/BySextype.cs
new file mode 100644
index 0000000..b853395
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/BySextype.cs
@@ -0,0 +1,25 @@
+using rjw;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class BySextype : SexSelector
+ {
+ public xxx.rjwSextype sextype = xxx.rjwSextype.None;
+
+ public override bool SexSatisfies(SexProps sexProps) => sexProps.hasPartner() && sexProps.sexType == sextype;
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (sextype == xxx.rjwSextype.None)
+ {
+ yield return " is not filled or has value \"None\"";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/CanBeImpregnated.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/CanBeImpregnated.cs
new file mode 100644
index 0000000..db5a155
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/CanBeImpregnated.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class CanBeImpregnated : SexSelector
+ {
+ public override bool SexSatisfies(SexProps sexProps) => sexProps.hasPartner() && PregnancyHelper.CanImpregnate(sexProps.partner, sexProps.pawn, sexProps.sexType);
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/CanImpregnate.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/CanImpregnate.cs
new file mode 100644
index 0000000..69d8341
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/CanImpregnate.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class CanImpregnate : SexSelector
+ {
+ public override bool SexSatisfies(SexProps sexProps) => sexProps.hasPartner() && PregnancyHelper.CanImpregnate(sexProps.pawn, sexProps.partner, sexProps.sexType);
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/Clothed.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/Clothed.cs
new file mode 100644
index 0000000..d6f1039
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/Clothed.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class Clothed : SexSelector
+ {
+ public override bool SexSatisfies(SexProps sexProps) => !sexProps.pawn.apparel.PsychologicallyNude;
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/ISexSelector.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/ISexSelector.cs
new file mode 100644
index 0000000..b11558b
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/ISexSelector.cs
@@ -0,0 +1,10 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public interface ISexSelector : Shared.IDefPart
+ {
+ void SetParent(QuirkDef quirkDef);
+ bool SexSatisfies(SexProps sexProps);
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalAnd.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalAnd.cs
new file mode 100644
index 0000000..d52f697
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalAnd.cs
@@ -0,0 +1,20 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class LogicalAnd : LogicalMultipart
+ {
+ public override bool SexSatisfies(SexProps sexProps)
+ {
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (!parts[i].SexSatisfies(sexProps))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalMultipart.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalMultipart.cs
new file mode 100644
index 0000000..5d891c5
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalMultipart.cs
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public abstract class LogicalMultipart : SexSelector
+ {
+ public List parts = new List();
+
+ public override void SetParent(QuirkDef quirkDef)
+ {
+ base.SetParent(quirkDef);
+ parts.ForEach(selector => selector.SetParent(quirkDef));
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (parts.Count < 2)
+ {
+ yield return " should have at least 2 elements";
+ }
+
+ foreach (var part in parts)
+ {
+ foreach (string error in part.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalNot.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalNot.cs
new file mode 100644
index 0000000..dcea851
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalNot.cs
@@ -0,0 +1,39 @@
+using rjw;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class LogicalNot : SexSelector
+ {
+ public ISexSelector negated;
+
+ public override bool SexSatisfies(SexProps sexProps) => !negated.SexSatisfies(sexProps);
+
+ public override void SetParent(QuirkDef quirkDef)
+ {
+ base.SetParent(quirkDef);
+ negated.SetParent(quirkDef);
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (negated == null)
+ {
+ yield return " is empty";
+ }
+ else
+ {
+ foreach (string error in negated.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalOr.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalOr.cs
new file mode 100644
index 0000000..99353c1
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/LogicalOr.cs
@@ -0,0 +1,20 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class LogicalOr : LogicalMultipart
+ {
+ public override bool SexSatisfies(SexProps sexProps)
+ {
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (parts[i].SexSatisfies(sexProps))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/Seen.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/Seen.cs
new file mode 100644
index 0000000..d534e1c
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/Seen.cs
@@ -0,0 +1,23 @@
+using rjw;
+using Verse;
+using Verse.AI;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class Seen : SexSelector
+ {
+ // Current implementation works only if somebody sees pawn exactly at the moment quirks are evaluated
+ public override bool SexSatisfies(SexProps sexProps) => sexProps.hasPartner() && SexSeen(sexProps);
+
+ public static bool SexSeen(SexProps sexProps)
+ {
+ bool isZoophile = xxx.is_zoophile(sexProps.pawn);
+ return sexProps.pawn.Map.mapPawns.AllPawnsSpawned.Any(x =>
+ x != sexProps.pawn
+ && x != sexProps.partner
+ && !x.Dead
+ && (isZoophile || !xxx.is_animal(x))
+ && x.CanSee(sexProps.pawn));
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/SexSelector.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/SexSelector.cs
new file mode 100644
index 0000000..a4f68a8
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/SexSelector.cs
@@ -0,0 +1,19 @@
+using rjw;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public abstract class SexSelector : ISexSelector
+ {
+ protected QuirkDef parentDef;
+
+ public abstract bool SexSatisfies(SexProps sexProps);
+
+ public virtual void SetParent(QuirkDef quirkDef) => parentDef = quirkDef;
+
+ public virtual IEnumerable ConfigErrors()
+ {
+ yield break;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Quirks/SexSelectors/WithPreferedPartner.cs b/RJW-Quirks/Modules/Quirks/SexSelectors/WithPreferedPartner.cs
new file mode 100644
index 0000000..3af5f66
--- /dev/null
+++ b/RJW-Quirks/Modules/Quirks/SexSelectors/WithPreferedPartner.cs
@@ -0,0 +1,9 @@
+using rjw;
+
+namespace rjwquirks.Modules.Quirks.SexSelectors
+{
+ public class WithPreferedPartner : SexSelector
+ {
+ public override bool SexSatisfies(SexProps sexProps) => sexProps.hasPartner() && parentDef.partnerPreference?.PartnerSatisfies(sexProps.pawn, sexProps.partner) == true;
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEvent.cs b/RJW-Quirks/Modules/Shared/Events/RjwEvent.cs
new file mode 100644
index 0000000..3630c90
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEvent.cs
@@ -0,0 +1,21 @@
+using RimWorld;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.Events
+{
+ ///
+ /// Copy of the HistoryEvent.
+ /// Made it it's own thing because it use cases are different
+ ///
+ public struct RjwEvent
+ {
+ public RjwEventDef def;
+ public SignalArgs args;
+
+ public RjwEvent(RjwEventDef def, params NamedArgument[] args)
+ {
+ this.def = def;
+ this.args = new SignalArgs(args);
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventArgNames.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventArgNames.cs
new file mode 100644
index 0000000..9c2d1ee
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventArgNames.cs
@@ -0,0 +1,11 @@
+namespace rjwquirks.Modules.Shared.Events
+{
+ public static class RjwEventArgNames
+ {
+ public static readonly string Pawn = "Pawn";
+ public static readonly string SexProps = "SexProps";
+ public static readonly string Quirk = "Quirk";
+ public static readonly string Record = "Record";
+ public static readonly string Satisfaction = "Satisfaction";
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventDef.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventDef.cs
new file mode 100644
index 0000000..b1c2756
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventDef.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.Events
+{
+ public class RjwEventDef : Def
+ {
+ public List obligatoryArgs;
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventDefOf.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventDefOf.cs
new file mode 100644
index 0000000..8486313
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventDefOf.cs
@@ -0,0 +1,14 @@
+using RimWorld;
+
+namespace rjwquirks.Modules.Shared.Events
+{
+ [DefOf]
+ public static class RjwEventDefOf
+ {
+ public static readonly RjwEventDef QuirkAddedTo;
+ public static readonly RjwEventDef QuirkRemovedFrom;
+ public static readonly RjwEventDef Orgasm;
+ public static readonly RjwEventDef RecordChanged;
+ public static readonly RjwEventDef PawnSexualized;
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventHandler.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventHandler.cs
new file mode 100644
index 0000000..9040b53
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventHandler.cs
@@ -0,0 +1,8 @@
+namespace rjwquirks.Modules.Shared.Events
+{
+ public abstract class RjwEventHandler
+ {
+ public RjwEventHandlerDef def;
+ public abstract void HandleEvent(RjwEvent ev);
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventHandlerDef.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventHandlerDef.cs
new file mode 100644
index 0000000..ba417fa
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventHandlerDef.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.Events
+{
+ public class RjwEventHandlerDef : Def
+ {
+ public Type workerClass;
+ public List handlesEvents;
+
+ private RjwEventHandler _worker;
+
+ public RjwEventHandler Worker
+ {
+ get
+ {
+ if (_worker == null)
+ {
+ _worker = (RjwEventHandler)Activator.CreateInstance(workerClass);
+ _worker.def = this;
+ }
+ return _worker;
+ }
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (workerClass == null)
+ {
+ yield return " is empty";
+ }
+
+ if (handlesEvents == null || handlesEvents.Count == 0)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Events/RjwEventManager.cs b/RJW-Quirks/Modules/Shared/Events/RjwEventManager.cs
new file mode 100644
index 0000000..396108e
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Events/RjwEventManager.cs
@@ -0,0 +1,97 @@
+using RimWorld;
+using rjw.Modules.Shared.Logs;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.Events
+{
+ public static class RjwEventManager
+ {
+ private static readonly Dictionary> _handlers = BuildHandlerDictionary();
+ private static readonly ILog _logger = LogManager.GetLogger("RjwEventManager");
+
+ ///
+ /// Routes RJW events to the relevant event handlers based on the def subscriptions
+ ///
+ public static void NotifyEvent(RjwEvent ev)
+ {
+ //implement own settings later
+ if (Prefs.DevMode)
+ {
+ _logger.Message($"RJW Event {ev.def}{SignalArgsToString(ev.args)}");
+ }
+
+ if (!_handlers.TryGetValue(ev.def, out List eventHandlers))
+ {
+ return;
+ }
+
+ if (Prefs.DevMode)
+ {
+ // Since event args are filled in C#, no reason to waste time checking them outside of the actual mod developement
+ CheckObligatoryArgs(ev);
+ }
+
+ foreach (RjwEventHandler handler in eventHandlers)
+ {
+ try
+ {
+ handler.HandleEvent(ev);
+ }
+ catch (Exception e)
+ {
+ // suppress exceptions so one bad mod wouldn't break everything
+ _logger.Error($"Handler exception when handling {ev.def}", e);
+ }
+ }
+ }
+
+ private static Dictionary> BuildHandlerDictionary()
+ {
+ Dictionary> handlers = new Dictionary>();
+
+ foreach (RjwEventHandlerDef handlerDef in DefDatabase.AllDefsListForReading)
+ {
+ foreach (RjwEventDef eventDef in handlerDef.handlesEvents)
+ {
+ if (handlers.ContainsKey(eventDef))
+ {
+ handlers[eventDef].Add(handlerDef.Worker);
+ }
+ else
+ {
+ handlers[eventDef] = new List { handlerDef.Worker };
+ }
+ }
+ }
+
+ return handlers;
+ }
+
+ private static void CheckObligatoryArgs(RjwEvent ev)
+ {
+ foreach (string argName in ev.def.obligatoryArgs)
+ {
+ if (!ev.args.TryGetArg(argName, out _))
+ {
+ _logger.Error($"Got a {ev.def} event without the obligatory argument '{argName}'");
+ }
+ }
+ }
+
+ private static string SignalArgsToString(SignalArgs args)
+ {
+ StringBuilder message = new StringBuilder();
+
+ foreach (var arg in args.Args)
+ {
+ message.Append(", ");
+ message.Append(arg);
+ }
+
+ return message.ToString();
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/IDefPart.cs b/RJW-Quirks/Modules/Shared/IDefPart.cs
new file mode 100644
index 0000000..5f005b7
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/IDefPart.cs
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Shared
+{
+ ///
+ /// This interface designates that a class is ment to be included in a def and
+ /// instantiated by the Rimworld when the def is loaded
+ ///
+ public interface IDefPart
+ {
+ ///
+ /// Needed to be called explicidly in the def's ConfigErrors()
+ ///
+ IEnumerable ConfigErrors();
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Shared/Selectors/IPartnerSelector.cs b/RJW-Quirks/Modules/Shared/Selectors/IPartnerSelector.cs
new file mode 100644
index 0000000..7a71eb8
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/IPartnerSelector.cs
@@ -0,0 +1,16 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ ///
+ /// Partner selectors are similar to the pawn selectors, but can define relations between two pawns.
+ ///
+ public interface IPartnerSelector : IDefPart
+ {
+ ///
+ /// Returns true if the partner satisfies all XML-defined conditions in relation to the pawn.
+ /// Non-commutative
+ ///
+ bool PartnerSatisfies(Pawn pawn, Pawn partner);
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Shared/Selectors/IPawnSelector.cs b/RJW-Quirks/Modules/Shared/Selectors/IPawnSelector.cs
new file mode 100644
index 0000000..e07d01b
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/IPawnSelector.cs
@@ -0,0 +1,15 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ ///
+ /// Pawn selectors are designed to provide a flexible way to define pawn requirements in the defs
+ ///
+ public interface IPawnSelector : IDefPart
+ {
+ ///
+ /// Returns true if pawn satisfies all XML-defined conditions
+ ///
+ bool PawnSatisfies(Pawn pawn);
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/CanBeImpregnatedBy.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/CanBeImpregnatedBy.cs
new file mode 100644
index 0000000..b203c6e
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/CanBeImpregnatedBy.cs
@@ -0,0 +1,10 @@
+using rjw;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class CanBeImpregnatedBy : PartnerSelector
+ {
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner) => PregnancyHelper.CanImpregnate(partner, pawn);
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/CanImpregnate.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/CanImpregnate.cs
new file mode 100644
index 0000000..9073f0e
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/CanImpregnate.cs
@@ -0,0 +1,10 @@
+using rjw;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class CanImpregnate : PartnerSelector
+ {
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner) => PregnancyHelper.CanImpregnate(pawn, partner);
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/HasOneOfRelations.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/HasOneOfRelations.cs
new file mode 100644
index 0000000..e661bb4
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/HasOneOfRelations.cs
@@ -0,0 +1,48 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class HasOneOfRelations : PartnerSelector
+ {
+ public List relations;
+
+ private HashSet relationsHashSet;
+
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner)
+ {
+ if (relationsHashSet == null)
+ {
+ relationsHashSet = new HashSet(relations);
+ }
+
+ IEnumerable pawnRelations = pawn.GetRelations(partner);
+
+ if (pawnRelations.EnumerableNullOrEmpty())
+ {
+ return false;
+ }
+
+ if (!relationsHashSet.Overlaps(pawnRelations))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (relations.NullOrEmpty())
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalAnd.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalAnd.cs
new file mode 100644
index 0000000..29e44f4
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalAnd.cs
@@ -0,0 +1,23 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class LogicalAnd : LogicalMultipart
+ {
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner)
+ {
+ if (partner == null)
+ return false;
+
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (!parts[i].PartnerSatisfies(pawn, partner))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalMultipart.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalMultipart.cs
new file mode 100644
index 0000000..b1a79da
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalMultipart.cs
@@ -0,0 +1,31 @@
+using rjwquirks.Modules.Shared.PawnSelectors;
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public abstract class LogicalMultipart : PartnerSelector
+ {
+ public List parts = new List();
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (parts.Count < 2)
+ {
+ yield return " should have at least 2 elements";
+ }
+
+ foreach (var part in parts)
+ {
+ foreach (string error in part.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalNot.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalNot.cs
new file mode 100644
index 0000000..941366d
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalNot.cs
@@ -0,0 +1,34 @@
+using rjwquirks.Modules.Shared.PawnSelectors;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class LogicalNot : PartnerSelector
+ {
+ public IPartnerSelector negated;
+
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner) => !negated.PartnerSatisfies(pawn, partner);
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (negated == null)
+ {
+ yield return " is empty";
+ }
+ else
+ {
+ foreach (string error in negated.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalOr.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalOr.cs
new file mode 100644
index 0000000..1ce47c5
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/LogicalOr.cs
@@ -0,0 +1,23 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public class LogicalOr : LogicalMultipart
+ {
+ public override bool PartnerSatisfies(Pawn pawn, Pawn partner)
+ {
+ if (partner == null)
+ return false;
+
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (parts[i].PartnerSatisfies(pawn, partner))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Partner/PartnerSelector.cs b/RJW-Quirks/Modules/Shared/Selectors/Partner/PartnerSelector.cs
new file mode 100644
index 0000000..1ba8cd1
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Partner/PartnerSelector.cs
@@ -0,0 +1,16 @@
+using rjwquirks.Modules.Shared.PawnSelectors;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PartnerSelectors
+{
+ public abstract class PartnerSelector : IPartnerSelector
+ {
+ public abstract bool PartnerSatisfies(Pawn pawn, Pawn partner);
+
+ public virtual IEnumerable ConfigErrors()
+ {
+ yield break;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasBodyType.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasBodyType.cs
new file mode 100644
index 0000000..cae86e0
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasBodyType.cs
@@ -0,0 +1,26 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasBodyType : PawnSelector
+ {
+ public BodyTypeDef bodyType;
+
+ public override bool PawnSatisfies(Pawn pawn) => pawn.story?.bodyType == bodyType;
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (bodyType == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasDegreeOfTrait.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasDegreeOfTrait.cs
new file mode 100644
index 0000000..741b77b
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasDegreeOfTrait.cs
@@ -0,0 +1,31 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasDegreeOfTrait : PawnSelector
+ {
+ public TraitDef trait;
+ public int degree = 0;
+
+ public override bool PawnSatisfies(Pawn pawn) => pawn.story?.traits?.HasTrait(trait, degree) == true;
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (trait == null)
+ {
+ yield return " is empty";
+ }
+ else if (trait.degreeDatas.Find(d => d.degree == degree) == null)
+ {
+ yield return $"{trait.defName} has no data for a degree {degree}";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasFertility.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasFertility.cs
new file mode 100644
index 0000000..4fae9d5
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasFertility.cs
@@ -0,0 +1,10 @@
+using rjw;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasFertility : PawnSelector
+ {
+ public override bool PawnSatisfies(Pawn pawn) => pawn.RaceHasFertility();
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasGender.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasGender.cs
new file mode 100644
index 0000000..657cfa1
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasGender.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasGender : PawnSelector
+ {
+ public Gender gender = Gender.None;
+
+ public override bool PawnSatisfies(Pawn pawn) => pawn.gender == gender;
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (gender == Gender.None)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasHumanScaleAge.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasHumanScaleAge.cs
new file mode 100644
index 0000000..48e574c
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasHumanScaleAge.cs
@@ -0,0 +1,31 @@
+using rjw;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasHumanScaleAge : PawnSelector
+ {
+ public int min = 0;
+ public int max = 1000;
+
+ public override bool PawnSatisfies(Pawn pawn)
+ {
+ int humanScaleAge = SexUtility.ScaleToHumanAge(pawn);
+ return min <= humanScaleAge && humanScaleAge <= max;
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (min == 0 && max == 1000)
+ {
+ yield return " and/or should be filled";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasRaceTag.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasRaceTag.cs
new file mode 100644
index 0000000..a436813
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasRaceTag.cs
@@ -0,0 +1,44 @@
+using rjw;
+using rjwquirks.Data;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasRaceTag : PawnSelector
+ {
+ ///
+ /// For def load only. Use RaceTag property
+ ///
+ public string raceTag;
+
+ public RaceTags RaceTag
+ {
+ get
+ {
+ if (RaceTags.TryParse(raceTag, out RaceTags tag))
+ return tag;
+ return null;
+ }
+ }
+
+ public override bool PawnSatisfies(Pawn pawn) => pawn.HasRaceTag(RaceTag);
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (raceTag.NullOrEmpty())
+ {
+ yield return " is empty";
+ }
+ else if (!RaceTags.TryParse(raceTag, out _))
+ {
+ yield return $"\"{raceTag}\" is not a valid RaceTag";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasSkillLevel.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasSkillLevel.cs
new file mode 100644
index 0000000..ba95dd9
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasSkillLevel.cs
@@ -0,0 +1,36 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasSkillLevel : PawnSelector
+ {
+ public SkillDef skill;
+ public int minLevel = 0;
+ public int maxLevel = 200; // mods can unlock levels past 20
+
+ public override bool PawnSatisfies(Pawn pawn)
+ {
+ int skillLevel = pawn.skills?.GetSkill(skill)?.levelInt ?? -1;
+ return minLevel <= skillLevel && skillLevel <= maxLevel;
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (skill == null)
+ {
+ yield return " is empty";
+ }
+ if (minLevel == 0 && maxLevel == 200)
+ {
+ yield return " and/or should be filled";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasStatValue.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasStatValue.cs
new file mode 100644
index 0000000..d52452c
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasStatValue.cs
@@ -0,0 +1,36 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasStatValue : PawnSelector
+ {
+ public StatDef stat;
+ public float minValue = float.MinValue;
+ public float maxValue = float.MaxValue;
+
+ public override bool PawnSatisfies(Pawn pawn)
+ {
+ float statValue = pawn.GetStatValue(stat);
+ return minValue <= statValue && statValue <= maxValue;
+ }
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (stat == null)
+ {
+ yield return " is empty";
+ }
+ if (minValue == float.MinValue && maxValue == float.MaxValue)
+ {
+ yield return " and/or should be filled";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasTrait.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasTrait.cs
new file mode 100644
index 0000000..6ef5ee5
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/HasTrait.cs
@@ -0,0 +1,26 @@
+using RimWorld;
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class HasTrait : PawnSelector
+ {
+ public TraitDef trait;
+
+ public override bool PawnSatisfies(Pawn pawn) => pawn.story?.traits?.HasTrait(trait) == true;
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (trait == null)
+ {
+ yield return " is empty";
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsDisfigured.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsDisfigured.cs
new file mode 100644
index 0000000..93fe6fe
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsDisfigured.cs
@@ -0,0 +1,10 @@
+using RimWorld;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class IsDisfigured : PawnSelector
+ {
+ public override bool PawnSatisfies(Pawn pawn) => RelationsUtility.IsDisfigured(pawn);
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsHumanlike.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsHumanlike.cs
new file mode 100644
index 0000000..5afdba7
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsHumanlike.cs
@@ -0,0 +1,9 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class IsHumanlike : PawnSelector
+ {
+ public override bool PawnSatisfies(Pawn pawn) => pawn?.RaceProps?.Humanlike == true;
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsSleeping.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsSleeping.cs
new file mode 100644
index 0000000..f3cc640
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsSleeping.cs
@@ -0,0 +1,10 @@
+using RimWorld;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class IsSleeping : PawnSelector
+ {
+ public override bool PawnSatisfies(Pawn pawn) => !pawn.Awake();
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsVisiblyPregnant.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsVisiblyPregnant.cs
new file mode 100644
index 0000000..402c969
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/IsVisiblyPregnant.cs
@@ -0,0 +1,10 @@
+using rjw;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class IsVisiblyPregnant : PawnSelector
+ {
+ public override bool PawnSatisfies(Pawn pawn) => pawn.IsVisiblyPregnant();
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalAnd.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalAnd.cs
new file mode 100644
index 0000000..f4a2fa3
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalAnd.cs
@@ -0,0 +1,20 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class LogicalAnd : LogicalMultipart
+ {
+ public override bool PawnSatisfies(Pawn pawn)
+ {
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (!parts[i].PawnSatisfies(pawn))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalMultipart.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalMultipart.cs
new file mode 100644
index 0000000..9984174
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalMultipart.cs
@@ -0,0 +1,30 @@
+using System.Collections.Generic;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public abstract class LogicalMultipart : PawnSelector
+ {
+ public List parts = new List();
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (parts.Count < 2)
+ {
+ yield return " should have at least 2 elements";
+ }
+
+ foreach (var part in parts)
+ {
+ foreach (string error in part.ConfigErrors())
+ {
+ yield return error;
+ }
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalNot.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalNot.cs
new file mode 100644
index 0000000..5bfe3fe
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalNot.cs
@@ -0,0 +1,33 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class LogicalNot : PawnSelector
+ {
+ public IPawnSelector negated;
+
+ public override bool PawnSatisfies(Pawn pawn) => !negated.PawnSatisfies(pawn);
+
+ public override IEnumerable ConfigErrors()
+ {
+ foreach (string error in base.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ if (negated == null)
+ {
+ yield return " is empty";
+ }
+ else
+ {
+ foreach (string error in negated.ConfigErrors())
+ {
+ yield return error;
+ }
+
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalOr.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalOr.cs
new file mode 100644
index 0000000..170826f
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/LogicalOr.cs
@@ -0,0 +1,20 @@
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public class LogicalOr : LogicalMultipart
+ {
+ public override bool PawnSatisfies(Pawn pawn)
+ {
+ for (int i = 0; i < parts.Count; i++)
+ {
+ if (parts[i].PawnSatisfies(pawn))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/RJW-Quirks/Modules/Shared/Selectors/Pawn/PawnSelector.cs b/RJW-Quirks/Modules/Shared/Selectors/Pawn/PawnSelector.cs
new file mode 100644
index 0000000..9aced1f
--- /dev/null
+++ b/RJW-Quirks/Modules/Shared/Selectors/Pawn/PawnSelector.cs
@@ -0,0 +1,17 @@
+using System.Collections.Generic;
+using Verse;
+
+namespace rjwquirks.Modules.Shared.PawnSelectors
+{
+ public abstract class PawnSelector : IPawnSelector, IPartnerSelector
+ {
+ public abstract bool PawnSatisfies(Pawn pawn);
+
+ public bool PartnerSatisfies(Pawn pawn, Pawn partner) => PawnSatisfies(partner);
+
+ public virtual IEnumerable ConfigErrors()
+ {
+ yield break;
+ }
+ }
+}
diff --git a/RJW-Quirks/PawnExtensions.cs b/RJW-Quirks/PawnExtensions.cs
new file mode 100644
index 0000000..b737f64
--- /dev/null
+++ b/RJW-Quirks/PawnExtensions.cs
@@ -0,0 +1,32 @@
+using rjw;
+using rjwquirks.Data;
+using rjwquirks.Modules.Quirks;
+using System.Linq;
+using Verse;
+
+namespace rjwquirks
+{
+ public static class PawnExtensions
+ {
+ public static bool HasQuirk(this Pawn pawn, QuirkDef quirk)
+ {
+ return xxx.is_human(pawn) && pawn.GetQuirks().Contains(quirk);
+ }
+
+ public static QuirkSet GetQuirks(this Pawn pawn)
+ {
+ return pawn.GetComp();
+ }
+
+ public static bool HasRaceTag(this Pawn pawn, RaceTags tag)
+ {
+ if (RaceGroupDef_Helper.TryGetRaceGroupDef(pawn, out var raceGroupDef))
+ {
+ return raceGroupDef.tags != null && raceGroupDef.tags.Contains(tag.Key);
+ } else
+ {
+ return tag.DefaultWhenNoRaceGroupDef(pawn);
+ }
+ }
+ }
+}
diff --git a/RJW-Quirks/Properties/AssemblyInfo.cs b/RJW-Quirks/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f7eeb19
--- /dev/null
+++ b/RJW-Quirks/Properties/AssemblyInfo.cs
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RJW-Quirks")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("RJW-Quirks")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e8ad47f9-dc4f-4e36-8e03-c148c7cea9e2")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/RJW-Quirks/RJW-Quirks.csproj b/RJW-Quirks/RJW-Quirks.csproj
new file mode 100644
index 0000000..02152b0
--- /dev/null
+++ b/RJW-Quirks/RJW-Quirks.csproj
@@ -0,0 +1,171 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}
+ Library
+ Properties
+ rjwquirks
+ RJW-Quirks
+ v4.7.2
+ 512
+ true
+
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ none
+ true
+ ..\1.4\Assemblies\
+ TRACE
+ prompt
+ 4
+
+
+
+ G:\SteamLibrary\steamapps\workshop\content\294100\2009463077\Current\Assemblies\0Harmony.dll
+ False
+
+
+ G:\SteamLibrary\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll
+ False
+
+
+ G:\SteamLibrary\steamapps\workshop\content\294100\818773962\v1.4\Assemblies\HugsLib.dll
+ False
+
+
+ G:\SteamLibrary\steamapps\common\RimWorld\Mods\rjwrepository\1.4\Assemblies\RJW.dll
+ False
+
+
+
+
+
+
+
+
+
+
+ G:\SteamLibrary\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll
+ False
+
+
+ G:\SteamLibrary\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll
+ False
+
+
+ G:\SteamLibrary\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.TextRenderingModule.dll
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RJW-Quirks/RJW-Quirks.sln b/RJW-Quirks/RJW-Quirks.sln
new file mode 100644
index 0000000..e1b42c9
--- /dev/null
+++ b/RJW-Quirks/RJW-Quirks.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32929.386
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RJW-Quirks", "RJW-Quirks.csproj", "{E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E8AD47F9-DC4F-4E36-8E03-C148C7CEA9E2}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {0521884B-2E20-4DD8-BBE6-9FA3CB026E97}
+ EndGlobalSection
+EndGlobal