106 lines
3.7 KiB
C#
106 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Verse;
|
|
using RimWorld;
|
|
using rjw;
|
|
|
|
namespace Privacy_Please
|
|
{
|
|
public class SexActReactionDef : Def
|
|
{
|
|
public string issueDefName;
|
|
public string sexActCheck;
|
|
public SubSexActReactionDef pawnReaction;
|
|
public SubSexActReactionDef witnessReaction;
|
|
|
|
private IssueDef _issueDef;
|
|
private bool _checkedForIssueDef;
|
|
|
|
public IssueDef issueDef
|
|
{
|
|
get
|
|
{
|
|
if (_checkedForIssueDef == false)
|
|
{ _issueDef = DefDatabase<IssueDef>.GetNamedSilentFail(issueDefName); _checkedForIssueDef = true; }
|
|
|
|
return _issueDef;
|
|
}
|
|
}
|
|
|
|
public class SubSexActReactionDef
|
|
{
|
|
public SexActThoughtDef defaultThoughtDef;
|
|
public List<SexActThoughtDef> associatedThoughtDefs;
|
|
public List<ReplacementThought> replacementThoughts;
|
|
}
|
|
|
|
public class ReplacementThought
|
|
{
|
|
public List<TraitRequirement> requiredTraits;
|
|
public string requiredQuirk;
|
|
public SexActThoughtDef replacementThoughtDef;
|
|
}
|
|
|
|
public ReactionToSexAct DetermineReactionOfPawns(Pawn pawn, Pawn witness, bool applyThoughtDefs)
|
|
{
|
|
DetermineReactionOfPawn(pawn, witness, pawnReaction, applyThoughtDefs);
|
|
ReactionToSexAct reactionToSexAct = DetermineReactionOfPawn(witness, pawn, witnessReaction, applyThoughtDefs);
|
|
|
|
return reactionToSexAct;
|
|
}
|
|
|
|
public ReactionToSexAct DetermineReactionOfPawn(Pawn reactor, Pawn otherPawn, SubSexActReactionDef reaction, bool applyThoughtDef)
|
|
{
|
|
SexActThoughtDef thoughtDef = GetThoughtDefForReactor(reactor, reaction, out Precept precept);
|
|
ReactionToSexAct reactionToSexAct = thoughtDef.reactionToSexAct;
|
|
|
|
if (applyThoughtDef)
|
|
{ reactor.needs.mood.thoughts.memories.TryGainMemory(thoughtDef, otherPawn, precept); }
|
|
|
|
var nullifyingTraits = ThoughtUtility.GetNullifyingTraits(thoughtDef)?.ToList();
|
|
|
|
if (thoughtDef.stages[0].baseMoodEffect < 0 && nullifyingTraits?.Any(x => x.HasTrait(reactor)) != true)
|
|
{ reactor.TryGetComp<CompPawnThoughtData>()?.TryToExclaim(); }
|
|
|
|
return reactionToSexAct;
|
|
}
|
|
|
|
private SexActThoughtDef GetThoughtDefForReactor(Pawn reactor, SubSexActReactionDef reaction, out Precept precept)
|
|
{
|
|
precept = null;
|
|
|
|
if (reactor == null || reaction == null) return null;
|
|
|
|
if (reaction.replacementThoughts.NullOrEmpty() == false)
|
|
{
|
|
foreach (ReplacementThought replacementThought in reaction.replacementThoughts)
|
|
{
|
|
if (replacementThought?.requiredTraits.Any(x => x.HasTrait(reactor)) == true)
|
|
{ return replacementThought.replacementThoughtDef; }
|
|
|
|
if (replacementThought.requiredQuirk != null && xxx.has_quirk(reactor, replacementThought.requiredQuirk))
|
|
{ return replacementThought.replacementThoughtDef; }
|
|
}
|
|
}
|
|
|
|
precept = reactor.GetPreceptForIssue(issueDef);
|
|
|
|
if (precept != null && reaction.associatedThoughtDefs.NullOrEmpty() == false)
|
|
{
|
|
string thoughtDefName = precept.def.defName;
|
|
|
|
foreach (SexActThoughtDef associatedThoughtDef in reaction.associatedThoughtDefs)
|
|
{
|
|
if (associatedThoughtDef.defName.Contains(thoughtDefName))
|
|
{ return associatedThoughtDef; }
|
|
}
|
|
}
|
|
|
|
return reaction.defaultThoughtDef;
|
|
}
|
|
}
|
|
}
|