mirror of
https://gitgud.io/AbstractConcept/privacy-please.git
synced 2024-08-15 00:03:18 +00:00
v 0.01
This commit is contained in:
parent
55402b9891
commit
03e634e56c
36 changed files with 866 additions and 491 deletions
105
Source/Scripts/Defs/SexActReactionDef.cs
Normal file
105
Source/Scripts/Defs/SexActReactionDef.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
14
Source/Scripts/Defs/SexActThoughtDef.cs
Normal file
14
Source/Scripts/Defs/SexActThoughtDef.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RimWorld;
|
||||
|
||||
namespace Privacy_Please
|
||||
{
|
||||
public class SexActThoughtDef : ThoughtDef
|
||||
{
|
||||
public ReactionToSexAct reactionToSexAct = ReactionToSexAct.Acceptance;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue