mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Interrim Documentation Update
This commit is contained in:
parent
147892ea18
commit
f51a85f191
10 changed files with 141 additions and 119 deletions
|
@ -1,60 +0,0 @@
|
|||
using Verse;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using System.Collections.Generic;
|
||||
using rjw.Modules.Quirks;
|
||||
using System;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class QuirkPatcher
|
||||
{
|
||||
public static void CountSatisfiedPostfix(ref int __result, SexProps props)
|
||||
{
|
||||
Pawn pawn = props.pawn;
|
||||
Pawn partner = props.partner;
|
||||
if(pawn!=null && partner != null)
|
||||
{
|
||||
if(!pawn.IsHuman()||!partner.IsHuman())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
int count = -1;
|
||||
List<string> listquirk = new List<string>();
|
||||
string s;
|
||||
foreach (Gene g in partner.genes.GenesListForReading)
|
||||
{
|
||||
if (partner.genes.HasActiveGene(g.def))
|
||||
{
|
||||
s = null;
|
||||
s = g.def?.GetModExtension<QirkExtension>()?.Satisfiedquirk;
|
||||
if (!string.IsNullOrEmpty(s))
|
||||
{
|
||||
listquirk.Add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Quirk q in Quirk.All)
|
||||
{
|
||||
if (pawn.Has(q))
|
||||
{
|
||||
|
||||
foreach (string s2 in listquirk)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(s2))
|
||||
if (q.LocaliztionKey==s2)
|
||||
{
|
||||
count++;
|
||||
Quirk.AddThought(pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count>0)__result = __result + count;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ namespace RJW_Genes
|
|||
{
|
||||
public class QirkExtension : DefModExtension
|
||||
{
|
||||
public String Satisfiedquirk;
|
||||
|
||||
public string Satisfiedquirk;
|
||||
}
|
||||
}
|
64
Source/Genes/Quirks/QuirkPatcher.cs
Normal file
64
Source/Genes/Quirks/QuirkPatcher.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using Verse;
|
||||
using RimWorld;
|
||||
using rjw;
|
||||
using System.Collections.Generic;
|
||||
using rjw.Modules.Quirks;
|
||||
using System;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
public class QuirkPatcher
|
||||
{
|
||||
/// <summary>
|
||||
/// This Patch is applied after the quirk-satisfaction and checks
|
||||
/// a) which quirks can the sex-partner satisfy?
|
||||
/// b) which of the quirks has the pawn?
|
||||
///
|
||||
/// The result of the Satisfied is an integer, based on the original framework.
|
||||
/// The framework "just checks" the number of satisfied quirks - we increase this number with this postfix.
|
||||
/// </summary>
|
||||
public static void CountSatisfiedPostfix(ref int __result, SexProps props)
|
||||
{
|
||||
if (props == null) return;
|
||||
Pawn pawn = props.pawn;
|
||||
Pawn partner = props.partner;
|
||||
if (partner == null || pawn == null) return;
|
||||
if(!pawn.IsHuman()||!partner.IsHuman()) return;
|
||||
|
||||
List<string> potentiallySatisfiedQuirks = new List<string>();
|
||||
foreach (Gene gene in partner.genes.GenesListForReading)
|
||||
{
|
||||
if (partner.genes.HasActiveGene(gene.def))
|
||||
{
|
||||
string satisfiable_quirk = gene.def?.GetModExtension<QirkExtension>()?.Satisfiedquirk;
|
||||
if (!string.IsNullOrEmpty(satisfiable_quirk))
|
||||
{
|
||||
potentiallySatisfiedQuirks.Add(satisfiable_quirk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int QuirksSatisfiedByGenes = -1;
|
||||
|
||||
foreach (Quirk quirk in Quirk.All)
|
||||
{
|
||||
if (pawn.Has(quirk))
|
||||
{
|
||||
foreach (string satisfiableQuirk in potentiallySatisfiedQuirks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(satisfiableQuirk) && quirk.LocaliztionKey == satisfiableQuirk)
|
||||
{
|
||||
QuirksSatisfiedByGenes++;
|
||||
Quirk.AddThought(pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(QuirksSatisfiedByGenes > 0)
|
||||
__result = __result + QuirksSatisfiedByGenes;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -171,7 +171,6 @@ namespace RJW_Genes
|
|||
private static Pawn_GeneTracker CopyGeneTracker(Pawn toCopyTo, Pawn_GeneTracker toCopyFrom)
|
||||
{
|
||||
var tracker = new Pawn_GeneTracker(toCopyTo);
|
||||
|
||||
// Due to Overwrite logics, we first add Endogenes and then a second pass on xenogenes
|
||||
|
||||
// Pass 1: Endogenes
|
||||
|
@ -190,12 +189,6 @@ namespace RJW_Genes
|
|||
}
|
||||
|
||||
tracker.Reset();
|
||||
var skin = tracker.GetMelaninGene();
|
||||
var hair = tracker.GetHairColorGene();
|
||||
|
||||
//ModLog.Message($"{toCopyTo} had Skin {skin.defName} and {hair.defName} as colour-genes");
|
||||
|
||||
|
||||
return tracker;
|
||||
}
|
||||
|
||||
|
@ -302,9 +295,6 @@ namespace RJW_Genes
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -328,5 +318,4 @@ Verse.TickList:Tick ()
|
|||
Verse.TickManager:TickManagerUpdate ()
|
||||
Verse.Game:UpdatePlay ()
|
||||
Verse.Root_Play:Update ()
|
||||
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue