2022-05-24 15:49:01 +00:00
using RimWorld ;
2021-09-24 15:14:02 +00:00
using rjw ;
2022-05-24 15:49:01 +00:00
using rjw.Modules.Interactions.Enums ;
using rjw.Modules.Interactions.Helpers ;
using rjw.Modules.Interactions.Objects ;
2023-07-09 04:49:51 +00:00
using RJWSexperience.Logs ;
2022-05-24 15:49:01 +00:00
using System.Collections.Generic ;
2021-09-24 15:14:02 +00:00
using Verse ;
2022-03-20 14:15:55 +00:00
using Verse.AI ;
2021-09-24 15:14:02 +00:00
namespace RJWSexperience
{
2022-04-27 10:56:16 +00:00
public static class RJWUtility
2022-05-24 15:49:01 +00:00
{
2023-07-09 04:49:51 +00:00
private static readonly rjw . Modules . Shared . Logs . ILog s_log = LogManager . GetLogger < DebugLogProvider > ( "RJWUtility" ) ;
2022-05-24 15:49:01 +00:00
/// <summary>
/// For ideo patch
/// </summary>
2022-06-11 09:23:28 +00:00
[System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1163:Unused parameter.", Justification = "All parameters are needed for the ideology patch")]
2023-03-24 15:22:54 +00:00
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "All parameters are needed for the ideology patch")]
2022-07-08 17:48:57 +00:00
public static void ThrowVirginHistoryEvent ( Pawn exVirgin , Pawn partner , SexProps props , int degree )
2022-05-24 15:49:01 +00:00
{
//for non-ideo
if ( partner . Ideo = = null )
{
2022-07-08 17:48:57 +00:00
partner . needs ? . mood ? . thoughts ? . memories . TryGainMemory ( xxx . took_virginity , exVirgin ) ;
2022-05-24 15:49:01 +00:00
}
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
/ *
2021-11-25 03:40:27 +00:00
* Uses RJW 4.9 . 0 ' s new interactiondefs to determine giver and receiver based on reverse interactiontag
* /
2022-05-24 15:49:01 +00:00
public static void DetermineGiversAndReceivers ( SexProps props , out Pawn giver , out Pawn receiver )
{
InteractionWithExtension interaction = InteractionHelper . GetWithExtension ( props . dictionaryKey ) ;
if ( interaction . HasInteractionTag ( InteractionTag . Reverse ) )
{
receiver = props . partner ;
giver = props . pawn ;
}
else
{
receiver = props . pawn ;
giver = props . partner ;
}
}
2021-11-25 03:40:27 +00:00
2022-05-24 15:49:01 +00:00
public static void UpdateSextypeRecords ( SexProps props )
{
xxx . rjwSextype sextype = props . sexType ;
Pawn pawn = props . pawn ;
Pawn partner = props . partner ;
2021-11-25 03:40:27 +00:00
2022-05-24 15:49:01 +00:00
DetermineGiversAndReceivers ( props , out Pawn giver , out Pawn receiver ) ;
2021-11-25 03:40:27 +00:00
2022-05-24 15:49:01 +00:00
if ( partner ! = null )
{
switch ( sextype )
{
case xxx . rjwSextype . Vaginal :
case xxx . rjwSextype . Scissoring :
2023-04-17 11:34:35 +00:00
IncreaseSameRecords ( pawn , partner , RsDefOf . Record . VaginalSexCount ) ;
2022-05-24 15:49:01 +00:00
break ;
case xxx . rjwSextype . Anal :
2023-04-17 11:34:35 +00:00
IncreaseSameRecords ( pawn , partner , RsDefOf . Record . AnalSexCount ) ;
2022-05-24 15:49:01 +00:00
break ;
case xxx . rjwSextype . Oral :
case xxx . rjwSextype . Fellatio :
if ( Genital_Helper . has_penis_fertile ( giver ) | | Genital_Helper . has_penis_infertile ( giver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . OralSexCount , RsDefOf . Record . BlowjobCount ) ;
2022-05-24 15:49:01 +00:00
}
else if ( Genital_Helper . has_penis_fertile ( receiver ) | | Genital_Helper . has_penis_infertile ( receiver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . BlowjobCount , RsDefOf . Record . OralSexCount ) ;
2022-05-24 15:49:01 +00:00
}
break ;
case xxx . rjwSextype . Sixtynine :
2023-04-17 11:34:35 +00:00
IncreaseSameRecords ( pawn , partner , RsDefOf . Record . OralSexCount ) ;
2022-05-24 15:49:01 +00:00
RecordDef recordpawn , recordpartner ;
if ( Genital_Helper . has_penis_fertile ( pawn ) | | Genital_Helper . has_penis_infertile ( pawn ) )
{
2023-04-17 11:34:35 +00:00
recordpartner = RsDefOf . Record . BlowjobCount ;
2022-05-24 15:49:01 +00:00
}
else
{
2023-04-17 11:34:35 +00:00
recordpartner = RsDefOf . Record . CunnilingusCount ;
2022-05-24 15:49:01 +00:00
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
if ( Genital_Helper . has_penis_fertile ( partner ) | | Genital_Helper . has_penis_infertile ( partner ) )
{
2023-04-17 11:34:35 +00:00
recordpawn = RsDefOf . Record . BlowjobCount ;
2022-05-24 15:49:01 +00:00
}
else
{
2023-04-17 11:34:35 +00:00
recordpawn = RsDefOf . Record . CunnilingusCount ;
2022-05-24 15:49:01 +00:00
}
IncreaseRecords ( pawn , partner , recordpawn , recordpartner ) ;
break ;
case xxx . rjwSextype . Cunnilingus :
if ( Genital_Helper . has_vagina ( giver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . OralSexCount , RsDefOf . Record . CunnilingusCount ) ;
2022-05-24 15:49:01 +00:00
}
else if ( Genital_Helper . has_vagina ( receiver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . CunnilingusCount , RsDefOf . Record . OralSexCount ) ;
2022-05-24 15:49:01 +00:00
}
break ;
case xxx . rjwSextype . Masturbation :
break ;
case xxx . rjwSextype . Handjob :
if ( Genital_Helper . has_penis_fertile ( giver ) | | Genital_Helper . has_penis_infertile ( giver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . GenitalCaressCount , RsDefOf . Record . HandjobCount ) ;
2022-05-24 15:49:01 +00:00
}
else
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . HandjobCount , RsDefOf . Record . GenitalCaressCount ) ;
2022-05-24 15:49:01 +00:00
}
break ;
case xxx . rjwSextype . Fingering :
case xxx . rjwSextype . Fisting :
if ( Genital_Helper . has_vagina ( giver ) )
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . GenitalCaressCount , RsDefOf . Record . FingeringCount ) ;
2022-05-24 15:49:01 +00:00
}
else
{
2023-04-17 11:34:35 +00:00
IncreaseRecords ( giver , receiver , RsDefOf . Record . FingeringCount , RsDefOf . Record . GenitalCaressCount ) ;
2022-05-24 15:49:01 +00:00
}
break ;
case xxx . rjwSextype . Footjob :
2023-04-17 11:34:35 +00:00
IncreaseSameRecords ( pawn , partner , RsDefOf . Record . FootjobCount ) ;
2022-05-24 15:49:01 +00:00
break ;
default :
2023-04-17 11:34:35 +00:00
IncreaseSameRecords ( pawn , partner , RsDefOf . Record . MiscSexualBehaviorCount ) ;
2022-05-24 15:49:01 +00:00
break ;
}
}
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
public static void IncreaseSameRecords ( Pawn pawn , Pawn partner , RecordDef record )
{
pawn . records ? . AddTo ( record , 1 ) ;
partner . records ? . AddTo ( record , 1 ) ;
}
2021-09-24 15:14:02 +00:00
2022-05-24 15:49:01 +00:00
public static void IncreaseRecords ( Pawn pawn , Pawn partner , RecordDef recordforpawn , RecordDef recordforpartner )
{
pawn . records ? . AddTo ( recordforpawn , 1 ) ;
partner . records ? . AddTo ( recordforpartner , 1 ) ;
}
2022-03-20 14:15:55 +00:00
2022-05-24 15:49:01 +00:00
// Moved this method back because of Menstruation
public static Building_CumBucket FindClosestBucket ( this Pawn pawn )
{
2023-04-17 11:34:35 +00:00
List < Building > buckets = pawn . Map . listerBuildings . allBuildingsColonist . FindAll ( x = > x is Building_CumBucket bucket & & bucket . StoredStackCount < RsDefOf . Thing . GatheredCum . stackLimit ) ;
2023-07-09 04:49:51 +00:00
if ( buckets . Count = = 0 )
{
s_log . Message ( "FindClosestBucket: No buckets on the map or buckets are full" ) ;
2022-05-24 15:49:01 +00:00
return null ;
2023-07-09 04:49:51 +00:00
}
2022-03-20 14:15:55 +00:00
2022-05-24 15:49:01 +00:00
Dictionary < Building , float > targets = new Dictionary < Building , float > ( ) ;
for ( int i = 0 ; i < buckets . Count ; i + + )
{
2023-07-09 04:49:51 +00:00
if ( pawn . CanReach ( buckets [ i ] , PathEndMode . ClosestTouch , Danger . Some ) )
2022-05-24 15:49:01 +00:00
{
targets . Add ( buckets [ i ] , pawn . Position . DistanceTo ( buckets [ i ] . Position ) ) ;
}
}
2023-07-09 04:49:51 +00:00
if ( targets . Count > 0 )
2022-05-24 15:49:01 +00:00
{
return ( Building_CumBucket ) targets . MinBy ( x = > x . Value ) . Key ;
}
2023-07-09 04:49:51 +00:00
else
{
s_log . Message ( "FindClosestBucket: No reachable buckets" ) ;
}
2022-05-24 15:49:01 +00:00
return null ;
}
}
2021-09-24 15:14:02 +00:00
}