diff --git a/1.5/Core/Defs/HediffDefs/Hediffs_Maintenance.xml b/1.5/Core/Defs/HediffDefs/Hediffs_Maintenance.xml
index 41c763b..db3ef76 100644
--- a/1.5/Core/Defs/HediffDefs/Hediffs_Maintenance.xml
+++ b/1.5/Core/Defs/HediffDefs/Hediffs_Maintenance.xml
@@ -128,7 +128,7 @@
Maintenance (required)
I can't move my body well.
-5
-
+
false
@@ -136,7 +136,7 @@
Maintenance (flawless)
I feel like I'm made new!
5
-
+
\ No newline at end of file
diff --git a/1.6/Biotech/Defs/Bio_Hediffs_Mechanitor.xml b/1.6/Biotech/Defs/Bio_Hediffs_Mechanitor.xml
new file mode 100644
index 0000000..f541bc9
--- /dev/null
+++ b/1.6/Biotech/Defs/Bio_Hediffs_Mechanitor.xml
@@ -0,0 +1,530 @@
+
+
+
+
+ PN_Mechlink
+ automaton mechlink
+ This is a modified mechlink for automaton.
+ Mechlink
+
+ MechlinkImplant
+
+
+ 100
+ -4
+ 1
+ 500
+ 0
+
+
+ Things/Pawn/Humanlike/Apparel/Mechlink
+ Graphic_Single
+ 0.65
+
+
+
+
+ CompUsableImplant
+ InstallMechlink
+ Install {0_label} to become mechanitor
+
+
+ CompUseEffect_InstallImplantMechlink
+ MechlinkImplant
+ PNBrain
+ true
+
+
+ MechlinkInstalled
+
+
+
+
+
+ PN_Make_Mechlink_Automaton
+ make automaton mechlink
+ make automaton mechlink
+ Making automaton mechlink.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ Mechlink
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+
+
+ 100
+ -4
+ 1
+ 1200
+ 0
+ 3200
+
+
+ Things/Item/Health/HealthItem
+ Graphic_Single
+ 0.80
+ (247,180,130)
+
+
+
+
+ None
+
+
+
+
+ ControlSublinkImplant
+
+
+ 3
+
+
+
+
+ PN_ControlSublink
+ automaton control sublink (standard)
+ This is a modified control sublink (standard) for automaton.
+
+ 1
+ 4
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant sublink
+ MechlinkImplant
+
+
+ ControlSublinkImplant
+ PNBrain
+ true
+ 3
+
+
+
+
+
+ PN_ControlSublinkHigh
+ automaton control sublink (high)
+ This is a modified control sublink (high) for automaton.
+
+ 1
+ 3
+ 3
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant high sublink
+ MechlinkImplant
+
+
+ ControlSublinkImplant
+ PNBrain
+ true
+ true
+ 3
+
+
+
+
+
+ PN_Make_ControlSublink_Automaton
+ make automaton sublink (standard)
+ make automaton sublink
+ Making automaton sublink.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ ControlSublink
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+ PN_Make_PN_ControlSublinkHigh_Automaton
+ make automaton sublink (high)
+ make automaton sublink
+ Making automaton sublink.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ ControlSublinkHigh
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+
+ PN_RemoteRepairer
+ automaton remote repairer
+ This is a modified remote repairer for automaton.
+
+ RemoteRepairerImplant
+
+
+ 1
+ 6
+
+
+ 3
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant {0_label}
+ MechlinkImplant
+
+
+ RemoteRepairerImplant
+ PNBrain
+ true
+
+
+
+
+
+ PN_Make_PN_RemoteRepairer_Automaton
+ make automaton remote repairer
+ make automaton remote repairer
+ Making automaton remote repairer.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ RemoteRepairer
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+
+ PN_MechFormfeeder
+ automaton mech gestation processor
+ This is a modified mech gestation processor for automaton.
+
+ MechFormfeederImplant
+
+
+ 1
+ 6
+
+
+ 6
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant {0_label}
+ MechlinkImplant
+
+
+ MechFormfeederImplant
+ PNBrain
+ true
+
+
+
+
+
+ PN_Make_PN_MechFormfeeder_Automaton
+ make automaton mech gestation processor
+ make automaton mech gestation processor
+ Making automaton mech gestation processor.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ MechFormfeeder
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+
+ PN_RemoteShielder
+ automaton remote shielder
+ This is a modified remote shielder for automaton.
+
+ RemoteShielderImplant
+
+
+ 1
+ 6
+
+
+ 3
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant {0_label}
+ MechlinkImplant
+
+
+ RemoteShielderImplant
+ PNBrain
+ true
+
+
+
+
+
+ PN_Make_PN_RemoteShielder_Automaton
+ make automaton remote shielder
+ make automaton remote shielder
+ Making automaton remote shielder.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ RemoteShielder
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
+
+
+ PN_RepairProbe
+ automaton repair probe
+ This is a modified repair probe for automaton.
+
+ RepairProbeImplant
+
+
+ 1
+ 2
+
+
+ 6
+
+
+
+ CompUsableImplant
+ UseItem
+ Implant {0_label}
+ MechlinkImplant
+
+
+ RepairProbeImplant
+ PNBrain
+ true
+
+
+
+
+
+ PN_Make_PN_RepairProbe_Automaton
+ make automaton repair probe
+ make automaton repair probe
+ Making automaton repair probe.
+ GeneralLaborSpeed
+ Cook
+ Recipe_Machining
+ 2000
+ true
+
+ PN_AutomatonBench
+
+
+
+
+
+ RepairProbe
+
+
+ 1
+
+
+
+
+ ComponentIndustrial
+
+
+ 2
+
+
+
+ 1
+
+
+ 6
+
+ Crafting
+ PNRP_Mechlink
+
+
\ No newline at end of file
diff --git a/1.6/Biotech/Defs/Bio_Reserch_ProjectDefs.xml b/1.6/Biotech/Defs/Bio_Reserch_ProjectDefs.xml
new file mode 100644
index 0000000..e19757b
--- /dev/null
+++ b/1.6/Biotech/Defs/Bio_Reserch_ProjectDefs.xml
@@ -0,0 +1,17 @@
+
+
+
+ PNRP_Mechlink
+ automaton mechlink
+ Research how to modify mechlink and sublink for use by the Automaton.
+ PN_technology
+ 300
+ Industrial
+
+ PNRP_Production
+
+ 1.0
+ 4.9
+
+
+
\ No newline at end of file
diff --git a/1.6/Biotech/Defs/Bio_ThingDef_Module.xml b/1.6/Biotech/Defs/Bio_ThingDef_Module.xml
new file mode 100644
index 0000000..111b19b
--- /dev/null
+++ b/1.6/Biotech/Defs/Bio_ThingDef_Module.xml
@@ -0,0 +1,102 @@
+
+
+
+
+
+ PN_ArrayModule
+ array module
+ [CAUTION]\nThis module can only be installed on compatible models.\nAlso, the module system must be stable.\n\n[compatible models list]\n\nAny model (legd), (mast), (exc)\n\nThis module increases the automaton's MechBandwidth and MechControlGroups stat.
+
+ PN_ArrayModuleHediff
+
+
+ 45
+ 20
+ 2
+ 1
+
+
+ PNRP_TierB_Module
+
+ 6
+
+
+
+
+
+
+
+ PN_ArrayModuleHediff
+ PNTorso
+
+
+
+
+
+ PN_ArrayModuleHediff
+ array module
+ The hediff created by installing array module.
+
+ PN_ArrayModule
+
+
+
+
+ 6
+ 1
+
+
+
+
+
+
+
+ PN_IntegratorModule
+ integrator module
+ [CAUTION]\nThis module can only be installed on compatible models.\nAlso, the module system must be stable.\n\n[compatible models list]\n\nAny model (legd)\n\nThis module increases the automaton's MechBandwidth and MechControlGroups stat.
+
+ PN_IntegratorModuleHediff
+
+
+ 45
+ 12
+ 9
+ 3
+ 2
+ 1
+
+
+ PNRP_TierC_Module
+
+ 6
+
+
+
+
+
+
+
+ PN_IntegratorModuleHediff
+ PNTorso
+
+
+
+
+
+ PN_IntegratorModuleHediff
+ integrator module
+ The hediff created by installing integrator module.
+
+ PN_IntegratorModule
+
+
+
+
+ 18
+ 1
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.6/Biotech/Defs/Bio_ThingDef_Part_Body.xml b/1.6/Biotech/Defs/Bio_ThingDef_Part_Body.xml
new file mode 100644
index 0000000..daaf347
--- /dev/null
+++ b/1.6/Biotech/Defs/Bio_ThingDef_Part_Body.xml
@@ -0,0 +1,70 @@
+
+
+
+
+ PN_DetoxifierOilFilter
+ detoxifier Oil Filter
+ a detoxifier oil filter
+ An advanced Oil Filter. Using PNL Industry technology, it can rapidly remove a vast range of toxins from the fuel, making it effective against environmental toxins, venoms, and injected poisons.
+
+ DetoxifierKidney
+
+ DetoxifierKidney
+
+ true
+ 1.1
+ true
+
+
+
+
+ 0.5
+
+
+
+
+
+
+ PN_InstallDetoxifierOilFilter
+ install detoxifier Oil Filter
+ Install a detoxifier oil filter.
+
+ DetoxifierKidney
+ PN_DetoxifierOilFilter
+
+ Installing detoxifier oil filter.
+
+
+
+
+ DetoxifierKidney
+
+
+ 1
+
+
+
+
+ DetoxifierKidney
+
+
+
+ PNKidney
+
+ PN_DetoxifierOilFilter
+ 0
+
+
+
+ PN_RemoveDetoxifierOilFilter
+ remove detoxifier Oil Filter
+ Remove detoxifier Oil Filter.
+
+ DetoxifierKidney
+ PN_DetoxifierOilFilter
+
+ Removing detoxifier Oil Filter.
+ PN_DetoxifierOilFilter
+
+
+
\ No newline at end of file
diff --git a/1.6/Core/Assemblies/1_CustomizableRecipe.dll b/1.6/Core/Assemblies/1_CustomizableRecipe.dll
new file mode 100644
index 0000000..4080252
Binary files /dev/null and b/1.6/Core/Assemblies/1_CustomizableRecipe.dll differ
diff --git a/1.6/Core/Assemblies/2_AutomataRace.dll b/1.6/Core/Assemblies/2_AutomataRace.dll
new file mode 100644
index 0000000..66f56de
Binary files /dev/null and b/1.6/Core/Assemblies/2_AutomataRace.dll differ
diff --git a/1.6/Core/Assemblies/2_AutomataRace.pdb b/1.6/Core/Assemblies/2_AutomataRace.pdb
new file mode 100644
index 0000000..8f25ff9
Binary files /dev/null and b/1.6/Core/Assemblies/2_AutomataRace.pdb differ
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs.sln b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs.sln
new file mode 100644
index 0000000..b08108b
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoharHediffs", "MoharHediffs\MoharHediffs.csproj", "{7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ActivityRestriction.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ActivityRestriction.cs
new file mode 100644
index 0000000..491e09a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ActivityRestriction.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class ActivityRestriction
+ {
+ public bool HasPostureRestriction
+ {
+ get
+ {
+ return !this.allowedPostures.NullOrEmpty();
+ }
+ }
+
+ public bool HasJobRestriction
+ {
+ get
+ {
+ return !this.allowedJobs.NullOrEmpty();
+ }
+ }
+
+ public bool HasAllowedRotation
+ {
+ get
+ {
+ return !this.allowedRotation.NullOrEmpty();
+ }
+ }
+
+ public bool onlyWhenMoving = true;
+
+ public List allowedPostures;
+
+ public List allowedJobs;
+
+ public List allowedRotation;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartCondition.cs
new file mode 100644
index 0000000..bc2ad45
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartCondition.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class BodyPartCondition
+ {
+ public bool HasLabel
+ {
+ get
+ {
+ return !this.bodyPartLabel.NullOrEmpty();
+ }
+ }
+
+ public bool HasDef
+ {
+ get
+ {
+ return !this.bodyPartDef.NullOrEmpty();
+ }
+ }
+
+ public bool HasTag
+ {
+ get
+ {
+ return !this.bodyPartTag.NullOrEmpty();
+ }
+ }
+
+ public bool HasBPCondition
+ {
+ get
+ {
+ return this.HasLabel || this.HasDef || this.HasTag;
+ }
+ }
+
+ public List bodyPartLabel;
+
+ public List bodyPartDef;
+
+ public List bodyPartTag;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartsTools.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartsTools.cs
new file mode 100644
index 0000000..2e43755
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyPartsTools.cs
@@ -0,0 +1,307 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class BodyPartsTools
+ {
+ public static BodyPartRecord GetBPRWithoutHediff(this Pawn pawn, BodyPartDef bpd, HediffDef hediffDef)
+ {
+ IEnumerable source;
+ bool flag = (source = from b in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)
+ where b.def == bpd
+ select b) == null;
+ BodyPartRecord result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ List bprToExclude = new List();
+ IEnumerable hediffs = pawn.health.hediffSet.hediffs;
+ Func <>9__1;
+ Func predicate;
+ if ((predicate = <>9__1) == null)
+ {
+ predicate = (<>9__1 = ((Hediff h) => h.def == hediffDef));
+ }
+ foreach (Hediff hediff in hediffs.Where(predicate))
+ {
+ bool flag2 = !bprToExclude.Contains(hediff.Part);
+ if (flag2)
+ {
+ bprToExclude.Add(hediff.Part);
+ }
+ }
+ bool flag3 = bprToExclude.NullOrEmpty();
+ if (flag3)
+ {
+ result = source.RandomElementWithFallback(null);
+ }
+ else
+ {
+ IEnumerable source2;
+ bool flag4 = (source2 = from b in source
+ where !bprToExclude.Contains(b)
+ select b) == null;
+ if (flag4)
+ {
+ result = null;
+ }
+ else
+ {
+ result = source2.RandomElementWithFallback(null);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static bool CheckIfExistingNaturalBP(this Pawn pawn, BodyPartDef bodyPartDef, bool myDebug = false)
+ {
+ BodyPartRecord bodyPartRecord = pawn.GetBPRecord(bodyPartDef, false) ?? null;
+ bool flag = bodyPartRecord == null || pawn.health.hediffSet.PartIsMissing(bodyPartRecord) || pawn.health.hediffSet.AncestorHasDirectlyAddedParts(bodyPartRecord);
+ return !flag;
+ }
+
+ public static BodyPartRecord GetBPRecord(this Pawn pawn, BodyPartDef bodyPartDef, bool myDebug = false)
+ {
+ IEnumerable enumerable = from b in DefDatabase.AllDefs
+ where b == bodyPartDef
+ select b;
+ bool flag = enumerable.EnumerableNullOrEmpty();
+ BodyPartRecord result;
+ if (flag)
+ {
+ if (myDebug)
+ {
+ string label = pawn.Label;
+ string str = " - GetBPRecord - did not find any ";
+ BodyPartDef bodyPartDef2 = bodyPartDef;
+ Log.Warning(label + str + ((bodyPartDef2 != null) ? bodyPartDef2.defName : null));
+ }
+ result = null;
+ }
+ else
+ {
+ BodyPartDef def = enumerable.RandomElement();
+ BodyPartRecord bodyPartRecord;
+ pawn.RaceProps.body.GetPartsWithDef(def).TryRandomElement(out bodyPartRecord);
+ if (myDebug)
+ {
+ string label2 = pawn.Label;
+ string str2 = "GetBPRecord - DID find ";
+ BodyPartDef bodyPartDef3 = bodyPartDef;
+ Log.Warning(label2 + str2 + ((bodyPartDef3 != null) ? bodyPartDef3.defName : null));
+ }
+ result = bodyPartRecord;
+ }
+ return result;
+ }
+
+ public static bool IsMissingBPR(this Pawn pawn, BodyPartRecord BPR, out Hediff missingHediff)
+ {
+ bool flag = BPR == null;
+ bool result;
+ if (flag)
+ {
+ missingHediff = null;
+ result = false;
+ }
+ else
+ {
+ missingHediff = (from h in pawn.health.hediffSet.hediffs
+ where h.def == HediffDefOf.MissingBodyPart && h.Part == BPR
+ select h).FirstOrFallback(null);
+ result = (missingHediff != null);
+ }
+ return result;
+ }
+
+ public static bool HasMissingChildren(this Pawn pawn, BodyPartRecord bpr)
+ {
+ List missingPartsCommonAncestors = pawn.health.hediffSet.GetMissingPartsCommonAncestors();
+ return missingPartsCommonAncestors.Any((Hediff_MissingPart HMP) => HMP.Part == bpr);
+ }
+
+ public static bool IsMissingOrHasMissingChildren(this Pawn pawn, BodyPartRecord bpr)
+ {
+ return pawn.health.hediffSet.PartIsMissing(bpr) || pawn.HasMissingChildren(bpr);
+ }
+
+ public static IEnumerable GetAllBPR(this Pawn pawn, string bodyPartLabel, BodyPartDef bodyPartDef)
+ {
+ bool HasLabel = !bodyPartLabel.NullOrEmpty();
+ bool HasDef = bodyPartDef != null;
+ return from bpr in pawn.RaceProps.body.AllParts
+ where (!HasLabel || bpr.customLabel == bodyPartLabel) && (!HasDef || bpr.def == bodyPartDef)
+ select bpr;
+ }
+
+ public static IEnumerable GetAllNotMissingBPR(this Pawn pawn, string bodyPartLabel, BodyPartDef bodyPartDef)
+ {
+ bool HasLabel = !bodyPartLabel.NullOrEmpty();
+ bool HasDef = bodyPartDef != null;
+ return from bpr in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)
+ where (!HasLabel || bpr.customLabel == bodyPartLabel) && (!HasDef || bpr.def == bodyPartDef)
+ select bpr;
+ }
+
+ public static BodyPartRecord GetBPRecordWithoutHediff(this Pawn pawn, string bodyPartLabel, BodyPartDef bodyPartDef, HediffDef hd, bool AllowMissing = false, bool PrioritizeMissing = false, bool AllowAddedPart = true, bool myDebug = false)
+ {
+ bool flag = hd != null;
+ bool flag2 = !bodyPartLabel.NullOrEmpty();
+ bool flag3 = bodyPartDef != null;
+ string text = pawn.Label + " GetBPRecordWithoutHediff - ";
+ if (myDebug)
+ {
+ string[] array = new string[5];
+ array[0] = text;
+ array[1] = string.Format("HasDef?{0} bodyPartDef:{1} ", flag3, (bodyPartDef != null) ? bodyPartDef.defName : null);
+ array[2] = string.Format("HasLabel?{0} bodyPartLabel:{1} ", flag2, bodyPartLabel);
+ int num = 3;
+ string format = "HasHediffDef?{0} Hediff:{1} ";
+ object arg = flag;
+ HediffDef hd2 = hd;
+ array[num] = string.Format(format, arg, (hd2 != null) ? hd2.defName : null);
+ array[4] = string.Format("AllowMissing:{0} PrioritizeMissing:{1} AllowAddedPart:{2}", AllowMissing, PrioritizeMissing, AllowAddedPart);
+ Log.Warning(string.Concat(array));
+ }
+ List bprToExclude = new List();
+ bool flag4 = flag;
+ if (flag4)
+ {
+ IEnumerable hediffs = pawn.health.hediffSet.hediffs;
+ Func <>9__3;
+ Func predicate;
+ if ((predicate = <>9__3) == null)
+ {
+ predicate = (<>9__3 = ((Hediff h) => h.def == hd));
+ }
+ foreach (Hediff hediff in hediffs.Where(predicate))
+ {
+ bool flag5 = !bprToExclude.Contains(hediff.Part);
+ if (flag5)
+ {
+ bprToExclude.Add(hediff.Part);
+ }
+ }
+ if (myDebug)
+ {
+ object[] array2 = new object[5];
+ array2[0] = text;
+ array2[1] = "found ";
+ int num2 = 2;
+ List bprToExclude2 = bprToExclude;
+ array2[num2] = ((bprToExclude2 != null) ? new int?(bprToExclude2.Count) : null);
+ array2[3] = " bpr to exclude bc they had ";
+ array2[4] = hd.defName;
+ Log.Warning(string.Concat(array2));
+ }
+ }
+ BodyPartRecord bodyPartRecord = null;
+ IEnumerable enumerable;
+ if (AllowMissing)
+ {
+ enumerable = pawn.GetAllBPR(bodyPartLabel, bodyPartDef);
+ if (myDebug)
+ {
+ Log.Warning(text + "Allow missing - found " + (enumerable.EnumerableNullOrEmpty() ? "0" : enumerable.Count().ToString()) + " bpr");
+ }
+ bool flag6 = PrioritizeMissing && !enumerable.EnumerableNullOrEmpty() && enumerable.Any((BodyPartRecord bpr) => pawn.IsMissingOrHasMissingChildren(bpr));
+ if (flag6)
+ {
+ enumerable = from bpr in enumerable
+ where pawn.IsMissingOrHasMissingChildren(bpr)
+ select bpr;
+ if (myDebug)
+ {
+ Log.Warning(text + "Prioritize Missing - found " + (enumerable.EnumerableNullOrEmpty() ? "0" : enumerable.Count().ToString()) + " bpr");
+ }
+ }
+ }
+ else
+ {
+ enumerable = pawn.GetAllNotMissingBPR(bodyPartLabel, bodyPartDef);
+ if (myDebug)
+ {
+ Log.Warning(text + "Not missing - found " + (enumerable.EnumerableNullOrEmpty() ? "0" : enumerable.Count().ToString()) + " bpr");
+ }
+ }
+ bool flag7 = enumerable.EnumerableNullOrEmpty();
+ BodyPartRecord result;
+ if (flag7)
+ {
+ result = null;
+ }
+ else
+ {
+ bool flag8 = !AllowAddedPart;
+ if (flag8)
+ {
+ Tools.Warn(text + "Trying to exlude addedpart", myDebug);
+ bool flag9 = enumerable.Any((BodyPartRecord bpr) => pawn.health.hediffSet.HasDirectlyAddedPartFor(bpr));
+ if (flag9)
+ {
+ enumerable = from bpr in enumerable
+ where !pawn.health.hediffSet.HasDirectlyAddedPartFor(bpr)
+ select bpr;
+ if (myDebug)
+ {
+ Log.Warning(text + "Added parts(bionics) forbidden- found " + (enumerable.EnumerableNullOrEmpty() ? "0" : enumerable.Count().ToString()) + " bpr");
+ }
+ }
+ else if (myDebug)
+ {
+ Log.Warning(text + "found no addedpart to exclude");
+ }
+ }
+ bool flag10 = bprToExclude.NullOrEmpty();
+ if (flag10)
+ {
+ enumerable.TryRandomElement(out bodyPartRecord);
+ }
+ else
+ {
+ bool flag11 = enumerable.Any((BodyPartRecord bp) => !bprToExclude.Contains(bp));
+ if (flag11)
+ {
+ (from bp in enumerable
+ where !bprToExclude.Contains(bp)
+ select bp).TryRandomElement(out bodyPartRecord);
+ }
+ else
+ {
+ bodyPartRecord = null;
+ }
+ }
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ pawn.Label,
+ "GetBPRecord - did ",
+ (bodyPartRecord == null) ? "not" : "",
+ " find with def ",
+ (bodyPartDef != null) ? bodyPartDef.defName : null,
+ " without hediff def ",
+ hd.defName
+ }));
+ }
+ result = bodyPartRecord;
+ }
+ return result;
+ }
+
+ public static BodyPartRecord GetBrain(this Pawn pawn)
+ {
+ BodyPartRecord result;
+ pawn.RaceProps.body.GetPartsWithTag(BodyPartTagDefOf.ConsciousnessSource).TryRandomElement(out result);
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeOffset.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeOffset.cs
new file mode 100644
index 0000000..7e5d88e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeOffset.cs
@@ -0,0 +1,13 @@
+using System;
+using RimWorld;
+using UnityEngine;
+
+namespace MoharHediffs
+{
+ public class BodyTypeOffset
+ {
+ public BodyTypeDef bodyType;
+
+ public Vector3 offset;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeSpecificities.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeSpecificities.cs
new file mode 100644
index 0000000..423944e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/BodyTypeSpecificities.cs
@@ -0,0 +1,12 @@
+using System;
+using RimWorld;
+
+namespace MoharHediffs
+{
+ public class BodyTypeSpecificities
+ {
+ public BodyTypeDef bodyTypeDef;
+
+ public DrawingSpecificities drawRules;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ChannelColorCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ChannelColorCondition.cs
new file mode 100644
index 0000000..bd0a06d
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ChannelColorCondition.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace MoharHediffs
+{
+ public class ChannelColorCondition
+ {
+ public string channelName;
+
+ public int channelNum = 0;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ColorRange.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ColorRange.cs
new file mode 100644
index 0000000..eea67be
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ColorRange.cs
@@ -0,0 +1,14 @@
+using System;
+using UnityEngine;
+
+namespace MoharHediffs
+{
+ public class ColorRange
+ {
+ public Color colorA;
+
+ public Color colorB;
+
+ public float variationPerIteration;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CommonSettings.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CommonSettings.cs
new file mode 100644
index 0000000..bbf6b84
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CommonSettings.cs
@@ -0,0 +1,11 @@
+using System;
+
+namespace MoharHediffs
+{
+ public class CommonSettings
+ {
+ public StackSettings stack;
+
+ public FilthSettings filth;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionBuilder.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionBuilder.cs
new file mode 100644
index 0000000..4f478cf
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionBuilder.cs
@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class ConditionBuilder
+ {
+ public static void CopyHediffCondition(HediffCondition source, HediffCondition dest, bool debug = false)
+ {
+ string str = debug ? "CopyHediffCondition - " : "";
+ bool hasBodypartCondition = source.HasBodypartCondition;
+ if (hasBodypartCondition)
+ {
+ Tools.Warn(str + "found HasBodypartCondition, copying", debug);
+ bool hasDef = source.bodyPart.HasDef;
+ if (hasDef)
+ {
+ dest.bodyPart.bodyPartDef = source.bodyPart.bodyPartDef.ListFullCopy();
+ }
+ bool hasLabel = source.bodyPart.HasLabel;
+ if (hasLabel)
+ {
+ dest.bodyPart.bodyPartLabel = source.bodyPart.bodyPartLabel.ListFullCopy();
+ }
+ bool hasTag = source.bodyPart.HasTag;
+ if (hasTag)
+ {
+ dest.bodyPart.bodyPartTag = source.bodyPart.bodyPartTag.ListFullCopy();
+ }
+ }
+ bool hasPawnCondition = source.HasPawnCondition;
+ if (hasPawnCondition)
+ {
+ Tools.Warn(str + "found HasPawnCondition, copying", debug);
+ bool hasRace = source.pawn.HasRace;
+ if (hasRace)
+ {
+ dest.pawn.race = source.pawn.race.ListFullCopy();
+ }
+ bool hasGender = source.pawn.HasGender;
+ if (hasGender)
+ {
+ dest.pawn.gender = source.pawn.gender.ListFullCopy();
+ }
+ dest.pawn.ageRange = source.pawn.ageRange;
+ }
+ }
+
+ public static HediffCondition GetDefaultPlusSpecificHediffCondition(HediffCondition defaultHC, HediffCondition specificHC, bool debug = false)
+ {
+ string str = debug ? "GetDefaultPlusSpecificHediffCondition - " : "";
+ Tools.Warn(str + "allocating answerHC", debug);
+ HediffCondition hediffCondition = new HediffCondition
+ {
+ bodyPart = new BodyPartCondition
+ {
+ bodyPartDef = new List(),
+ bodyPartLabel = new List(),
+ bodyPartTag = new List()
+ },
+ pawn = new PawnCondition
+ {
+ race = new List(),
+ gender = new List()
+ }
+ };
+ bool flag = defaultHC != null;
+ if (flag)
+ {
+ Tools.Warn(str + "found defaultHC, copying", debug);
+ ConditionBuilder.CopyHediffCondition(defaultHC, hediffCondition, debug);
+ }
+ bool flag2 = specificHC != null;
+ if (flag2)
+ {
+ Tools.Warn(str + "found specificHC, copying", debug);
+ ConditionBuilder.CopyHediffCondition(specificHC, hediffCondition, debug);
+ }
+ return hediffCondition;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionValidation.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionValidation.cs
new file mode 100644
index 0000000..da42e86
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ConditionValidation.cs
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class ConditionValidation
+ {
+ public static bool ValidateCompatibilityOfHediffWithPawn(this PawnCondition pCon, Pawn pawn, bool debug = false)
+ {
+ string text = debug ? (pawn.LabelShort + " ValidateCompatibilityOfHediffWithPawn - ") : "";
+ bool hasRace = pCon.HasRace;
+ if (hasRace)
+ {
+ bool flag = !pCon.race.Contains(pawn.def);
+ if (flag)
+ {
+ Tools.Warn(text + " does not belong to the good race", debug);
+ return false;
+ }
+ }
+ bool hasGender = pCon.HasGender;
+ if (hasGender)
+ {
+ bool flag2 = !pCon.gender.Contains(pawn.gender);
+ if (flag2)
+ {
+ Tools.Warn(text + " does not belong to the good gender", debug);
+ return false;
+ }
+ }
+ bool flag3 = !pCon.ageRange.Includes((float)pawn.ageTracker.AgeBiologicalYears);
+ bool result;
+ if (flag3)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ " does not have the good age : ",
+ pawn.ageTracker.AgeBiologicalYears,
+ " => ",
+ pCon.ageRange
+ }), debug);
+ result = false;
+ }
+ else
+ {
+ Tools.Warn(text + " valid ok", debug);
+ result = true;
+ }
+ return result;
+ }
+
+ public static bool InitialHediffConditionCheck(this HediffComp_AnotherRandom comp, bool debug = false)
+ {
+ string str = debug ? (comp.Pawn.LabelShort + " InitialHediffConditionCheck - ") : "";
+ Tools.Warn(str + " Entering", debug);
+ bool result = !comp.GetCompatibleItems().NullOrEmpty();
+ Tools.Warn(str + "found anyAppliableItem:" + result.ToString(), debug);
+ return result;
+ }
+
+ public static bool GetBPRFromHediffCondition(this BodyPartCondition bpCon, Pawn pawn, out BodyPartRecord BPR, bool debug = false)
+ {
+ string text = debug ? (pawn.LabelShort + " GetBPRFromHediffCondition - ") : "";
+ BPR = null;
+ Tools.Warn(text + " Entering", debug);
+ bool flag = bpCon == null;
+ bool result;
+ if (flag)
+ {
+ Tools.Warn(text + " Found no condition, returning null aka body", debug);
+ result = true;
+ }
+ else
+ {
+ bool flag2 = !bpCon.HasBPCondition;
+ if (flag2)
+ {
+ Tools.Warn(text + " Found no BP condition, returning null aka body", debug);
+ result = true;
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ text,
+ " Found BP conditions, selecting : Label:",
+ bpCon.HasLabel.ToString(),
+ "; Def:",
+ bpCon.HasDef.ToString(),
+ "; Tag:",
+ bpCon.HasTag.ToString()
+ }), debug);
+ IEnumerable enumerable = from bpr in pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined, null, null)
+ where (!bpCon.HasLabel || bpCon.bodyPartLabel.Any((string s) => s == bpr.customLabel)) && (!bpCon.HasDef || bpCon.bodyPartDef.Any((BodyPartDef d) => d == bpr.def)) && (!bpCon.HasTag || (!bpr.def.tags.NullOrEmpty() && !bpCon.bodyPartTag.Intersect(bpr.def.tags).EnumerableNullOrEmpty()))
+ select bpr;
+ bool flag3 = !enumerable.EnumerableNullOrEmpty();
+ if (flag3)
+ {
+ BPR = enumerable.RandomElement();
+ result = true;
+ }
+ else
+ {
+ Tools.Warn(pawn.LabelShort + " does not have any compatible bodypart", debug);
+ result = false;
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CopyPawnSettings.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CopyPawnSettings.cs
new file mode 100644
index 0000000..bc4a81f
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/CopyPawnSettings.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class CopyPawnSettings
+ {
+ public bool HasHediffExclusion
+ {
+ get
+ {
+ return !this.excludeHediff.NullOrEmpty();
+ }
+ }
+
+ public bool name = false;
+
+ public bool pawnKind = false;
+
+ public bool age = false;
+
+ public bool gender = false;
+
+ public bool melanin = false;
+
+ public bool skinColorChannel = false;
+
+ public bool bodyType = false;
+
+ public bool crownType = false;
+
+ public bool hair = false;
+
+ public bool hairColor = false;
+
+ public bool hediff = false;
+
+ public List excludeHediff;
+
+ public bool excludeTendableHediffs = false;
+
+ public bool excludePermanentHediffs = false;
+
+ public bool childBS = false;
+
+ public bool adultBS = false;
+
+ public bool skills = false;
+
+ public FloatRange skillDecay = new FloatRange(1f, 1f);
+
+ public bool passions = false;
+
+ public bool traits = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/DrawingSpecificities.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/DrawingSpecificities.cs
new file mode 100644
index 0000000..1b02741
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/DrawingSpecificities.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class DrawingSpecificities
+ {
+ public Vector3 GetRotationOffset(Pawn p)
+ {
+ RotationOffset rotationOffset;
+ bool flag = (rotationOffset = (from ro in this.rotationOffset
+ where ro.rot == p.Rotation
+ select ro).FirstOrFallback(null)) != null;
+ Vector3 result;
+ if (flag)
+ {
+ result = rotationOffset.offset;
+ }
+ else
+ {
+ result = Vector3.zero;
+ }
+ return result;
+ }
+
+ public FloatRange randomScale = new FloatRange(0.5f, 0.8f);
+
+ public List rotationOffset;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerParameters.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerParameters.cs
new file mode 100644
index 0000000..4b07566
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerParameters.cs
@@ -0,0 +1,113 @@
+using System;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class FactionPickerParameters
+ {
+ public bool HasInheritedFaction
+ {
+ get
+ {
+ return this.inheritedFaction;
+ }
+ }
+
+ public bool HasForcedFaction
+ {
+ get
+ {
+ return this.forcedFaction != null;
+ }
+ }
+
+ public bool HasPlayerFaction
+ {
+ get
+ {
+ return this.playerFaction;
+ }
+ }
+
+ public bool HasNoFaction
+ {
+ get
+ {
+ return this.noFaction;
+ }
+ }
+
+ public bool HasDefaultPawnKindFaction
+ {
+ get
+ {
+ return this.defaultPawnKindFaction;
+ }
+ }
+
+ public bool IsLegitRandomFactionParameter()
+ {
+ int num = 0;
+ bool hasInheritedFaction = this.HasInheritedFaction;
+ checked
+ {
+ if (hasInheritedFaction)
+ {
+ num++;
+ }
+ bool hasForcedFaction = this.HasForcedFaction;
+ if (hasForcedFaction)
+ {
+ num++;
+ }
+ bool hasPlayerFaction = this.HasPlayerFaction;
+ if (hasPlayerFaction)
+ {
+ num++;
+ }
+ bool hasNoFaction = this.HasNoFaction;
+ if (hasNoFaction)
+ {
+ num++;
+ }
+ bool hasDefaultPawnKindFaction = this.HasDefaultPawnKindFaction;
+ if (hasDefaultPawnKindFaction)
+ {
+ num++;
+ }
+ return num == 1;
+ }
+ }
+
+ public void Dump()
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ "inherited:",
+ this.HasInheritedFaction.ToString(),
+ "; forced:",
+ this.HasForcedFaction.ToString(),
+ "; player:",
+ this.HasPlayerFaction.ToString(),
+ "; noFaction:",
+ this.HasNoFaction.ToString(),
+ "; defaultPawnKindFaction:",
+ this.HasDefaultPawnKindFaction.ToString(),
+ "; "
+ }));
+ }
+
+ public bool inheritedFaction = false;
+
+ public FactionDef forcedFaction = null;
+
+ public bool playerFaction = false;
+
+ public bool defaultPawnKindFaction = false;
+
+ public bool noFaction = false;
+
+ public float weight = 1f;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerUtils.cs
new file mode 100644
index 0000000..8693c91
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FactionPickerUtils.cs
@@ -0,0 +1,161 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class FactionPickerUtils
+ {
+ public static float FactionTotalWeight(this List FPP)
+ {
+ float num = 0f;
+ for (int i = 0; i < FPP.Count; i = checked(i + 1))
+ {
+ num += FPP[i].weight;
+ }
+ return num;
+ }
+
+ public static void ComputeRandomFaction(this HediffComp_RandySpawnUponDeath comp)
+ {
+ bool flag = !comp.ChosenItem.HasFactionParams;
+ if (!flag)
+ {
+ int weightedRandomFaction = comp.GetWeightedRandomFaction();
+ bool flag2 = weightedRandomFaction == -1;
+ if (flag2)
+ {
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("ComputeRandomFaction - found no index");
+ }
+ }
+ else
+ {
+ FactionPickerParameters factionPickerParameters = comp.ChosenItem.faction[weightedRandomFaction];
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ factionPickerParameters.Dump();
+ }
+ comp.RandomFaction = comp.GetFaction(factionPickerParameters);
+ bool myDebug3 = comp.MyDebug;
+ if (myDebug3)
+ {
+ string str = "ComputeRandomFaction - found:";
+ Faction randomFaction = comp.RandomFaction;
+ Log.Warning(str + ((randomFaction != null) ? randomFaction.GetCallLabel() : null));
+ }
+ }
+ }
+ }
+
+ public static int GetWeightedRandomFaction(this HediffComp_RandySpawnUponDeath comp)
+ {
+ bool flag = !comp.HasChosenPawn || !comp.ChosenItem.HasFactionParams;
+ checked
+ {
+ int result;
+ if (flag)
+ {
+ result = -1;
+ }
+ else
+ {
+ List faction = comp.ChosenItem.faction;
+ float num = Rand.Range(0f, faction.FactionTotalWeight());
+ for (int i = 0; i < faction.Count; i++)
+ {
+ bool flag2 = unchecked(num -= faction[i].weight) < 0f;
+ if (flag2)
+ {
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("GetWeightedRandomIndex : returning " + i);
+ }
+ return i;
+ }
+ }
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning("GetWeightedRandomFaction : failed to return proper index, returning -1");
+ }
+ result = -1;
+ }
+ return result;
+ }
+ }
+
+ public static Faction GetFaction(this HediffComp_RandySpawnUponDeath comp, FactionPickerParameters FPP)
+ {
+ FactionDef fDef = comp.GetFactionDef(FPP);
+ bool flag = fDef == null;
+ Faction result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ result = (from F in Find.FactionManager.AllFactions
+ where F.def == fDef
+ select F).FirstOrFallback(null);
+ }
+ return result;
+ }
+
+ public static FactionDef GetFactionDef(this HediffComp_RandySpawnUponDeath comp, FactionPickerParameters FPP)
+ {
+ Pawn pawn = comp.Pawn;
+ bool flag = FPP.HasInheritedFaction && pawn.Faction != null;
+ FactionDef result;
+ if (flag)
+ {
+ result = pawn.Faction.def;
+ }
+ else
+ {
+ bool hasForcedFaction = FPP.HasForcedFaction;
+ if (hasForcedFaction)
+ {
+ result = FPP.forcedFaction;
+ }
+ else
+ {
+ bool hasPlayerFaction = FPP.HasPlayerFaction;
+ if (hasPlayerFaction)
+ {
+ result = Faction.OfPlayer.def;
+ }
+ else
+ {
+ bool hasNoFaction = FPP.HasNoFaction;
+ if (hasNoFaction)
+ {
+ result = null;
+ }
+ else
+ {
+ bool hasDefaultPawnKindFaction = FPP.HasDefaultPawnKindFaction;
+ if (hasDefaultPawnKindFaction)
+ {
+ PawnKindDef pawnKindToSpawn = comp.ChosenItem.pawnKindToSpawn;
+ result = (((pawnKindToSpawn != null) ? pawnKindToSpawn.defaultFactionType : null) ?? null);
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FilthSettings.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FilthSettings.cs
new file mode 100644
index 0000000..54be685
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/FilthSettings.cs
@@ -0,0 +1,14 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class FilthSettings
+ {
+ public ThingDef filthDef = null;
+
+ public IntRange filthNum = new IntRange(1, 1);
+
+ public FloatRange filthRadius = new FloatRange(1f, 1f);
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Footprint.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Footprint.cs
new file mode 100644
index 0000000..e6c8ddd
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Footprint.cs
@@ -0,0 +1,27 @@
+using System;
+using UnityEngine;
+
+namespace MoharHediffs
+{
+ public class Footprint
+ {
+ public string Dump()
+ {
+ return string.Concat(new object[]
+ {
+ "intervalDistance:",
+ this.intervalDistance,
+ "; offset:",
+ this.offset,
+ "; distanceBetweenFeet:",
+ this.distanceBetweenFeet
+ });
+ }
+
+ public float intervalDistance = 0.632f;
+
+ public Vector3 offset = new Vector3(0f, 0f, -0.3f);
+
+ public float distanceBetweenFeet = 0.17f;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GeneralSettings.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GeneralSettings.cs
new file mode 100644
index 0000000..6075da4
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GeneralSettings.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class GeneralSettings
+ {
+ public bool HasSomethingToSpawn
+ {
+ get
+ {
+ return !this.things.NullOrEmpty();
+ }
+ }
+
+ public bool HasDefaultSettings
+ {
+ get
+ {
+ return this.defaultSettings != null;
+ }
+ }
+
+ public void LogParams(bool myDebug = false)
+ {
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ "HasSomethingToSpawn:",
+ this.HasSomethingToSpawn.ToString(),
+ "; HasDefaultSettings:",
+ this.HasDefaultSettings.ToString(),
+ "; "
+ }));
+ }
+ }
+
+ public List things;
+
+ public CommonSettings defaultSettings;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GfxEffects.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GfxEffects.cs
new file mode 100644
index 0000000..8fd89c0
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/GfxEffects.cs
@@ -0,0 +1,153 @@
+using System;
+using AlienRace;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class GfxEffects
+ {
+ public static Color ClosestColor(Pawn pawn, bool complementary = false, bool myDebug = false)
+ {
+ AlienPartGenerator.AlienComp alien = Tools.GetAlien(pawn);
+ bool flag = alien == null;
+ Color color;
+ if (flag)
+ {
+ color = pawn.DrawColor;
+ }
+ else
+ {
+ color = alien.GetChannel("skin").first;
+ if (myDebug)
+ {
+ Log.Warning(pawn.LabelShort + " is alien, color=" + color);
+ }
+ }
+ Color color2 = Color.blue;
+ float num = 1000f;
+ float num2 = Math.Abs(color.r - MyGfx.Purple.r) + Math.Abs(color.g - MyGfx.Purple.g) / 4f + Math.Abs(color.b - MyGfx.Purple.b);
+ float num3 = Math.Abs(color.r - MyGfx.Blue.r) / 2f + Math.Abs(color.g - MyGfx.Blue.g) / 2f + Math.Abs(color.b - MyGfx.Blue.b);
+ float num4 = Math.Abs(color.r - MyGfx.Cyan.r) / 4f + Math.Abs(color.g - MyGfx.Cyan.g) + Math.Abs(color.b - MyGfx.Cyan.b);
+ float num5 = Math.Abs(color.r - MyGfx.Green.r) / 2f + Math.Abs(color.g - MyGfx.Green.g) + Math.Abs(color.b - MyGfx.Green.b) / 2f;
+ float num6 = Math.Abs(color.r - MyGfx.Yellow.r) + Math.Abs(color.g - MyGfx.Yellow.g) + Math.Abs(color.b - MyGfx.Yellow.b) / 4f;
+ float num7 = Math.Abs(color.r - MyGfx.Orange.r) + Math.Abs(color.g - MyGfx.Orange.g) / 1.6f + Math.Abs(color.b - MyGfx.Orange.b) / 2.5f;
+ float num8 = Math.Abs(color.r - MyGfx.Red.r) + Math.Abs(color.g - MyGfx.Red.g) / 2f + Math.Abs(color.b - MyGfx.Red.b) / 2f;
+ if (myDebug)
+ {
+ Log.Warning(pawn.LabelShort + "'s pColor: " + color);
+ Log.Warning(string.Concat(new object[]
+ {
+ "purpleDiff: ",
+ num2,
+ "; blueDiff: ",
+ num3,
+ "; cyanDiff: ",
+ num4,
+ "; greenDiff: ",
+ num5,
+ "; yellowDiff: ",
+ num6,
+ "; orangeDiff: ",
+ num7,
+ "; redDiff: ",
+ num8
+ }));
+ }
+ bool flag2 = num2 < num;
+ if (flag2)
+ {
+ num = num2;
+ color2 = MyGfx.Purple;
+ }
+ bool flag3 = num3 < num;
+ if (flag3)
+ {
+ num = num3;
+ color2 = MyGfx.Blue;
+ }
+ bool flag4 = num4 < num;
+ if (flag4)
+ {
+ num = num4;
+ color2 = MyGfx.Blue;
+ }
+ bool flag5 = num5 < num;
+ if (flag5)
+ {
+ num = num5;
+ color2 = MyGfx.Green;
+ }
+ bool flag6 = num6 < num;
+ if (flag6)
+ {
+ num = num6;
+ color2 = MyGfx.Yellow;
+ }
+ bool flag7 = num7 < num;
+ if (flag7)
+ {
+ num = num7;
+ color2 = MyGfx.Orange;
+ }
+ bool flag8 = num8 < num;
+ if (flag8)
+ {
+ color2 = MyGfx.Red;
+ }
+ if (complementary)
+ {
+ bool flag9 = color2 == MyGfx.Purple;
+ if (flag9)
+ {
+ color2 = MyGfx.Yellow;
+ }
+ else
+ {
+ bool flag10 = color2 == MyGfx.Blue || color2 == MyGfx.Cyan;
+ if (flag10)
+ {
+ color2 = MyGfx.Orange;
+ }
+ else
+ {
+ bool flag11 = color2 == MyGfx.Green;
+ if (flag11)
+ {
+ color2 = MyGfx.Red;
+ }
+ else
+ {
+ bool flag12 = color2 == MyGfx.Yellow;
+ if (flag12)
+ {
+ color2 = MyGfx.Purple;
+ }
+ else
+ {
+ bool flag13 = color2 == MyGfx.Orange;
+ if (flag13)
+ {
+ color2 = MyGfx.Blue;
+ }
+ else
+ {
+ bool flag14 = color2 == MyGfx.Red;
+ if (flag14)
+ {
+ color2 = MyGfx.Green;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (myDebug)
+ {
+ Log.Warning(complementary ? "complementary" : ("closest Color=" + color2));
+ }
+ return color2;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffCompProperties_HediffExclusive.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffCompProperties_HediffExclusive.cs
new file mode 100644
index 0000000..65eb369
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffCompProperties_HediffExclusive.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HeDiffCompProperties_HediffExclusive : HediffCompProperties
+ {
+ public HeDiffCompProperties_HediffExclusive()
+ {
+ this.compClass = typeof(HeDiffComp_HediffExclusive);
+ }
+
+ public List hediffToNullify;
+
+ public List hediffPatternToNullify;
+
+ public HediffDef hediffToApply = null;
+
+ public BodyDef bodyDef;
+
+ public List bodyDefWhiteList;
+
+ public List bodyDefBlackList;
+
+ public BodyPartDef bodyPartDef;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffComp_HediffExclusive.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffComp_HediffExclusive.cs
new file mode 100644
index 0000000..2a4d8e6
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HeDiffComp_HediffExclusive.cs
@@ -0,0 +1,341 @@
+using System;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HeDiffComp_HediffExclusive : HediffComp
+ {
+ private bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public HeDiffCompProperties_HediffExclusive Props
+ {
+ get
+ {
+ return (HeDiffCompProperties_HediffExclusive)this.props;
+ }
+ }
+
+ public bool HasHediffToNullify
+ {
+ get
+ {
+ return !this.Props.hediffToNullify.NullOrEmpty();
+ }
+ }
+
+ public bool HasHediffPatternToNullify
+ {
+ get
+ {
+ return !this.Props.hediffPatternToNullify.NullOrEmpty();
+ }
+ }
+
+ public bool HasHediffToApply
+ {
+ get
+ {
+ return this.Props.hediffToApply != null;
+ }
+ }
+
+ private bool HasWhiteList
+ {
+ get
+ {
+ return !this.Props.bodyDefWhiteList.NullOrEmpty();
+ }
+ }
+
+ private bool HasBlackList
+ {
+ get
+ {
+ return !this.Props.bodyDefBlackList.NullOrEmpty();
+ }
+ }
+
+ private bool WhiteListCompliant
+ {
+ get
+ {
+ return !this.HasWhiteList || this.Props.bodyDefWhiteList.Contains(base.Pawn.def.race.body);
+ }
+ }
+
+ private bool BlackListCompliant
+ {
+ get
+ {
+ return !this.HasBlackList || !this.Props.bodyDefBlackList.Contains(base.Pawn.def.race.body);
+ }
+ }
+
+ private bool HasAccessList
+ {
+ get
+ {
+ return this.HasWhiteList || this.HasBlackList;
+ }
+ }
+
+ private string DebugStr
+ {
+ get
+ {
+ return this.MyDebug ? (base.Pawn.LabelShort + " HediffExclusive " + this.parent.def.defName + " - ") : "";
+ }
+ }
+
+ private bool PatternMatch(string MyHediffDefname)
+ {
+ foreach (string value in this.Props.hediffPatternToNullify)
+ {
+ bool flag = MyHediffDefname.Contains(value);
+ if (flag)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void NullifyHediff()
+ {
+ int num = 0;
+ checked
+ {
+ foreach (Hediff hediff in base.Pawn.health.hediffSet.hediffs)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ base.Pawn.Label,
+ " hediff #",
+ num,
+ ": ",
+ hediff.def.defName
+ }), this.MyDebug);
+ int num2 = 0;
+ foreach (HediffDef hediffDef in this.Props.hediffToNullify)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ " Props.hediffToNullify #",
+ num2,
+ ": ",
+ hediffDef
+ }), this.MyDebug);
+ bool flag = hediff.def == hediffDef && this.Props.hediffToApply != hediffDef;
+ if (flag)
+ {
+ hediff.Severity = 0f;
+ Tools.Warn(hediff.def.defName + " removed", this.MyDebug);
+ }
+ num2++;
+ }
+ num++;
+ }
+ }
+ }
+
+ public void PatternNullifyHediff()
+ {
+ int num = 0;
+ checked
+ {
+ foreach (Hediff hediff in base.Pawn.health.hediffSet.hediffs)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ base.Pawn.LabelShort,
+ " hediff #",
+ num,
+ ": ",
+ hediff.def.defName
+ }));
+ }
+ int num2 = 0;
+ foreach (string text in this.Props.hediffPatternToNullify)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ " Props.hediffPatternToNullify #",
+ num2,
+ ": ",
+ text
+ }));
+ }
+ bool flag = this.PatternMatch(hediff.def.defName);
+ if (flag)
+ {
+ hediff.Severity = 0f;
+ Tools.Warn(hediff.def.defName + " severity = 0", this.MyDebug);
+ }
+ num2++;
+ }
+ num++;
+ }
+ }
+ }
+
+ public void ApplyHediff()
+ {
+ HediffDef hediffToApply = this.Props.hediffToApply;
+ bool flag = hediffToApply == null;
+ if (flag)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("cant find hediff called: " + this.Props.hediffToApply);
+ }
+ }
+ else
+ {
+ BodyPartDef bodyPartDef = (from b in DefDatabase.AllDefs
+ where b == this.Props.bodyPartDef
+ select b).RandomElementWithFallback(null);
+ BodyPartRecord bodyPartRecord = null;
+ bool flag2 = bodyPartDef != null;
+ if (flag2)
+ {
+ bodyPartRecord = base.Pawn.RaceProps.body.GetPartsWithDef(bodyPartDef).RandomElementWithFallback(null);
+ bool flag3 = bodyPartRecord == null;
+ if (flag3)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning("cant find body part record called: " + this.Props.bodyPartDef.defName);
+ }
+ return;
+ }
+ }
+ Hediff hediff = HediffMaker.MakeHediff(hediffToApply, base.Pawn, bodyPartRecord);
+ bool flag4 = hediff == null;
+ if (flag4)
+ {
+ bool myDebug3 = this.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning("cant create hediff " + hediffToApply.defName + " to apply on " + this.Props.bodyPartDef.defName);
+ }
+ }
+ else
+ {
+ base.Pawn.health.AddHediff(hediff, bodyPartRecord, null, null);
+ }
+ }
+ }
+
+ public bool CheckProps()
+ {
+ string text = this.DebugStr + "ApplyHediff - ";
+ bool flag = this.Props.bodyDef != null;
+ if (flag)
+ {
+ bool flag2 = base.Pawn.def.race.body != this.Props.bodyDef;
+ if (flag2)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ base.Pawn.Label,
+ " has not a bodyDef like required: ",
+ base.Pawn.def.race.body.ToString(),
+ "!=",
+ this.Props.bodyDef.ToString()
+ }));
+ }
+ return false;
+ }
+ }
+ bool hasAccessList = this.HasAccessList;
+ if (hasAccessList)
+ {
+ bool blackListCompliant = this.BlackListCompliant;
+ bool whiteListCompliant = this.WhiteListCompliant;
+ bool flag3 = !blackListCompliant || !whiteListCompliant;
+ if (flag3)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ text,
+ this.HasWhiteList ? string.Format("Props.BodyDefWhiteList contains {0} elements", this.Props.bodyDefWhiteList.Count) : "No whitelist",
+ ", compliant: ",
+ whiteListCompliant.ToString(),
+ "; ",
+ this.HasBlackList ? string.Format("Props.BodyDefBlackList contains {0} elements", this.Props.bodyDefBlackList.Count) : "No blacklist",
+ ", compliant:",
+ blackListCompliant.ToString()
+ }));
+ }
+ return false;
+ }
+ bool myDebug3 = this.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning(text + " AccessList compliant ok");
+ }
+ }
+ return true;
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ if (!flag)
+ {
+ bool flag2 = this.CheckProps();
+ if (flag2)
+ {
+ bool hasHediffToNullify = this.HasHediffToNullify;
+ if (hasHediffToNullify)
+ {
+ this.NullifyHediff();
+ }
+ bool hasHediffPatternToNullify = this.HasHediffPatternToNullify;
+ if (hasHediffPatternToNullify)
+ {
+ this.PatternNullifyHediff();
+ }
+ bool hasHediffToApply = this.HasHediffToApply;
+ if (hasHediffToApply)
+ {
+ this.ApplyHediff();
+ }
+ }
+ Tools.DestroyParentHediff(this.parent, this.MyDebug);
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string empty = string.Empty;
+ return empty + "This should disappear very fast";
+ }
+ }
+
+ private const int tickLimiterModulo = 60;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffAndBodyPart.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffAndBodyPart.cs
new file mode 100644
index 0000000..61d575e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffAndBodyPart.cs
@@ -0,0 +1,24 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffAndBodyPart
+ {
+ public HediffDef hediff;
+
+ public BodyPartDef bodyPart;
+
+ public string bodyPartLabel;
+
+ public bool prioritizeMissing = false;
+
+ public bool allowMissing = true;
+
+ public bool regenIfMissing = true;
+
+ public bool allowAddedPart = true;
+
+ public bool wholeBodyFallback = true;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_AnotherRandom.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_AnotherRandom.cs
new file mode 100644
index 0000000..90c33eb
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_AnotherRandom.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_AnotherRandom : HediffCompProperties
+ {
+ public bool HasConditionsToApplyHediffs
+ {
+ get
+ {
+ return this.conditionsToApplyHediffs != null;
+ }
+ }
+
+ public bool HasDefaultCondition
+ {
+ get
+ {
+ return this.defaultCondition != null;
+ }
+ }
+
+ public bool HasHediffPool
+ {
+ get
+ {
+ return !this.hediffPool.NullOrEmpty();
+ }
+ }
+
+ public HediffCompProperties_AnotherRandom()
+ {
+ this.compClass = typeof(HediffComp_AnotherRandom);
+ }
+
+ public HediffCondition conditionsToApplyHediffs;
+
+ public HediffCondition defaultCondition;
+
+ public List hediffPool;
+
+ public IntRange hediffToApplyNumRange = new IntRange(1, 1);
+
+ public bool excludePickedItems = true;
+
+ public bool excludeRandomlyNotApplied = false;
+
+ public bool debug = false;
+
+ public int verbosity = 1;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Filther.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Filther.cs
new file mode 100644
index 0000000..ae08e6a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Filther.cs
@@ -0,0 +1,21 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_Filther : HediffCompProperties
+ {
+ public HediffCompProperties_Filther()
+ {
+ this.compClass = typeof(HediffComp_Filther);
+ }
+
+ public int MinTicksBetweenSprays = 60;
+
+ public int MaxTicksBetweenSprays = 120;
+
+ public ThingDef filthDef = null;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffNullifier.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffNullifier.cs
new file mode 100644
index 0000000..c632728
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffNullifier.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_HediffNullifier : HediffCompProperties
+ {
+ public HediffCompProperties_HediffNullifier()
+ {
+ this.compClass = typeof(HediffComp_HediffNullifier);
+ }
+
+ public int checkPeriod = 240;
+
+ public List hediffToNullify;
+
+ public int limitedUsageNumber = -99;
+
+ public List RequiredBodyPart;
+
+ public bool showMessage = false;
+
+ public string nullifyKey = "";
+
+ public bool concatUsageLimit = false;
+
+ public string limitedKey = "";
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffRandom.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffRandom.cs
new file mode 100644
index 0000000..39dc875
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_HediffRandom.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_HediffRandom : HediffCompProperties
+ {
+ public HediffCompProperties_HediffRandom()
+ {
+ this.compClass = typeof(HediffComp_HediffRandom);
+ }
+
+ public BodyDef bodyDef;
+
+ public List hediffPool;
+
+ public List weights;
+
+ public List bodyPartDef;
+
+ public bool debug = false;
+
+ public bool hideBySeverity = true;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_InnerShine.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_InnerShine.cs
new file mode 100644
index 0000000..c0f7120
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_InnerShine.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_InnerShine : HediffCompProperties
+ {
+ public bool HasShinePool
+ {
+ get
+ {
+ return this.HasRawShinePool || this.HasShineDefPool;
+ }
+ }
+
+ public bool HasRawShinePool
+ {
+ get
+ {
+ return !this.innerShinePool.NullOrEmpty();
+ }
+ }
+
+ public bool HasShineDefPool
+ {
+ get
+ {
+ return !this.innerShineDefPool.NullOrEmpty();
+ }
+ }
+
+ public HediffCompProperties_InnerShine()
+ {
+ this.compClass = typeof(HediffComp_InnerShine);
+ }
+
+ public List innerShinePool;
+
+ public List innerShineDefPool;
+
+ public bool debug;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_MultipleHediff.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_MultipleHediff.cs
new file mode 100644
index 0000000..16c10ca
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_MultipleHediff.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_MultipleHediff : HediffCompProperties
+ {
+ public HediffCompProperties_MultipleHediff()
+ {
+ this.compClass = typeof(HediffComp_MultipleHediff);
+ }
+
+ public BodyDef bodyDef;
+
+ public List bodyDefWhiteList;
+
+ public List bodyDefBlackList;
+
+ public List hediffAndBodypart;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_OnTheCarpet.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_OnTheCarpet.cs
new file mode 100644
index 0000000..2b74c6e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_OnTheCarpet.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_OnTheCarpet : HediffCompProperties
+ {
+ public bool HasDefaultCondition
+ {
+ get
+ {
+ return this.defaultCondition != null;
+ }
+ }
+
+ public bool HasHediffPool
+ {
+ get
+ {
+ return !this.hediffPool.NullOrEmpty();
+ }
+ }
+
+ public int ItemCount
+ {
+ get
+ {
+ return this.HasHediffPool ? this.hediffPool.Count : 0;
+ }
+ }
+
+ public HediffCompProperties_OnTheCarpet()
+ {
+ this.compClass = typeof(HediffComp_OnTheCarpet);
+ }
+
+ public List hediffPool;
+
+ public HediffKeepingCondition defaultCondition;
+
+ public int checkPeriod = 120;
+
+ public int graceTimeBase = 120;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_PostRemoveTrigger_HediffAdd.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_PostRemoveTrigger_HediffAdd.cs
new file mode 100644
index 0000000..ef49eac
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_PostRemoveTrigger_HediffAdd.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_PostRemoveTrigger_HediffAdd : HediffCompProperties
+ {
+ public HediffCompProperties_PostRemoveTrigger_HediffAdd()
+ {
+ this.compClass = typeof(HediffComp_PostRemoveTrigger_HediffAdd);
+ }
+
+ public List triggeredHediff;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RainbowTrail.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RainbowTrail.cs
new file mode 100644
index 0000000..90c99c5
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RainbowTrail.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_RainbowTrail : HediffCompProperties
+ {
+ public HediffCompProperties_RainbowTrail()
+ {
+ this.compClass = typeof(HediffComp_RainbowTrail);
+ }
+
+ public int period = 15;
+
+ public List motePurpleDef;
+
+ public List moteBlueDef;
+
+ public List moteGreenDef;
+
+ public List moteYellowDef;
+
+ public List moteOrangeDef;
+
+ public List moteRedDef;
+
+ public float staySameColorChance = 0.5f;
+
+ public int maxTimesSameColor = 3;
+
+ public int minTimesSameColor = 1;
+
+ public FloatRange scale = new FloatRange(0.5f, 0.8f);
+
+ public bool threeColorsGradient = false;
+
+ public HediffComp_RainbowTrail.ColorChoice colorChoice = HediffComp_RainbowTrail.ColorChoice.random;
+
+ public HediffComp_RainbowTrail.CycleKind cycleKind = HediffComp_RainbowTrail.CycleKind.circular;
+
+ public bool debug = false;
+
+ public bool hideBySeverity = true;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawnUponDeath.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawnUponDeath.cs
new file mode 100644
index 0000000..e1a6e33
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawnUponDeath.cs
@@ -0,0 +1,45 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_RandySpawnUponDeath : HediffCompProperties
+ {
+ public bool HasRequirements
+ {
+ get
+ {
+ return this.requirements != null;
+ }
+ }
+
+ public bool HasParentRedress
+ {
+ get
+ {
+ return this.redressParent != null;
+ }
+ }
+
+ public HediffCompProperties_RandySpawnUponDeath()
+ {
+ this.compClass = typeof(HediffComp_RandySpawnUponDeath);
+ }
+
+ public GeneralSettings settings;
+
+ public RedressSettings redressParent;
+
+ public RequirementSettings requirements;
+
+ public IntRange iterationRange = new IntRange(1, 1);
+
+ public bool excludeAlreadyPickedOptions = false;
+
+ public int spawnMaxAdjacent = -1;
+
+ public bool spawnForbidden = false;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawner.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawner.cs
new file mode 100644
index 0000000..7b67b66
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_RandySpawner.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_RandySpawner : HediffCompProperties
+ {
+ public HediffCompProperties_RandySpawner()
+ {
+ this.compClass = typeof(HediffComp_RandySpawner);
+ }
+
+ public List itemParameters;
+
+ public int spawnMaxAdjacent = -1;
+
+ public bool spawnForbidden = false;
+
+ public bool hungerRelative = false;
+
+ public bool healthRelative = false;
+
+ public bool logNextSpawn = false;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Spawner.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Spawner.cs
new file mode 100644
index 0000000..a558bf7
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Spawner.cs
@@ -0,0 +1,55 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_Spawner : HediffCompProperties
+ {
+ public HediffCompProperties_Spawner()
+ {
+ this.compClass = typeof(HediffComp_Spawner);
+ }
+
+ public ThingDef thingToSpawn;
+
+ public int spawnCount = 1;
+
+ public bool animalThing = false;
+
+ public PawnKindDef animalToSpawn;
+
+ public bool factionOfPlayerAnimal = false;
+
+ public float minDaysB4Next = 1f;
+
+ public float maxDaysB4Next = 2f;
+
+ public float randomGrace = 0f;
+
+ public float graceDays = 0.5f;
+
+ public int spawnMaxAdjacent = -1;
+
+ public bool spawnForbidden = false;
+
+ public bool hungerRelative = false;
+
+ public bool healthRelative = false;
+
+ public bool ageWeightedQuantity = false;
+
+ public bool ageWeightedPeriod = false;
+
+ public bool olderSmallerPeriod = false;
+
+ public bool olderBiggerQuantity = false;
+
+ public bool exponentialQuantity = false;
+
+ public int exponentialRatioLimit = 15;
+
+ public string spawnVerb = "delivery";
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Steamer.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Steamer.cs
new file mode 100644
index 0000000..f52c48b
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_Steamer.cs
@@ -0,0 +1,27 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_Steamer : HediffCompProperties
+ {
+ public HediffCompProperties_Steamer()
+ {
+ this.compClass = typeof(HediffComp_Steamer);
+ }
+
+ public int MinTicksBetweenSprays = 200;
+
+ public int MaxTicksBetweenSprays = 400;
+
+ public int MinSprayDuration = 60;
+
+ public int MaxSprayDuration = 120;
+
+ public float puffingChance = 1f;
+
+ public float temperatureIncreasePerPuff = 0.5f;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_TrailLeaver.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_TrailLeaver.cs
new file mode 100644
index 0000000..75bf603
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCompProperties_TrailLeaver.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffCompProperties_TrailLeaver : HediffCompProperties
+ {
+ public bool HasRestriction
+ {
+ get
+ {
+ return this.restriction != null;
+ }
+ }
+
+ public bool HasColorRange
+ {
+ get
+ {
+ return this.colorRange != null;
+ }
+ }
+
+ public bool UsesFootPrints
+ {
+ get
+ {
+ return this.footprint != null;
+ }
+ }
+
+ public bool HasMotePool
+ {
+ get
+ {
+ return !this.motePool.NullOrEmpty();
+ }
+ }
+
+ public bool HasOffset
+ {
+ get
+ {
+ return !this.offSetPerBodyType.NullOrEmpty();
+ }
+ }
+
+ public bool HasRotationOffset
+ {
+ get
+ {
+ return this.rotationOffset != 0f;
+ }
+ }
+
+ public HediffCompProperties_TrailLeaver()
+ {
+ this.compClass = typeof(HediffComp_TrailLeaver);
+ }
+
+ public IntRange period = new IntRange(15, 25);
+
+ public List motePool;
+
+ public List offSetPerBodyType;
+
+ public Vector3 defaultOffset = new Vector3(0f, 0f, -0.32f);
+
+ public Restriction restriction;
+
+ public Footprint footprint;
+
+ public ColorRange colorRange;
+
+ public float rotationOffset = 0f;
+
+ public bool dynamicRotation = true;
+
+ public FloatRange randomScale = new FloatRange(0.5f, 0.8f);
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_AnotherRandom.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_AnotherRandom.cs
new file mode 100644
index 0000000..8c01cde
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_AnotherRandom.cs
@@ -0,0 +1,322 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_AnotherRandom : HediffComp
+ {
+ public bool HasItems
+ {
+ get
+ {
+ return this.Props.HasHediffPool;
+ }
+ }
+
+ public int ItemNum
+ {
+ get
+ {
+ return this.Props.hediffPool.Count;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public bool LowVerbosity
+ {
+ get
+ {
+ return this.Props.debug && this.Props.verbosity >= 1;
+ }
+ }
+
+ public bool MediumVerbosity
+ {
+ get
+ {
+ return this.Props.debug && this.Props.verbosity >= 2;
+ }
+ }
+
+ public bool HighVerbosity
+ {
+ get
+ {
+ return this.Props.debug && this.Props.verbosity >= 3;
+ }
+ }
+
+ public HediffCompProperties_AnotherRandom Props
+ {
+ get
+ {
+ return (HediffCompProperties_AnotherRandom)this.props;
+ }
+ }
+
+ public void DumpProps()
+ {
+ string text = "CheckProps";
+ bool flag = !this.HasItems;
+ if (flag)
+ {
+ Tools.Warn(text + "- HediffComp_AnotherRandom; no item found", this.MyDebug);
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ "- HediffComp_AnotherRandom; found ",
+ this.ItemNum,
+ " items"
+ }), this.MyDebug);
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ base.CompPostMake();
+ string text = this.MyDebug ? (base.Pawn.LabelShort + " CompPostMake - ") : "";
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ this.DumpProps();
+ }
+ bool flag = !this.HasItems;
+ if (flag)
+ {
+ Tools.Warn(text + " found no item to work with, destroying ", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ this.blockAction = true;
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ " found ",
+ this.ItemNum,
+ " items to work with"
+ }), this.MyDebug);
+ bool hasConditionsToApplyHediffs = this.Props.HasConditionsToApplyHediffs;
+ if (hasConditionsToApplyHediffs)
+ {
+ BodyPartRecord bodyPartRecord;
+ bool flag2 = !this.Props.conditionsToApplyHediffs.pawn.ValidateCompatibilityOfHediffWithPawn(base.Pawn, this.MyDebug) || !this.Props.conditionsToApplyHediffs.bodyPart.GetBPRFromHediffCondition(base.Pawn, out bodyPartRecord, this.MyDebug);
+ if (flag2)
+ {
+ Tools.Warn(text + " is not compatible with this hediff, destroying ", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ this.blockAction = true;
+ return;
+ }
+ }
+ else
+ {
+ Tools.Warn(text + " skipped HasConditionsToApplyHediffs", this.MyDebug);
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ " checking if at least 1 hediff from ",
+ this.ItemNum,
+ " is appliable"
+ }), this.MyDebug);
+ bool flag3 = !this.InitialHediffConditionCheck(this.MyDebug);
+ if (flag3)
+ {
+ Tools.Warn(text + " has found no appliable item, destroying ", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ this.blockAction = true;
+ }
+ else
+ {
+ Tools.Warn(text + " found at least 1 appliable hediff", this.MyDebug);
+ }
+ }
+ }
+
+ public void ApplyHediff(Pawn pawn)
+ {
+ string text = this.MyDebug ? (base.Pawn.LabelShort + " - " + this.parent.def.defName + " - ApplyHediff") : "";
+ List list = new List();
+ int randomInRange = this.Props.hediffToApplyNumRange.RandomInRange;
+ List list2 = this.GetCompatibleItems();
+ bool flag = list2.NullOrEmpty();
+ checked
+ {
+ if (!flag)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ "Trying to apply ",
+ randomInRange,
+ " hediffs among ",
+ list2.Count,
+ " options pool"
+ }), this.MyDebug);
+ for (int i = 0; i < randomInRange; i++)
+ {
+ string text2 = this.MyDebug ? string.Concat(new object[]
+ {
+ "[",
+ i,
+ "/",
+ randomInRange,
+ "]"
+ }) : "";
+ bool flag2 = !list.NullOrEmpty();
+ if (flag2)
+ {
+ list2 = list2.GetRemainingItems(list);
+ bool flag3 = list2.NullOrEmpty();
+ if (flag3)
+ {
+ break;
+ }
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ text2,
+ " ",
+ list2.Count,
+ " options remaining "
+ }), this.MyDebug);
+ HediffItem hediffItem = list2.PickRandomWeightedItem(false);
+ bool flag4 = hediffItem == null;
+ if (flag4)
+ {
+ Tools.Warn(text + text2 + " null hediffItem, giving up ", this.MyDebug);
+ break;
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ text2,
+ " found a hediffItem:",
+ (hediffItem != null) ? hediffItem.hediffDef : null,
+ ", going on "
+ }), this.MyDebug);
+ float randomInRange2 = hediffItem.applyChance.RandomInRange;
+ bool flag5 = !Rand.Chance(randomInRange2);
+ if (flag5)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ text2,
+ " rand(",
+ randomInRange2,
+ ") == false, nothing is applied"
+ }), this.MyDebug);
+ bool flag6 = this.Props.excludePickedItems && this.Props.excludeRandomlyNotApplied;
+ if (flag6)
+ {
+ list.Add(hediffItem);
+ }
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ text2,
+ " rand(",
+ randomInRange2,
+ ") == true, hediff:",
+ (hediffItem != null) ? hediffItem.hediffDef : null,
+ " will be applied"
+ }), this.MyDebug);
+ HediffDef hediffDef = hediffItem.hediffDef;
+ bool flag7 = hediffDef == null;
+ if (flag7)
+ {
+ Tools.Warn(text + text2 + "cant find hediff, giving up", this.MyDebug);
+ break;
+ }
+ HediffCompProperties_AnotherRandom props = this.Props;
+ HediffCondition defaultPlusSpecificHediffCondition = ConditionBuilder.GetDefaultPlusSpecificHediffCondition(((props != null) ? props.defaultCondition : null) ?? null, ((hediffItem != null) ? hediffItem.specificCondition : null) ?? null, this.HighVerbosity);
+ BodyPartRecord bodyPartRecord;
+ bool flag8 = !defaultPlusSpecificHediffCondition.bodyPart.GetBPRFromHediffCondition(base.Pawn, out bodyPartRecord, this.MyDebug);
+ if (flag8)
+ {
+ Tools.Warn(text + text2 + " could not find anything suitable, giving up", this.MyDebug);
+ break;
+ }
+ Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn, bodyPartRecord);
+ bool flag9 = hediff == null;
+ if (flag9)
+ {
+ Tools.Warn(text + text2 + "cant create hediff", this.MyDebug);
+ break;
+ }
+ hediff.Severity = hediffItem.severity.RandomInRange;
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ text2,
+ " Applying hediff:",
+ hediffDef.defName,
+ "; bpr:",
+ (bodyPartRecord == null) ? "body" : bodyPartRecord.def.defName,
+ "; severity:",
+ hediff.Severity
+ }), this.MyDebug);
+ pawn.health.AddHediff(hediff, bodyPartRecord, null, null);
+ bool excludePickedItems = this.Props.excludePickedItems;
+ if (excludePickedItems)
+ {
+ list.Add(hediffItem);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ Pawn pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(pawn);
+ if (!flag)
+ {
+ bool flag2 = this.blockAction;
+ if (flag2)
+ {
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ }
+ else
+ {
+ bool hasItems = this.HasItems;
+ if (hasItems)
+ {
+ this.ApplyHediff(pawn);
+ }
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string empty = string.Empty;
+ return empty + "This should disappear very fast";
+ }
+ }
+
+ private bool blockAction = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Filther.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Filther.cs
new file mode 100644
index 0000000..cdb1a13
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Filther.cs
@@ -0,0 +1,64 @@
+using System;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_Filther : HediffComp
+ {
+ public HediffCompProperties_Filther Props
+ {
+ get
+ {
+ return (HediffCompProperties_Filther)this.props;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ this.myDebug = this.Props.debug;
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ this.myPawn = this.parent.pawn;
+ bool flag = this.myPawn == null;
+ checked
+ {
+ if (flag)
+ {
+ Tools.Warn("pawn null", this.myDebug);
+ }
+ else
+ {
+ bool flag2 = this.myPawn.Map == null;
+ if (!flag2)
+ {
+ bool flag3 = this.Props.filthDef == null;
+ if (!flag3)
+ {
+ bool flag4 = this.filthTicksLeft <= 0;
+ if (flag4)
+ {
+ FilthMaker.TryMakeFilth(this.myPawn.Position, this.myPawn.Map, this.Props.filthDef, 1, FilthSourceFlags.None, true);
+ this.filthTicksLeft = (this.ticksUntilFilth = Rand.RangeInclusive(this.Props.MinTicksBetweenSprays, this.Props.MaxTicksBetweenSprays));
+ }
+ else
+ {
+ this.filthTicksLeft--;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private Pawn myPawn = null;
+
+ private int ticksUntilFilth = 500;
+
+ private int filthTicksLeft;
+
+ private bool myDebug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffNullifier.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffNullifier.cs
new file mode 100644
index 0000000..4806add
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffNullifier.cs
@@ -0,0 +1,230 @@
+using System;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_HediffNullifier : HediffComp
+ {
+ public HediffCompProperties_HediffNullifier Props
+ {
+ get
+ {
+ return (HediffCompProperties_HediffNullifier)this.props;
+ }
+ }
+
+ public bool RequiresAtLeastOneBodyPart
+ {
+ get
+ {
+ return !this.Props.RequiredBodyPart.NullOrEmpty();
+ }
+ }
+
+ public bool HasMessageToDisplay
+ {
+ get
+ {
+ return this.Props.showMessage && !this.Props.nullifyKey.NullOrEmpty();
+ }
+ }
+
+ public bool DisplayLimitedUsageLeft
+ {
+ get
+ {
+ return this.HasMessageToDisplay && this.Props.concatUsageLimit && !this.Props.limitedKey.NullOrEmpty();
+ }
+ }
+
+ public bool HasHediffToNullify
+ {
+ get
+ {
+ return !this.Props.hediffToNullify.NullOrEmpty();
+ }
+ }
+
+ public bool HasLimitedUsage
+ {
+ get
+ {
+ return this.Props.limitedUsageNumber != -99;
+ }
+ }
+
+ public void BlockAndDestroy()
+ {
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ this.BlockPostTick = true;
+ }
+
+ public override void CompPostMake()
+ {
+ bool flag = this.myDebug;
+ if (flag)
+ {
+ Log.Warning(">>>" + this.parent.def.defName + " - CompPostMake start");
+ }
+ bool flag2 = !this.HasHediffToNullify;
+ if (flag2)
+ {
+ bool flag3 = this.myDebug;
+ if (flag3)
+ {
+ Log.Warning(this.parent.def.defName + " has no hediff to nullify, autokill");
+ }
+ this.BlockAndDestroy();
+ }
+ this.DestroyHediffIfMissingBP();
+ bool hasLimitedUsage = this.HasLimitedUsage;
+ if (hasLimitedUsage)
+ {
+ this.LimitedUsageNumber = this.Props.limitedUsageNumber;
+ }
+ }
+
+ public void DestroyHediffIfMissingBP()
+ {
+ bool flag = !this.RequiresAtLeastOneBodyPart;
+ if (!flag)
+ {
+ bool flag2 = false;
+ foreach (BodyPartDef bodyPartDef in this.Props.RequiredBodyPart)
+ {
+ bool flag3;
+ flag2 = (flag3 = base.Pawn.CheckIfExistingNaturalBP(bodyPartDef, false));
+ if (flag3)
+ {
+ break;
+ }
+ }
+ bool flag4 = !flag2;
+ if (flag4)
+ {
+ bool flag5 = this.myDebug;
+ if (flag5)
+ {
+ Log.Warning(base.Pawn.LabelShort + " does not have any required body part to have an active " + this.parent.def.defName + ", autokill");
+ }
+ this.BlockAndDestroy();
+ }
+ }
+ }
+
+ public override void CompExposeData()
+ {
+ Scribe_Values.Look(ref this.LimitedUsageNumber, "LimitedUsageNumber", 0, false);
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = !base.Pawn.IsHashIntervalTick(this.Props.checkPeriod);
+ checked
+ {
+ if (!flag)
+ {
+ bool flag2 = !Tools.OkPawn(base.Pawn);
+ if (!flag2)
+ {
+ this.DestroyHediffIfMissingBP();
+ bool blockPostTick = this.BlockPostTick;
+ if (!blockPostTick)
+ {
+ foreach (Hediff hediff in from h in base.Pawn.health.hediffSet.hediffs
+ where this.Props.hediffToNullify.Contains(h.def)
+ select h)
+ {
+ bool flag3 = this.myDebug;
+ if (flag3)
+ {
+ Log.Warning(base.Pawn.Label + " - " + hediff.def.defName);
+ }
+ hediff.Severity = 0f;
+ bool flag4 = this.myDebug;
+ if (flag4)
+ {
+ Log.Warning(hediff.def.defName + " severity = 0");
+ }
+ bool hasLimitedUsage = this.HasLimitedUsage;
+ if (hasLimitedUsage)
+ {
+ this.LimitedUsageNumber--;
+ bool flag5 = this.LimitedUsageNumber <= 0;
+ if (flag5)
+ {
+ bool flag6 = this.myDebug;
+ if (flag6)
+ {
+ Log.Warning(this.parent.def.defName + " has reached its limit usage, autokill");
+ }
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ }
+ bool hasMessageToDisplay = this.HasMessageToDisplay;
+ if (hasMessageToDisplay)
+ {
+ string text = this.Props.nullifyKey.Translate(base.Pawn.LabelShort, hediff.def.label, base.Pawn.gender.GetPronoun(), base.Pawn.kindDef.race.label);
+ bool displayLimitedUsageLeft = this.DisplayLimitedUsageLeft;
+ if (displayLimitedUsageLeft)
+ {
+ text += this.Props.limitedKey.Translate(this.LimitedUsageNumber);
+ }
+ text += ".";
+ Messages.Message(text, MessageTypeDefOf.NeutralEvent, true);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string text = string.Empty;
+ bool flag = !this.HasHediffToNullify;
+ string result;
+ if (flag)
+ {
+ result = text;
+ }
+ else
+ {
+ text += "Immune to: ";
+ foreach (HediffDef hediffDef in this.Props.hediffToNullify)
+ {
+ text = text + hediffDef.label + "; ";
+ }
+ bool flag2 = !this.HasLimitedUsage;
+ if (flag2)
+ {
+ text += " for ever";
+ }
+ else
+ {
+ text = string.Concat(new object[]
+ {
+ text,
+ " ",
+ this.LimitedUsageNumber,
+ " left"
+ });
+ }
+ result = text;
+ }
+ return result;
+ }
+ }
+
+ private int LimitedUsageNumber = 0;
+
+ private bool BlockPostTick = false;
+
+ private readonly bool myDebug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffRandom.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffRandom.cs
new file mode 100644
index 0000000..a8b9b16
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_HediffRandom.cs
@@ -0,0 +1,178 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_HediffRandom : HediffComp
+ {
+ public HediffCompProperties_HediffRandom Props
+ {
+ get
+ {
+ return (HediffCompProperties_HediffRandom)this.props;
+ }
+ }
+
+ private bool myDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ private bool HasWeights
+ {
+ get
+ {
+ return !this.Props.weights.NullOrEmpty() && this.Props.weights.Count == this.Props.hediffPool.Count;
+ }
+ }
+
+ private bool HasBodyParts
+ {
+ get
+ {
+ return !this.Props.bodyPartDef.NullOrEmpty() && this.Props.bodyPartDef.Count == this.Props.hediffPool.Count;
+ }
+ }
+
+ private bool HasHediff
+ {
+ get
+ {
+ return !this.Props.hediffPool.NullOrEmpty();
+ }
+ }
+
+ private Pawn pawn
+ {
+ get
+ {
+ return this.parent.pawn;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ bool hideBySeverity = this.Props.hideBySeverity;
+ if (hideBySeverity)
+ {
+ this.parent.Severity = 0.05f;
+ }
+ }
+
+ public int WeightedRandomness
+ {
+ get
+ {
+ int num = 0;
+ checked
+ {
+ foreach (int num2 in this.Props.weights)
+ {
+ num += num2;
+ }
+ int num3 = Rand.Range(0, num);
+ for (int i = 0; i < this.Props.weights.Count; i++)
+ {
+ int num4 = this.Props.weights[i];
+ bool flag = (num3 -= num4) < 0;
+ if (flag)
+ {
+ return i;
+ }
+ }
+ return 0;
+ }
+ }
+ }
+
+ public void ApplyHediff(Pawn pawn)
+ {
+ bool flag = this.Props.bodyDef != null;
+ if (flag)
+ {
+ bool flag2 = pawn.def.race.body != this.Props.bodyDef;
+ if (flag2)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ pawn.Label,
+ " has not a bodyDef like required: ",
+ pawn.def.race.body.ToString(),
+ "!=",
+ this.Props.bodyDef.ToString()
+ }), this.myDebug);
+ return;
+ }
+ }
+ bool flag3 = !this.HasWeights;
+ int num;
+ if (flag3)
+ {
+ num = Rand.Range(0, this.Props.hediffPool.Count());
+ }
+ else
+ {
+ num = this.WeightedRandomness;
+ }
+ bool flag4 = num < 0 || num >= this.Props.hediffPool.Count;
+ if (flag4)
+ {
+ Tools.Warn(num + " is out of range. Applyhediff will fail. Please report this error.", this.myDebug);
+ }
+ HediffDef hediffDef = this.Props.hediffPool[num];
+ bool flag5 = hediffDef == null;
+ if (flag5)
+ {
+ Tools.Warn("cant find hediff", this.myDebug);
+ }
+ else
+ {
+ BodyPartRecord bodyPartRecord = null;
+ BodyPartDef bodyPartDef = null;
+ bool hasBodyParts = this.HasBodyParts;
+ if (hasBodyParts)
+ {
+ bodyPartDef = this.Props.bodyPartDef[num];
+ IEnumerable partsWithDef = pawn.RaceProps.body.GetPartsWithDef(bodyPartDef);
+ bool flag6 = partsWithDef.EnumerableNullOrEmpty();
+ if (flag6)
+ {
+ Tools.Warn("cant find body part record called: " + bodyPartDef.defName, this.myDebug);
+ return;
+ }
+ bodyPartRecord = partsWithDef.RandomElement();
+ }
+ Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn, bodyPartRecord);
+ bool flag7 = hediff == null;
+ if (flag7)
+ {
+ Tools.Warn("cant create hediff " + hediffDef.defName + " to apply on " + ((bodyPartDef != null) ? bodyPartDef.defName : null), this.myDebug);
+ }
+ else
+ {
+ pawn.health.AddHediff(hediff, bodyPartRecord, null, null);
+ Tools.Warn("Succesfully applied " + hediffDef.defName + " to apply on " + ((bodyPartDef != null) ? bodyPartDef.defName : null), this.myDebug);
+ }
+ }
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = !Tools.OkPawn(this.pawn);
+ if (!flag)
+ {
+ bool hasHediff = this.HasHediff;
+ if (hasHediff)
+ {
+ this.ApplyHediff(this.pawn);
+ }
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_InnerShine.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_InnerShine.cs
new file mode 100644
index 0000000..91cad6b
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_InnerShine.cs
@@ -0,0 +1,209 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_InnerShine : HediffComp
+ {
+ public Map MyMap
+ {
+ get
+ {
+ return base.Pawn.Map;
+ }
+ }
+
+ public bool NullMap
+ {
+ get
+ {
+ return this.MyMap == null;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public bool HasEmptyTracer
+ {
+ get
+ {
+ return this.Tracer.NullOrEmpty();
+ }
+ }
+
+ public bool HasShinePool
+ {
+ get
+ {
+ return this.Props.HasShinePool;
+ }
+ }
+
+ public HediffCompProperties_InnerShine Props
+ {
+ get
+ {
+ return (HediffCompProperties_InnerShine)this.props;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ this.PropsCheck();
+ this.CreateTracer();
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ checked
+ {
+ if (flag)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("null pawn");
+ }
+ }
+ else
+ {
+ bool hasEmptyTracer = this.HasEmptyTracer;
+ if (hasEmptyTracer)
+ {
+ this.CreateTracer();
+ }
+ foreach (InnerShineRecord innerShineRecord in this.Tracer)
+ {
+ InnerShineItem innerShineItem = this.RetrieveISI(innerShineRecord.label);
+ bool flag2 = innerShineItem == null;
+ if (flag2)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning("Did not find ISI with label:" + innerShineRecord.label);
+ }
+ }
+ else
+ {
+ bool flag3 = innerShineRecord.ticksLeft <= 0;
+ if (flag3)
+ {
+ bool flag4 = innerShineItem.ShouldSpawnMote(innerShineRecord, base.Pawn);
+ if (flag4)
+ {
+ innerShineItem.TryPlaceMote(innerShineRecord, base.Pawn);
+ }
+ innerShineItem.ResetTicks(innerShineRecord);
+ }
+ else
+ {
+ innerShineRecord.ticksLeft--;
+ }
+ innerShineItem.UpdateMotes(innerShineRecord, base.Pawn, this.MyDebug);
+ }
+ }
+ }
+ }
+ }
+
+ public void PropsCheck()
+ {
+ bool flag = !this.HasShinePool;
+ checked
+ {
+ if (flag)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("no shine pool, giving up");
+ }
+ this.SelfDestroy();
+ }
+ else
+ {
+ bool flag2 = !this.MyDebug;
+ if (!flag2)
+ {
+ bool hasRawShinePool = this.Props.HasRawShinePool;
+ if (hasRawShinePool)
+ {
+ IEnumerable enumerable;
+ bool flag3 = (enumerable = from s in this.Props.innerShinePool
+ where !s.HasMotePool
+ select s) != null;
+ if (flag3)
+ {
+ foreach (InnerShineItem innerShineItem in enumerable)
+ {
+ Log.Warning(innerShineItem.label + " has no mote pool");
+ }
+ }
+ IEnumerable enumerable2;
+ bool flag4 = (enumerable2 = from s in this.Props.innerShinePool
+ where !s.HasDefaultDrawRules && !s.HasBodyTypeDrawRules
+ select s) != null;
+ if (flag4)
+ {
+ foreach (InnerShineItem innerShineItem2 in enumerable2)
+ {
+ Log.Warning(innerShineItem2.label + " has no default nor bodytypedef draw rules, at least one is required");
+ }
+ }
+ int num = 0;
+ foreach (InnerShineItem innerShineItem3 in this.Props.innerShinePool)
+ {
+ Log.Warning("Raw" + num.ToString("00") + " => " + innerShineItem3.Dump());
+ num++;
+ }
+ }
+ bool hasShineDefPool = this.Props.HasShineDefPool;
+ if (hasShineDefPool)
+ {
+ IEnumerable enumerable3;
+ bool flag5 = (enumerable3 = from s in this.Props.innerShineDefPool
+ where !s.item.HasMotePool
+ select s) != null;
+ if (flag5)
+ {
+ foreach (InnerShineDef innerShineDef in enumerable3)
+ {
+ Log.Warning(innerShineDef.item.label + " has no mote pool");
+ }
+ }
+ IEnumerable enumerable4;
+ bool flag6 = (enumerable4 = from s in this.Props.innerShineDefPool
+ where !s.item.HasDefaultDrawRules && !s.item.HasBodyTypeDrawRules
+ select s) != null;
+ if (flag6)
+ {
+ foreach (InnerShineDef innerShineDef2 in enumerable4)
+ {
+ Log.Warning(innerShineDef2.item.label + " has no default nor bodytypedef draw rules, at least one is required");
+ }
+ }
+ int num2 = 0;
+ foreach (InnerShineDef innerShineDef3 in this.Props.innerShineDefPool)
+ {
+ Log.Warning("Def" + num2.ToString("00") + " => " + innerShineDef3.item.Dump());
+ num2++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public List Tracer;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_MultipleHediff.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_MultipleHediff.cs
new file mode 100644
index 0000000..8de1b36
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_MultipleHediff.cs
@@ -0,0 +1,287 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_MultipleHediff : HediffComp
+ {
+ private bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ private string DebugStr
+ {
+ get
+ {
+ return this.MyDebug ? (base.Pawn.LabelShort + " MultipleHediff " + this.parent.def.defName + " - ") : "";
+ }
+ }
+
+ private bool HasSingleBodyRequirement
+ {
+ get
+ {
+ return this.Props.bodyDef != null;
+ }
+ }
+
+ private bool HasWhiteList
+ {
+ get
+ {
+ return !this.Props.bodyDefWhiteList.NullOrEmpty();
+ }
+ }
+
+ private bool HasBlackList
+ {
+ get
+ {
+ return !this.Props.bodyDefBlackList.NullOrEmpty();
+ }
+ }
+
+ private bool WhiteListCompliant
+ {
+ get
+ {
+ return !this.HasWhiteList || this.Props.bodyDefWhiteList.Contains(base.Pawn.def.race.body);
+ }
+ }
+
+ private bool BlackListCompliant
+ {
+ get
+ {
+ return !this.HasBlackList || !this.Props.bodyDefBlackList.Contains(base.Pawn.def.race.body);
+ }
+ }
+
+ private bool HasAccessList
+ {
+ get
+ {
+ return this.HasWhiteList || this.HasBlackList;
+ }
+ }
+
+ public HediffCompProperties_MultipleHediff Props
+ {
+ get
+ {
+ return (HediffCompProperties_MultipleHediff)this.props;
+ }
+ }
+
+ public bool HasHediffToApply
+ {
+ get
+ {
+ return !this.Props.hediffAndBodypart.NullOrEmpty();
+ }
+ }
+
+ public void CheckProps()
+ {
+ string text = this.DebugStr + "CheckProps - ";
+ bool flag = !this.HasHediffToApply;
+ if (flag)
+ {
+ Tools.Warn(text + "- empty hediffAndBodypart, destroying", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, false);
+ this.blockAction = true;
+ }
+ bool flag2 = this.HasSingleBodyRequirement && base.Pawn.def.race.body != this.Props.bodyDef;
+ if (flag2)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ text,
+ " has not a bodyDef like required: ",
+ base.Pawn.def.race.body.ToString(),
+ "!=",
+ this.Props.bodyDef.ToString()
+ }), this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, false);
+ this.blockAction = true;
+ }
+ bool hasAccessList = this.HasAccessList;
+ if (hasAccessList)
+ {
+ bool blackListCompliant = this.BlackListCompliant;
+ bool whiteListCompliant = this.WhiteListCompliant;
+ bool flag3 = !blackListCompliant || !whiteListCompliant;
+ if (flag3)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new string[]
+ {
+ text,
+ this.HasWhiteList ? string.Format("Props.BodyDefWhiteList contains {0} elements", this.Props.bodyDefWhiteList.Count) : "No whitelist",
+ ", compliant: ",
+ whiteListCompliant.ToString(),
+ "; ",
+ this.HasBlackList ? string.Format("Props.BodyDefBlackList contains {0} elements", this.Props.bodyDefBlackList.Count) : "No blacklist",
+ ", compliant:",
+ blackListCompliant.ToString()
+ }));
+ }
+ base.Pawn.DestroyHediff(this.parent, false);
+ this.blockAction = true;
+ }
+ else
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(text + " AccessList compliant ok");
+ }
+ }
+ }
+ bool flag4 = this.Props.hediffAndBodypart.Any((HediffAndBodyPart habp) => habp.bodyPart != null && habp.bodyPartLabel != null);
+ if (flag4)
+ {
+ Tools.Warn(text + "at least one item has both a bodypart def and a bodypart label, label will be prioritized", this.MyDebug);
+ }
+ bool flag5 = this.Props.hediffAndBodypart.Any((HediffAndBodyPart habp) => habp.hediff == null);
+ if (flag5)
+ {
+ Tools.Warn(text + "at least one item has no hediff defined. What will happen ?", this.MyDebug);
+ }
+ }
+
+ public void BlockAndDestroy(string ErrorLog = "", bool myDebug = false)
+ {
+ Tools.Warn(ErrorLog, myDebug && !ErrorLog.NullOrEmpty());
+ this.blockAction = true;
+ Tools.DestroyParentHediff(this.parent, myDebug);
+ }
+
+ public override void CompPostMake()
+ {
+ base.CompPostMake();
+ Tools.Warn(this.DebugStr + "CompPostMake", this.MyDebug);
+ this.CheckProps();
+ }
+
+ public void ApplyHediff(Pawn pawn)
+ {
+ string text = this.DebugStr + "ApplyHediff - ";
+ checked
+ {
+ for (int i = 0; i < this.Props.hediffAndBodypart.Count; i++)
+ {
+ HediffDef hediff = this.Props.hediffAndBodypart[i].hediff;
+ BodyPartDef bodyPart = this.Props.hediffAndBodypart[i].bodyPart;
+ string bodyPartLabel = this.Props.hediffAndBodypart[i].bodyPartLabel;
+ bool prioritizeMissing = this.Props.hediffAndBodypart[i].prioritizeMissing;
+ bool allowMissing = this.Props.hediffAndBodypart[i].allowMissing;
+ bool regenIfMissing = this.Props.hediffAndBodypart[i].regenIfMissing;
+ bool allowAddedPart = this.Props.hediffAndBodypart[i].allowAddedPart;
+ bool wholeBodyFallback = this.Props.hediffAndBodypart[i].wholeBodyFallback;
+ bool flag = hediff == null;
+ if (flag)
+ {
+ Tools.Warn(text + "cant find hediff; i=" + i, true);
+ }
+ else
+ {
+ BodyPartRecord bodyPartRecord = null;
+ bool flag2 = bodyPartLabel != null || bodyPart != null;
+ if (flag2)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ text,
+ "Trying to retrieve BPR with [BP label]:",
+ bodyPartLabel,
+ " [BP def]:",
+ (bodyPart != null) ? bodyPart.defName : null
+ }), this.MyDebug);
+ bodyPartRecord = pawn.GetBPRecordWithoutHediff(bodyPartLabel, bodyPart, hediff, allowMissing, prioritizeMissing, allowAddedPart, this.MyDebug);
+ }
+ bool flag3 = bodyPartRecord == null;
+ if (flag3)
+ {
+ Tools.Warn(text + "Could not find a BPR to apply hediff, will pick whole body?" + wholeBodyFallback.ToString(), this.MyDebug);
+ bool flag4 = !wholeBodyFallback;
+ if (flag4)
+ {
+ goto IL_291;
+ }
+ }
+ bool flag5 = allowMissing && regenIfMissing && bodyPartRecord != null;
+ if (flag5)
+ {
+ Hediff hediff2;
+ bool flag6 = base.Pawn.IsMissingBPR(bodyPartRecord, out hediff2);
+ if (flag6)
+ {
+ Tools.Warn(text + "regenerating " + bodyPartRecord.customLabel, this.MyDebug);
+ base.Pawn.health.RemoveHediff(hediff2);
+ }
+ }
+ Hediff hediff3 = HediffMaker.MakeHediff(hediff, pawn, bodyPartRecord);
+ bool flag7 = hediff3 == null;
+ if (flag7)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ text,
+ "cant create hediff ",
+ hediff.defName,
+ " to apply on ",
+ bodyPart.defName
+ }), true);
+ }
+ else
+ {
+ pawn.health.AddHediff(hediff3, bodyPartRecord, null, null);
+ Tools.Warn(text + "Applied " + hediff.defName, this.MyDebug);
+ }
+ }
+ IL_291:;
+ }
+ }
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ if (!flag)
+ {
+ bool flag2 = this.blockAction;
+ if (flag2)
+ {
+ Tools.DestroyParentHediff(this.parent, this.MyDebug);
+ }
+ else
+ {
+ bool hasHediffToApply = this.HasHediffToApply;
+ if (hasHediffToApply)
+ {
+ this.ApplyHediff(base.Pawn);
+ }
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string empty = string.Empty;
+ return empty + "This should disappear very fast";
+ }
+ }
+
+ private bool blockAction = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_OnTheCarpet.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_OnTheCarpet.cs
new file mode 100644
index 0000000..be43d76
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_OnTheCarpet.cs
@@ -0,0 +1,146 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_OnTheCarpet : HediffComp
+ {
+ public bool HasItems
+ {
+ get
+ {
+ return this.Props.HasHediffPool;
+ }
+ }
+
+ public int ItemCount
+ {
+ get
+ {
+ return this.Props.ItemCount;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public bool IsTimeToCheck
+ {
+ get
+ {
+ return base.Pawn.IsHashIntervalTick(this.Props.checkPeriod);
+ }
+ }
+
+ public HediffCompProperties_OnTheCarpet Props
+ {
+ get
+ {
+ return (HediffCompProperties_OnTheCarpet)this.props;
+ }
+ }
+
+ public void BlockAndDestroy(string ErrorLog = "", bool myDebug = false)
+ {
+ Tools.Warn(ErrorLog, myDebug && !ErrorLog.NullOrEmpty());
+ this.blockAction = true;
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ }
+
+ public override void CompPostMake()
+ {
+ base.CompPostMake();
+ string text = this.MyDebug ? (base.Pawn.LabelShort + " " + this.parent.def.defName + " CompPostMake - ") : "";
+ bool flag = !this.HasItems;
+ if (flag)
+ {
+ Tools.Warn(text + " found no item to work with, destroying ", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ this.blockAction = true;
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ " found ",
+ this.ItemCount,
+ " items to work with"
+ }), this.MyDebug);
+ bool flag2 = !this.Props.IsPawnNeedCompatible(base.Pawn);
+ if (flag2)
+ {
+ Tools.Warn(text + " is not compatible with this hediff, destroying ", this.MyDebug);
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ this.blockAction = true;
+ }
+ else
+ {
+ this.SetGraceTime();
+ Tools.Warn(text + " found something to do", this.MyDebug);
+ }
+ }
+ }
+
+ public void SetGraceTime()
+ {
+ this.graceTime = this.Props.graceTimeBase;
+ }
+
+ public override void CompExposeData()
+ {
+ base.CompExposeData();
+ Scribe_Values.Look(ref this.graceTime, "graceTime", 0, false);
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ base.CompPostTick(ref severityAdjustment);
+ bool flag = base.Pawn.Negligible();
+ if (!flag)
+ {
+ bool flag2 = this.blockAction;
+ if (!flag2)
+ {
+ int num = this.graceTime;
+ this.graceTime = checked(num - 1);
+ bool flag3 = num > 0;
+ if (!flag3)
+ {
+ bool flag4 = false;
+ bool isTimeToCheck = this.IsTimeToCheck;
+ if (isTimeToCheck)
+ {
+ flag4 = !this.TreatRelevantHediffsAndReportIfStillHediffsToCheck();
+ }
+ bool flag5 = flag4;
+ if (flag5)
+ {
+ base.Pawn.DestroyHediff(this.parent, this.MyDebug);
+ }
+ }
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string empty = string.Empty;
+ return empty + "This should not disappear until an hediff is still there";
+ }
+ }
+
+ private bool blockAction = false;
+
+ private int graceTime = 999;
+
+ public bool foundFault = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_PostRemoveTrigger_HediffAdd.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_PostRemoveTrigger_HediffAdd.cs
new file mode 100644
index 0000000..5107726
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_PostRemoveTrigger_HediffAdd.cs
@@ -0,0 +1,99 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_PostRemoveTrigger_HediffAdd : HediffComp
+ {
+ public HediffCompProperties_PostRemoveTrigger_HediffAdd Props
+ {
+ get
+ {
+ return (HediffCompProperties_PostRemoveTrigger_HediffAdd)this.props;
+ }
+ }
+
+ public void CheckProps()
+ {
+ bool flag = !this.HasHediffToApply;
+ if (flag)
+ {
+ this.blockAction = true;
+ Tools.DestroyParentHediff(this.parent, this.Props.debug);
+ }
+ }
+
+ public bool HasHediffToApply
+ {
+ get
+ {
+ return !this.Props.triggeredHediff.NullOrEmpty();
+ }
+ }
+
+ public void ApplyHediff(Pawn pawn)
+ {
+ checked
+ {
+ for (int i = 0; i < this.Props.triggeredHediff.Count; i++)
+ {
+ HediffDef hediffDef = this.Props.triggeredHediff[i];
+ bool flag = hediffDef == null;
+ if (flag)
+ {
+ Tools.Warn("cant find hediff; i=" + i, true);
+ break;
+ }
+ Hediff hediff = HediffMaker.MakeHediff(hediffDef, pawn, null);
+ bool flag2 = hediff == null;
+ if (flag2)
+ {
+ Tools.Warn("cant create hediff " + hediffDef.defName, true);
+ break;
+ }
+ Tools.Warn("Adding " + hediffDef.defName + "for science", this.Props.debug);
+ pawn.health.AddHediff(hediff, null, null, null);
+ }
+ }
+ }
+
+ public override void CompPostPostRemoved()
+ {
+ Pawn pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(pawn);
+ if (flag)
+ {
+ Tools.DestroyParentHediff(this.parent, this.Props.debug);
+ }
+ else
+ {
+ bool flag2 = this.blockAction;
+ if (!flag2)
+ {
+ Tools.Warn(this.parent.def.defName + " is no more, applying hediff", this.Props.debug);
+ bool hasHediffToApply = this.HasHediffToApply;
+ if (hasHediffToApply)
+ {
+ this.ApplyHediff(pawn);
+ }
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string text = string.Empty;
+ bool debug = this.Props.debug;
+ if (debug)
+ {
+ text = text + this.parent.def.defName + " is still alive, aperture science we do what we must";
+ }
+ return text;
+ }
+ }
+
+ private bool blockAction = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RainbowTrail.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RainbowTrail.cs
new file mode 100644
index 0000000..fe998d8
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RainbowTrail.cs
@@ -0,0 +1,514 @@
+using System;
+using System.Collections.Generic;
+using RimWorld;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_RainbowTrail : HediffComp
+ {
+ public HediffCompProperties_RainbowTrail Props
+ {
+ get
+ {
+ return (HediffCompProperties_RainbowTrail)this.props;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ bool hideBySeverity = this.Props.hideBySeverity;
+ if (hideBySeverity)
+ {
+ this.parent.Severity = 0.05f;
+ }
+ this.myDebug = this.Props.debug;
+ this.Init(this.myDebug);
+ }
+
+ public override void CompExposeData()
+ {
+ Scribe_Values.Look(ref this.ticksLeft, "ticksLeft", 0, false);
+ Scribe_Values.Look(ref this.curColor, "curColor", HediffComp_RainbowTrail.RainbowColor.purple, false);
+ Scribe_Values.Look(ref this.variation, "variation", 0, false);
+ Scribe_Values.Look(ref this.myDebug, "debug", false, false);
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ this.SetPawnAndMap();
+ bool flag = this.myPawn == null || this.myMap == null || this.blockAction;
+ checked
+ {
+ if (flag)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ "null tick - pawn: ",
+ (this.myPawn == null).ToString(),
+ "myMap: ",
+ (this.myMap == null).ToString(),
+ "blockAction: ",
+ this.blockAction.ToString()
+ }), this.myDebug);
+ }
+ else
+ {
+ bool flag2 = this.moteDef.NullOrEmpty();
+ if (flag2)
+ {
+ Tools.Warn("empty moteDef", this.myDebug);
+ this.Init(this.myDebug);
+ }
+ TerrainDef terrain = this.myPawn.Position.GetTerrain(this.myPawn.Map);
+ bool flag3 = terrain == null || terrain.IsWater || this.myPawn.Map.snowGrid.GetDepth(this.myPawn.Position) >= 0.4f || !this.myPawn.Position.InBounds(this.myMap);
+ if (flag3)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ this.myPawn,
+ "'s ",
+ this.parent.def.defName,
+ " is blocked by terrain"
+ }), this.myDebug);
+ }
+ else
+ {
+ bool flag4 = this.ticksLeft <= 0;
+ if (flag4)
+ {
+ bool flag5 = this.TryPlaceMote();
+ if (flag5)
+ {
+ this.sameColorInRow++;
+ bool flag6 = this.sameColorInRow >= this.Props.minTimesSameColor || this.sameColorInRow > this.Props.maxTimesSameColor || !Rand.Chance(this.Props.staySameColorChance);
+ if (flag6)
+ {
+ bool threeColorsGradient = this.Props.threeColorsGradient;
+ if (threeColorsGradient)
+ {
+ this.NextColorThreeColors();
+ }
+ else
+ {
+ this.NextColorRainbow();
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ this.myPawn,
+ "'s ",
+ this.parent.def.defName,
+ " now uses ",
+ this.curColor,
+ "after ",
+ this.sameColorInRow,
+ "puddles"
+ }), this.myDebug);
+ this.SetMoteDef();
+ this.sameColorInRow = 0;
+ }
+ this.Reset();
+ }
+ else
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ this.myPawn,
+ "'s ",
+ this.parent.def.defName,
+ "failed to TryPlaceMote"
+ }), this.myDebug);
+ }
+ }
+ else
+ {
+ this.ticksLeft--;
+ }
+ }
+ }
+ }
+ }
+
+ public void SetMoteDef()
+ {
+ switch (this.curColor)
+ {
+ case HediffComp_RainbowTrail.RainbowColor.purple:
+ this.moteDef = this.Props.motePurpleDef;
+ break;
+ case HediffComp_RainbowTrail.RainbowColor.blue:
+ this.moteDef = this.Props.moteBlueDef;
+ break;
+ case HediffComp_RainbowTrail.RainbowColor.green:
+ this.moteDef = this.Props.moteGreenDef;
+ break;
+ case HediffComp_RainbowTrail.RainbowColor.yellow:
+ this.moteDef = this.Props.moteYellowDef;
+ break;
+ case HediffComp_RainbowTrail.RainbowColor.orange:
+ this.moteDef = this.Props.moteOrangeDef;
+ break;
+ case HediffComp_RainbowTrail.RainbowColor.red:
+ this.moteDef = this.Props.moteRedDef;
+ break;
+ }
+ }
+
+ public void NextColorRainbow()
+ {
+ checked
+ {
+ this.curColor += this.variation;
+ bool flag = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.circular;
+ if (flag)
+ {
+ bool flag2 = this.curColor > HediffComp_RainbowTrail.RainbowColor.red;
+ if (flag2)
+ {
+ this.curColor = HediffComp_RainbowTrail.RainbowColor.purple;
+ }
+ else
+ {
+ bool flag3 = this.curColor < HediffComp_RainbowTrail.RainbowColor.purple;
+ if (flag3)
+ {
+ this.curColor = HediffComp_RainbowTrail.RainbowColor.red;
+ }
+ }
+ }
+ else
+ {
+ bool flag4 = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.bouncing;
+ if (flag4)
+ {
+ bool flag5 = this.curColor > HediffComp_RainbowTrail.RainbowColor.red;
+ if (flag5)
+ {
+ this.variation = -1;
+ this.curColor = HediffComp_RainbowTrail.RainbowColor.orange;
+ }
+ else
+ {
+ bool flag6 = this.curColor < HediffComp_RainbowTrail.RainbowColor.purple;
+ if (flag6)
+ {
+ this.variation = 1;
+ this.curColor = HediffComp_RainbowTrail.RainbowColor.blue;
+ }
+ }
+ }
+ else
+ {
+ bool flag7 = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.random;
+ if (flag7)
+ {
+ this.curColor = (HediffComp_RainbowTrail.RainbowColor)Rand.Range(0, 6);
+ }
+ }
+ }
+ }
+ }
+
+ public void NextColorThreeColors()
+ {
+ checked
+ {
+ this.curColor += this.variation;
+ bool flag = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.circular;
+ if (flag)
+ {
+ bool flag2 = this.curColor > this.topColor;
+ if (flag2)
+ {
+ this.curColor = this.bottomColor;
+ }
+ else
+ {
+ bool flag3 = this.curColor < this.bottomColor;
+ if (flag3)
+ {
+ this.curColor = this.topColor;
+ }
+ }
+ }
+ else
+ {
+ bool flag4 = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.bouncing;
+ if (flag4)
+ {
+ bool flag5 = this.curColor > this.topColor;
+ if (flag5)
+ {
+ this.variation = -1;
+ this.curColor = this.pivotColor;
+ }
+ else
+ {
+ bool flag6 = this.curColor < HediffComp_RainbowTrail.RainbowColor.purple;
+ if (flag6)
+ {
+ this.variation = 1;
+ this.curColor = this.pivotColor;
+ }
+ }
+ }
+ else
+ {
+ bool flag7 = this.Props.cycleKind == HediffComp_RainbowTrail.CycleKind.random;
+ if (flag7)
+ {
+ bool flag8 = Rand.Chance(0.33f);
+ if (flag8)
+ {
+ this.curColor = this.pivotColor;
+ }
+ else
+ {
+ bool flag9 = Rand.Chance(0.5f);
+ if (flag9)
+ {
+ this.curColor = this.topColor;
+ }
+ else
+ {
+ this.curColor = this.bottomColor;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void SetPawnAndMap()
+ {
+ this.myPawn = this.parent.pawn;
+ this.myMap = this.myPawn.Map;
+ }
+
+ public HediffComp_RainbowTrail.RainbowColor ColorTranslation(Color myColor)
+ {
+ bool flag = myColor == MyGfx.Purple;
+ HediffComp_RainbowTrail.RainbowColor result;
+ if (flag)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.purple;
+ }
+ else
+ {
+ bool flag2 = myColor == MyGfx.Blue;
+ if (flag2)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.blue;
+ }
+ else
+ {
+ bool flag3 = myColor == MyGfx.Green;
+ if (flag3)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.green;
+ }
+ else
+ {
+ bool flag4 = myColor == MyGfx.Yellow;
+ if (flag4)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.yellow;
+ }
+ else
+ {
+ bool flag5 = myColor == MyGfx.Orange;
+ if (flag5)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.orange;
+ }
+ else
+ {
+ bool flag6 = myColor == MyGfx.Red;
+ if (flag6)
+ {
+ result = HediffComp_RainbowTrail.RainbowColor.red;
+ }
+ else
+ {
+ Tools.Warn(this.myPawn.LabelShort + " could not ColorTranslation, default value", this.myDebug);
+ result = HediffComp_RainbowTrail.RainbowColor.blue;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public void Init(bool myDebug = false)
+ {
+ this.SetPawnAndMap();
+ Tools.Warn(string.Concat(new object[]
+ {
+ this.myPawn,
+ "'s ",
+ this.parent.def.defName,
+ " Init"
+ }), myDebug);
+ bool flag = this.Props.motePurpleDef.NullOrEmpty() || this.Props.moteBlueDef.NullOrEmpty() || this.Props.moteGreenDef.NullOrEmpty() || this.Props.moteYellowDef.NullOrEmpty() || this.Props.moteOrangeDef.NullOrEmpty() || this.Props.moteRedDef.NullOrEmpty();
+ if (flag)
+ {
+ this.blockAction = true;
+ this.parent.Severity = 0f;
+ }
+ switch (this.Props.colorChoice)
+ {
+ case HediffComp_RainbowTrail.ColorChoice.pawnColor:
+ {
+ Color myColor = GfxEffects.ClosestColor(this.myPawn, false, myDebug);
+ this.pivotColor = (this.curColor = this.ColorTranslation(myColor));
+ break;
+ }
+ case HediffComp_RainbowTrail.ColorChoice.complementary:
+ {
+ Color myColor2 = GfxEffects.ClosestColor(this.myPawn, true, myDebug);
+ this.pivotColor = (this.curColor = this.ColorTranslation(myColor2));
+ break;
+ }
+ case HediffComp_RainbowTrail.ColorChoice.random:
+ this.pivotColor = (this.curColor = (HediffComp_RainbowTrail.RainbowColor)Rand.Range(0, 6));
+ break;
+ }
+ checked
+ {
+ this.bottomColor = this.pivotColor - 1;
+ this.topColor = this.pivotColor + 1;
+ bool flag2 = this.topColor > HediffComp_RainbowTrail.RainbowColor.red;
+ if (flag2)
+ {
+ this.topColor = HediffComp_RainbowTrail.RainbowColor.purple;
+ }
+ bool flag3 = this.bottomColor < HediffComp_RainbowTrail.RainbowColor.purple;
+ if (flag3)
+ {
+ this.bottomColor = HediffComp_RainbowTrail.RainbowColor.red;
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ this.myPawn,
+ "'s ",
+ this.parent.def.defName,
+ " bottom: ",
+ this.bottomColor,
+ " pivot: ",
+ this.pivotColor,
+ " top: ",
+ this.topColor
+ }), myDebug);
+ this.SetMoteDef();
+ }
+ }
+
+ public static void PlacePuddle(Vector3 loc, Map map, float rot, float scale, ThingDef Mote_FootprintDef)
+ {
+ bool flag = !loc.ShouldSpawnMotesAt(map, true) || map.moteCounter.SaturatedLowPriority;
+ if (!flag)
+ {
+ MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(Mote_FootprintDef, null);
+ moteThrown.Scale = scale;
+ moteThrown.exactRotation = rot;
+ moteThrown.exactPosition = loc;
+ GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);
+ }
+ }
+
+ private bool TryPlaceMote()
+ {
+ Vector3 drawPos = this.myPawn.Drawer.DrawPos;
+ Vector3 normalized = (drawPos - this.lastFootprintPlacePos).normalized;
+ float rot = normalized.AngleFlat();
+ Vector3 vector = this.myPawn.TrueCenter() + HediffComp_RainbowTrail.PuddleOffset;
+ IntVec3 c = vector.ToIntVec3();
+ bool flag = c.InBounds(this.myMap);
+ if (flag)
+ {
+ TerrainDef terrain = c.GetTerrain(this.myPawn.Map);
+ bool flag2 = terrain != null;
+ if (flag2)
+ {
+ HediffComp_RainbowTrail.PlacePuddle(vector, this.myMap, rot, this.Props.scale.RandomInRange, this.moteDef.RandomElement());
+ return true;
+ }
+ }
+ this.lastFootprintPlacePos = drawPos;
+ return false;
+ }
+
+ private void Reset()
+ {
+ this.ticksLeft = this.Props.period;
+ }
+
+ private Pawn myPawn = null;
+
+ private Map myMap = null;
+
+ private Vector3 lastFootprintPlacePos;
+
+ private static readonly Vector3 PuddleOffset = new Vector3(0f, 0f, -0.3f);
+
+ private int ticksLeft;
+
+ private List moteDef = null;
+
+ private HediffComp_RainbowTrail.RainbowColor curColor = HediffComp_RainbowTrail.RainbowColor.purple;
+
+ private int sameColorInRow = 0;
+
+ public HediffComp_RainbowTrail.RainbowColor bottomColor;
+
+ public HediffComp_RainbowTrail.RainbowColor pivotColor;
+
+ public HediffComp_RainbowTrail.RainbowColor topColor;
+
+ private int variation = 1;
+
+ private bool blockAction = false;
+
+ private bool myDebug = false;
+
+ public enum RainbowColor
+ {
+ [Description("purple")]
+ purple,
+ [Description("blue")]
+ blue,
+ [Description("green")]
+ green,
+ [Description("yellow")]
+ yellow,
+ [Description("orange")]
+ orange,
+ [Description("red")]
+ red
+ }
+
+ public enum ColorChoice
+ {
+ [Description("pawnColor")]
+ pawnColor,
+ [Description("complementary")]
+ complementary,
+ [Description("random")]
+ random
+ }
+
+ public enum CycleKind
+ {
+ [Description("circular")]
+ circular,
+ [Description("bouncing")]
+ bouncing,
+ [Description("random")]
+ random
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawnUponDeath.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawnUponDeath.cs
new file mode 100644
index 0000000..893ed2e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawnUponDeath.cs
@@ -0,0 +1,587 @@
+using System;
+using System.Collections.Generic;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_RandySpawnUponDeath : HediffComp
+ {
+ public HediffCompProperties_RandySpawnUponDeath Props
+ {
+ get
+ {
+ return (HediffCompProperties_RandySpawnUponDeath)this.props;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public bool ValidIndex
+ {
+ get
+ {
+ return this.RandomIndex != -1 && this.Props.settings.HasSomethingToSpawn && this.RandomIndex < this.NumberOfItems;
+ }
+ }
+
+ public bool ValidQuantity
+ {
+ get
+ {
+ return this.RandomQuantity > 0;
+ }
+ }
+
+ public ThingSettings ChosenItem
+ {
+ get
+ {
+ return this.ValidIndex ? this.Props.settings.things[this.RandomIndex] : null;
+ }
+ }
+
+ public bool HasRequirement
+ {
+ get
+ {
+ return this.Props.HasRequirements && this.Props.requirements.HasAtLeastOneRequirementSetting;
+ }
+ }
+
+ public bool HasHediffRequirement
+ {
+ get
+ {
+ return this.Props.HasRequirements && this.Props.requirements.HasHediffRequirement;
+ }
+ }
+
+ public bool HasThingRequirement
+ {
+ get
+ {
+ return this.Props.HasRequirements && this.Props.requirements.HasThingRequirement;
+ }
+ }
+
+ public bool HasCustomSpawn
+ {
+ get
+ {
+ bool result;
+ if (this.HasThingRequirement)
+ {
+ result = this.Props.requirements.thing.Any((ThingRequirementSettings t) => t.HasCustomSpawn);
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ public bool HasContainerSpawn
+ {
+ get
+ {
+ bool result;
+ if (this.HasThingRequirement)
+ {
+ result = this.Props.requirements.thing.Any((ThingRequirementSettings t) => t.HasContainerSpawn);
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ public bool HasChosenThing
+ {
+ get
+ {
+ return this.ChosenItem != null && this.ChosenItem.thingToSpawn != null;
+ }
+ }
+
+ public bool HasChosenPawn
+ {
+ get
+ {
+ return this.ChosenItem != null && (this.ChosenItem.pawnKindToSpawn != null || this.IsParentPawnKindCopier);
+ }
+ }
+
+ public bool IsParentPawnKindCopier
+ {
+ get
+ {
+ return this.ChosenItem.IsCopier && this.ChosenItem.copyParent.pawnKind;
+ }
+ }
+
+ public bool PrecedentIterationsExclusion
+ {
+ get
+ {
+ return this.Props.excludeAlreadyPickedOptions;
+ }
+ }
+
+ public bool HasColorCondition
+ {
+ get
+ {
+ return this.Props.settings.things.Any((ThingSettings t) => t.HasColorCondition);
+ }
+ }
+
+ public ThingDef ThingOfChoice
+ {
+ get
+ {
+ return this.HasChosenThing ? this.ChosenItem.thingToSpawn : null;
+ }
+ }
+
+ public List FullOptionList
+ {
+ get
+ {
+ return this.Props.settings.things;
+ }
+ }
+
+ public PawnKindDef PawnOfChoice
+ {
+ get
+ {
+ bool flag = !this.HasChosenPawn;
+ PawnKindDef result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ bool isParentPawnKindCopier = this.IsParentPawnKindCopier;
+ if (isParentPawnKindCopier)
+ {
+ result = base.Pawn.kindDef;
+ }
+ else
+ {
+ result = this.ChosenItem.pawnKindToSpawn;
+ }
+ }
+ return result;
+ }
+ }
+
+ public bool HasFilth
+ {
+ get
+ {
+ return this.FilthToSpawn != null;
+ }
+ }
+
+ public int NumberOfItems
+ {
+ get
+ {
+ return this.Props.settings.things.Count;
+ }
+ }
+
+ public int NumberToSpawn
+ {
+ get
+ {
+ bool flag = this.HasChosenThing && this.ChosenItem.HasStackSettings;
+ int result;
+ if (flag)
+ {
+ result = this.ChosenItem.specificSettings.stack.spawnCount.RandomInRange;
+ }
+ else
+ {
+ bool hasDefaultSettings = this.Props.settings.HasDefaultSettings;
+ if (hasDefaultSettings)
+ {
+ result = this.Props.settings.defaultSettings.stack.spawnCount.RandomInRange;
+ }
+ else
+ {
+ result = 1;
+ }
+ }
+ return result;
+ }
+ }
+
+ public bool WeightedSpawn
+ {
+ get
+ {
+ bool flag = this.HasChosenThing && this.ChosenItem.HasStackSettings;
+ bool result;
+ if (flag)
+ {
+ result = this.ChosenItem.specificSettings.stack.weightedSpawnCount;
+ }
+ else
+ {
+ bool hasDefaultSettings = this.Props.settings.HasDefaultSettings;
+ result = (hasDefaultSettings && this.Props.settings.defaultSettings.stack.weightedSpawnCount);
+ }
+ return result;
+ }
+ }
+
+ public ThingDef FilthToSpawn
+ {
+ get
+ {
+ bool flag = this.HasChosenThing && this.ChosenItem.HasFilthSettings;
+ ThingDef result;
+ if (flag)
+ {
+ result = this.ChosenItem.specificSettings.filth.filthDef;
+ }
+ else
+ {
+ bool hasDefaultSettings = this.Props.settings.HasDefaultSettings;
+ if (hasDefaultSettings)
+ {
+ result = this.Props.settings.defaultSettings.filth.filthDef;
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ return result;
+ }
+ }
+
+ public FloatRange FilthRadius
+ {
+ get
+ {
+ bool flag = this.HasChosenThing && this.ChosenItem.HasFilthSettings;
+ FloatRange result;
+ if (flag)
+ {
+ result = this.ChosenItem.specificSettings.filth.filthRadius;
+ }
+ else
+ {
+ bool hasDefaultSettings = this.Props.settings.HasDefaultSettings;
+ if (hasDefaultSettings)
+ {
+ result = this.Props.settings.defaultSettings.filth.filthRadius;
+ }
+ else
+ {
+ result = new FloatRange(0f, 1f);
+ }
+ }
+ return result;
+ }
+ }
+
+ public IntRange FilthNum
+ {
+ get
+ {
+ bool flag = this.HasChosenThing && this.ChosenItem.HasFilthSettings;
+ IntRange result;
+ if (flag)
+ {
+ result = this.ChosenItem.specificSettings.filth.filthNum;
+ }
+ else
+ {
+ bool hasDefaultSettings = this.Props.settings.HasDefaultSettings;
+ if (hasDefaultSettings)
+ {
+ result = this.Props.settings.defaultSettings.filth.filthNum;
+ }
+ else
+ {
+ result = new IntRange(0, 0);
+ }
+ }
+ return result;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ string[] array = new string[5];
+ array[0] = ">>> ";
+ int num = 1;
+ Pawn pawn = base.Pawn;
+ array[num] = ((pawn != null) ? pawn.Label : null);
+ array[2] = " - ";
+ array[3] = this.parent.def.defName;
+ array[4] = " - CompPostMake start";
+ Log.Warning(string.Concat(array));
+ }
+ }
+
+ public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
+ {
+ string text = this.MyDebug ? (base.Pawn.LabelShort + " HediffComp_RandySpawnUponDeath Notify_PawnDied") : "";
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(text + " Entering");
+ }
+ bool flag = false;
+ bool flag2 = base.Pawn.Corpse.Negligible();
+ if (flag2)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(text + " Corpse is no more, cant find its position - giving up");
+ }
+ flag = true;
+ }
+ bool flag3 = this.blockSpawn;
+ if (flag3)
+ {
+ bool myDebug3 = this.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning(text + " blockSpawn for some reason- giving up");
+ }
+ flag = true;
+ }
+ Thing closestThing;
+ bool flag4 = !this.FulfilsRequirement(out closestThing);
+ if (flag4)
+ {
+ bool myDebug4 = this.MyDebug;
+ if (myDebug4)
+ {
+ Log.Warning(text + "not Fulfiling requirements- giving up");
+ }
+ flag = true;
+ }
+ bool flag5 = flag;
+ checked
+ {
+ if (flag5)
+ {
+ base.Notify_PawnDied(dinfo, culprit);
+ }
+ else
+ {
+ int randomInRange = this.Props.iterationRange.RandomInRange;
+ List list = new List();
+ bool myDebug5 = this.MyDebug;
+ if (myDebug5)
+ {
+ Log.Warning(text + "iterationNum: " + randomInRange);
+ }
+ for (int i = 0; i < randomInRange; i++)
+ {
+ bool myDebug6 = this.MyDebug;
+ if (myDebug6)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " Trying to spawn ",
+ i,
+ "/",
+ randomInRange - 1
+ }));
+ }
+ bool flag6 = !this.DiceThrow(list);
+ if (flag6)
+ {
+ bool myDebug7 = this.MyDebug;
+ if (myDebug7)
+ {
+ Log.Warning(text + " DiceThrow wrong results");
+ }
+ base.Notify_PawnDied(dinfo, culprit);
+ return;
+ }
+ bool myDebug8 = this.MyDebug;
+ if (myDebug8)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " index: ",
+ this.RandomIndex,
+ " quantity: ",
+ this.RandomQuantity,
+ " nature: ",
+ this.ChosenItem.ItemDump
+ }));
+ }
+ bool precedentIterationsExclusion = this.PrecedentIterationsExclusion;
+ if (precedentIterationsExclusion)
+ {
+ list.Add(this.RandomIndex);
+ }
+ bool flag7 = this.CheckShouldSpawn(closestThing);
+ if (flag7)
+ {
+ bool myDebug9 = this.MyDebug;
+ if (myDebug9)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " Spawn ",
+ i,
+ "/",
+ randomInRange - 1,
+ " occured nature: t:",
+ this.ChosenItem.ItemDump
+ }));
+ }
+ }
+ bool myDebug10 = this.MyDebug;
+ if (myDebug10)
+ {
+ Log.Warning("#################");
+ }
+ }
+ bool flag8 = this.CheckShouldHandleCorpse();
+ if (flag8)
+ {
+ bool myDebug11 = this.MyDebug;
+ if (myDebug11)
+ {
+ Log.Warning(text + " Corpse handled");
+ }
+ }
+ base.Notify_PawnDied(dinfo, culprit);
+ }
+ }
+ }
+
+ public bool DiceThrow(List AlreadyPickedOptions)
+ {
+ this.RandomIndex = this.GetWeightedRandomIndex(AlreadyPickedOptions);
+ bool flag = this.HasChosenPawn && this.ChosenItem.HasFactionParams;
+ if (flag)
+ {
+ this.ComputeRandomFaction();
+ }
+ this.RandomQuantity = this.ComputeSpawnCount();
+ bool flag2 = !this.ValidIndex;
+ bool result;
+ if (flag2)
+ {
+ this.BlockAndDestroy(">ERROR< failed to find an index for IP, check and adjust your hediff props", this.MyDebug);
+ result = false;
+ }
+ else
+ {
+ bool flag3 = !this.ValidQuantity;
+ if (flag3)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("random quantity: " + this.RandomQuantity + " - impossible to spawn anything");
+ }
+ result = false;
+ }
+ else
+ {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ public void BlockAndDestroy(string ErrorLog = "", bool myDebug = false)
+ {
+ bool flag = this.MyDebug && !ErrorLog.NullOrEmpty();
+ if (flag)
+ {
+ Log.Warning(ErrorLog);
+ }
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, myDebug);
+ }
+
+ private bool CheckShouldSpawn(Thing closestThing)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(base.Pawn.LabelShort + " CheckShouldSpawn");
+ }
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ " Trying to spawn ",
+ this.RandomQuantity,
+ " ",
+ this.ThingOfChoice,
+ "/",
+ this.PawnOfChoice
+ }));
+ }
+ Thing thing = this.HasCustomSpawn ? closestThing : base.Pawn.Corpse;
+ bool result = this.TryDoSpawn(thing, this.RandomQuantity);
+ bool myDebug3 = this.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning("TryDoSpawn: " + result.ToString());
+ }
+ return result;
+ }
+
+ private bool CheckShouldHandleCorpse()
+ {
+ Corpse corpse = base.Pawn.Corpse;
+ bool flag = false;
+ flag |= this.StripCorpse(corpse);
+ return flag | this.DestroyCorpse(corpse);
+ }
+
+ private bool blockSpawn = false;
+
+ private int RandomIndex = -1;
+
+ public Faction RandomFaction = null;
+
+ public MentalStateDef RandomMS = null;
+
+ private int RandomQuantity = 0;
+
+ public readonly float minDaysB4NextErrorLimit = 0.001f;
+
+ public readonly int spawnCountErrorLimit = 750;
+
+ public Pawn_SkillTracker rememberSkillTracker = null;
+
+ public int lastSkillUpdateTick = -1;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawner.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawner.cs
new file mode 100644
index 0000000..beea1ea
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_RandySpawner.cs
@@ -0,0 +1,450 @@
+using System;
+using System.Collections.Generic;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_RandySpawner : HediffComp
+ {
+ public HediffCompProperties_RandySpawner Props
+ {
+ get
+ {
+ return (HediffCompProperties_RandySpawner)this.props;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public bool HasGraceDelay
+ {
+ get
+ {
+ return this.graceTicks > 0;
+ }
+ }
+
+ private float CalculatedDaysB4Next
+ {
+ get
+ {
+ return (float)this.ticksUntilSpawn / 60000f;
+ }
+ }
+
+ public ItemParameter CurIP
+ {
+ get
+ {
+ return (this.pickedItem != -1 && !this.Props.itemParameters.NullOrEmpty() && this.pickedItem < this.Props.itemParameters.Count) ? this.Props.itemParameters[this.pickedItem] : null;
+ }
+ }
+
+ public bool HasValidIP
+ {
+ get
+ {
+ return this.CurIP != null;
+ }
+ }
+
+ public bool RequiresFood
+ {
+ get
+ {
+ return this.Props.hungerRelative && base.Pawn.IsHungry(this.MyDebug);
+ }
+ }
+
+ public bool RequiresHealth
+ {
+ get
+ {
+ return this.Props.healthRelative && base.Pawn.IsInjured(this.MyDebug);
+ }
+ }
+
+ public override void CompExposeData()
+ {
+ Scribe_Values.Look(ref this.ticksUntilSpawn, "ticksUntilSpawn", 0, false);
+ Scribe_Values.Look(ref this.initialTicksUntilSpawn, "initialTicksUntilSpawn", 0, false);
+ Scribe_Values.Look(ref this.calculatedQuantity, "calculatedQuantity", 0, false);
+ Scribe_Values.Look(ref this.hungerReset, "LTF_hungerReset", 0, false);
+ Scribe_Values.Look(ref this.healthReset, "LTF_healthReset", 0, false);
+ Scribe_Values.Look(ref this.graceTicks, "graceTicks", 0, false);
+ Scribe_Values.Look(ref this.pickedItem, "pickedItem", 0, false);
+ }
+
+ public override void CompPostMake()
+ {
+ string[] array = new string[5];
+ array[0] = ">>> ";
+ int num = 1;
+ Pawn pawn = base.Pawn;
+ array[num] = ((pawn != null) ? pawn.Label : null);
+ array[2] = " - ";
+ array[3] = this.parent.def.defName;
+ array[4] = " - CompPostMake start";
+ Tools.Warn(string.Concat(array), this.MyDebug);
+ this.DumpProps();
+ this.CheckProps();
+ this.CalculateValues();
+ this.CheckCalculatedValues();
+ this.DumpCalculatedValues();
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ checked
+ {
+ if (!flag)
+ {
+ bool flag2 = this.blockSpawn;
+ if (!flag2)
+ {
+ bool hasGraceDelay = this.HasGraceDelay;
+ if (hasGraceDelay)
+ {
+ this.graceTicks--;
+ }
+ else
+ {
+ bool flag3 = this.SetRequirementGraceTicks();
+ if (!flag3)
+ {
+ bool flag4 = this.CheckShouldSpawn();
+ if (flag4)
+ {
+ Tools.Warn("Reseting countdown bc spawned thing", this.MyDebug);
+ this.CalculateValues();
+ this.CheckCalculatedValues();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void CalculateValues()
+ {
+ this.pickedItem = this.GetWeightedRandomIndex();
+ bool hasValidIP = this.HasValidIP;
+ if (hasValidIP)
+ {
+ this.CurIP.ComputeRandomParameters(out this.ticksUntilSpawn, out this.graceTicks, out this.calculatedQuantity);
+ bool hasFactionParams = this.CurIP.HasFactionParams;
+ if (hasFactionParams)
+ {
+ this.ComputeRandomFaction();
+ }
+ }
+ else
+ {
+ this.BlockAndDestroy(">ERROR< failed to find an index for IP, check and adjust your hediff props", this.MyDebug);
+ }
+ }
+
+ private void CheckCalculatedValues()
+ {
+ bool flag = this.calculatedQuantity > this.spawnCountErrorLimit;
+ if (flag)
+ {
+ this.BlockAndDestroy(string.Concat(new object[]
+ {
+ ">ERROR< calculatedQuantity is too high: ",
+ this.calculatedQuantity,
+ "(>",
+ this.spawnCountErrorLimit,
+ "), check and adjust your hediff props"
+ }), this.MyDebug);
+ }
+ else
+ {
+ bool flag2 = this.CalculatedDaysB4Next < this.minDaysB4NextErrorLimit;
+ if (flag2)
+ {
+ this.BlockAndDestroy(string.Concat(new object[]
+ {
+ ">ERROR< calculatedMinDaysB4Next is too low: ",
+ this.CalculatedDaysB4Next,
+ "(<",
+ this.minDaysB4NextErrorLimit,
+ "), check and adjust your hediff props"
+ }), this.MyDebug);
+ }
+ }
+ }
+
+ private void DumpCalculatedValues()
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "<<< calculatedDaysB4Next: ",
+ this.CalculatedDaysB4Next,
+ "; CalculatedQuantity: ",
+ this.calculatedQuantity,
+ "; "
+ }), this.MyDebug);
+ }
+
+ public void BlockAndDestroy(string ErrorLog = "", bool myDebug = false)
+ {
+ Tools.Warn(ErrorLog, myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, myDebug);
+ }
+
+ private bool CheckShouldSpawn()
+ {
+ checked
+ {
+ this.ticksUntilSpawn--;
+ bool flag = this.ticksUntilSpawn <= 0;
+ bool result;
+ if (flag)
+ {
+ bool flag2 = this.TryDoSpawn();
+ Tools.Warn("TryDoSpawn: " + flag2.ToString(), this.MyDebug);
+ bool flag3 = flag2;
+ if (flag3)
+ {
+ this.pickedItem = -1;
+ }
+ result = flag2;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ public bool TrySpawnPawn()
+ {
+ PawnGenerationRequest request = new PawnGenerationRequest(this.CurIP.pawnKindToSpawn, this.Itemfaction, PawnGenerationContext.NonPlayer, -1, false, this.newBorn, false, true, false, 1f, false, true, false, true, true, false, false, false, false, 0f, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null, false, false, false, false, null, null, null, null, null, 0f, DevelopmentalStage.Adult, null, null, null, false, false, false, -1, 0, false);
+ checked
+ {
+ for (int i = 0; i < this.calculatedQuantity; i++)
+ {
+ Pawn newThing = PawnGenerator.GeneratePawn(request);
+ GenSpawn.Spawn(newThing, base.Pawn.Position, base.Pawn.Map, WipeMode.Vanish);
+ bool hasFilth = this.CurIP.HasFilth;
+ if (hasFilth)
+ {
+ FilthMaker.TryMakeFilth(this.parent.pawn.Position, this.parent.pawn.Map, this.CurIP.filthDef, 1, FilthSourceFlags.None, true);
+ }
+ }
+ return true;
+ }
+ }
+
+ public bool TryDoSpawn()
+ {
+ bool flag = base.Pawn.Negligible();
+ checked
+ {
+ bool result;
+ if (flag)
+ {
+ Tools.Warn("TryDoSpawn - pawn null", this.MyDebug);
+ result = false;
+ }
+ else
+ {
+ bool pawnSpawner = this.CurIP.PawnSpawner;
+ if (pawnSpawner)
+ {
+ result = this.TrySpawnPawn();
+ }
+ else
+ {
+ bool thingSpawner = this.CurIP.ThingSpawner;
+ if (thingSpawner)
+ {
+ bool flag2 = this.Props.spawnMaxAdjacent >= 0;
+ if (flag2)
+ {
+ int num = 0;
+ for (int i = 0; i < 9; i++)
+ {
+ IntVec3 c = base.Pawn.Position + GenAdj.AdjacentCellsAndInside[i];
+ bool flag3 = !c.InBounds(base.Pawn.Map);
+ if (!flag3)
+ {
+ List thingList = c.GetThingList(base.Pawn.Map);
+ for (int j = 0; j < thingList.Count; j++)
+ {
+ bool flag4 = thingList[j].def == this.CurIP.thingToSpawn;
+ if (flag4)
+ {
+ num += thingList[j].stackCount;
+ bool flag5 = num >= this.Props.spawnMaxAdjacent;
+ if (flag5)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ int k = 0;
+ int num2 = this.calculatedQuantity;
+ int num3 = 0;
+ while (k < this.calculatedQuantity)
+ {
+ IntVec3 intVec;
+ bool flag6 = this.TryFindSpawnCell(out intVec);
+ if (flag6)
+ {
+ Thing thing = ThingMaker.MakeThing(this.CurIP.thingToSpawn, null);
+ thing.stackCount = num2;
+ bool flag7 = thing.def.stackLimit > 0;
+ if (flag7)
+ {
+ bool flag8 = thing.stackCount > thing.def.stackLimit;
+ if (flag8)
+ {
+ thing.stackCount = thing.def.stackLimit;
+ }
+ }
+ k += thing.stackCount;
+ num2 -= thing.stackCount;
+ Thing t;
+ GenPlace.TryPlaceThing(thing, intVec, base.Pawn.Map, ThingPlaceMode.Direct, ref t, null, null, default(Rot4));
+ bool spawnForbidden = this.Props.spawnForbidden;
+ if (spawnForbidden)
+ {
+ t.SetForbidden(true, true);
+ }
+ }
+ bool flag9 = num3++ > 10;
+ if (flag9)
+ {
+ Tools.Warn("Had to break the loop", this.MyDebug);
+ return false;
+ }
+ }
+ bool flag10 = num2 <= 0;
+ result = flag10;
+ }
+ }
+ return result;
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string text = string.Empty;
+ bool flag = !this.HasValidIP || !this.Props.logNextSpawn;
+ string result;
+ if (flag)
+ {
+ result = text;
+ }
+ else
+ {
+ bool hasGraceDelay = this.HasGraceDelay;
+ if (hasGraceDelay)
+ {
+ bool pawnSpawner = this.CurIP.PawnSpawner;
+ if (pawnSpawner)
+ {
+ text = " No " + this.CurIP.pawnKindToSpawn.label + " for " + this.graceTicks.ToStringTicksToPeriod(true, false, true, true, false);
+ }
+ else
+ {
+ bool thingSpawner = this.CurIP.ThingSpawner;
+ if (thingSpawner)
+ {
+ text = " No " + this.CurIP.thingToSpawn.label + " for " + this.graceTicks.ToStringTicksToPeriod(true, false, true, true, false);
+ }
+ }
+ bool flag2 = this.hungerReset > 0;
+ if (flag2)
+ {
+ text += "(hunger)";
+ }
+ else
+ {
+ bool flag3 = this.healthReset > 0;
+ if (flag3)
+ {
+ text += "(injury)";
+ }
+ else
+ {
+ text += "(grace period)";
+ }
+ }
+ }
+ else
+ {
+ text = this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true, false) + " before ";
+ bool pawnSpawner2 = this.CurIP.PawnSpawner;
+ if (pawnSpawner2)
+ {
+ text += this.CurIP.pawnKindToSpawn.label;
+ }
+ else
+ {
+ bool thingSpawner2 = this.CurIP.ThingSpawner;
+ if (thingSpawner2)
+ {
+ text += this.CurIP.thingToSpawn.label;
+ }
+ }
+ text = string.Concat(new object[]
+ {
+ text,
+ " ",
+ this.CurIP.spawnVerb,
+ "(",
+ this.calculatedQuantity,
+ "x)"
+ });
+ }
+ result = text;
+ }
+ return result;
+ }
+ }
+
+ private int ticksUntilSpawn;
+
+ private int initialTicksUntilSpawn = 0;
+
+ public int graceTicks = 0;
+
+ public int calculatedQuantity;
+
+ public int hungerReset = 0;
+
+ public int healthReset = 0;
+
+ private bool blockSpawn = false;
+
+ private int pickedItem = -1;
+
+ public Faction Itemfaction = null;
+
+ public bool newBorn = false;
+
+ public readonly float minDaysB4NextErrorLimit = 0.001f;
+
+ public readonly int spawnCountErrorLimit = 750;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Spawner.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Spawner.cs
new file mode 100644
index 0000000..199ea8a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Spawner.cs
@@ -0,0 +1,778 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_Spawner : HediffComp
+ {
+ public HediffCompProperties_Spawner Props
+ {
+ get
+ {
+ return (HediffCompProperties_Spawner)this.props;
+ }
+ }
+
+ public override void CompExposeData()
+ {
+ Scribe_Values.Look(ref this.ticksUntilSpawn, "ticksUntilSpawn", 0, false);
+ Scribe_Values.Look(ref this.initialTicksUntilSpawn, "initialTicksUntilSpawn", 0, false);
+ Scribe_Values.Look(ref this.calculatedMinDaysB4Next, "calculatedMinDaysB4Next", 0f, false);
+ Scribe_Values.Look(ref this.calculatedMaxDaysB4Next, "calculatedMaxDaysB4Next", 0f, false);
+ Scribe_Values.Look(ref this.calculatedQuantity, "calculatedQuantity", 0, false);
+ Scribe_Values.Look(ref this.graceTicks, "graceTicks", 0, false);
+ }
+
+ public override void CompPostMake()
+ {
+ this.myDebug = this.Props.debug;
+ Tools.Warn(string.Concat(new string[]
+ {
+ ">>> ",
+ this.parent.pawn.Label,
+ " - ",
+ this.parent.def.defName,
+ " - CompPostMake start"
+ }), this.myDebug);
+ this.TraceProps();
+ this.CheckProps();
+ this.CalculateValues();
+ this.CheckCalculatedValues();
+ this.TraceCalculatedValues();
+ bool flag = this.initialTicksUntilSpawn == 0;
+ if (flag)
+ {
+ Tools.Warn("Reseting countdown bc initialTicksUntilSpawn == 0 (comppostmake)", this.myDebug);
+ this.ResetCountdown();
+ }
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ this.pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(this.pawn);
+ checked
+ {
+ if (!flag)
+ {
+ bool flag2 = this.blockSpawn;
+ if (!flag2)
+ {
+ bool flag3 = this.graceTicks > 0;
+ if (flag3)
+ {
+ this.graceTicks--;
+ }
+ else
+ {
+ bool flag4 = this.Props.hungerRelative && this.pawn.IsHungry(this.myDebug);
+ if (flag4)
+ {
+ int num = (int)(unchecked(this.RandomGraceDays() * 60000f));
+ this.hungerReset++;
+ this.graceTicks = num;
+ }
+ else
+ {
+ bool flag5 = this.Props.healthRelative && this.pawn.IsInjured(this.myDebug);
+ if (flag5)
+ {
+ int num2 = (int)(unchecked(this.RandomGraceDays() * 60000f));
+ this.healthReset++;
+ this.graceTicks = num2;
+ }
+ else
+ {
+ this.hungerReset = (this.healthReset = 0);
+ bool flag6 = this.CheckShouldSpawn();
+ if (flag6)
+ {
+ Tools.Warn("Reseting countdown bc spawned thing", this.myDebug);
+ this.CalculateValues();
+ this.CheckCalculatedValues();
+ this.ResetCountdown();
+ bool flag7 = Rand.Chance(this.Props.randomGrace);
+ if (flag7)
+ {
+ int num3 = (int)(unchecked(this.RandomGraceDays() * 60000f));
+ this.graceTicks = num3;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void TraceProps()
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "Props => minDaysB4Next: ",
+ this.Props.minDaysB4Next,
+ "; maxDaysB4Next: ",
+ this.Props.maxDaysB4Next,
+ "; randomGrace: ",
+ this.Props.randomGrace,
+ "; graceDays: ",
+ this.Props.graceDays,
+ "; hungerRelative: ",
+ this.Props.hungerRelative.ToString(),
+ "; healthRelative: ",
+ this.Props.healthRelative.ToString(),
+ "; "
+ }), this.myDebug);
+ bool animalThing = this.Props.animalThing;
+ if (animalThing)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ "animalThing: ",
+ this.Props.animalThing.ToString(),
+ "; animalName: ",
+ this.Props.animalToSpawn.defName,
+ "; factionOfPlayerAnimal: ",
+ this.Props.factionOfPlayerAnimal.ToString(),
+ "; "
+ }), this.myDebug);
+ }
+ bool ageWeightedQuantity = this.Props.ageWeightedQuantity;
+ if (ageWeightedQuantity)
+ {
+ Tools.Warn(string.Concat(new string[]
+ {
+ "ageWeightedQuantity:",
+ this.Props.ageWeightedQuantity.ToString(),
+ "; olderBiggerQuantity:",
+ this.Props.olderBiggerQuantity.ToString(),
+ "; ",
+ this.myDebug.ToString()
+ }), false);
+ bool exponentialQuantity = this.Props.exponentialQuantity;
+ if (exponentialQuantity)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "exponentialQuantity:",
+ this.Props.exponentialQuantity.ToString(),
+ "; exponentialRatioLimit:",
+ this.Props.exponentialRatioLimit,
+ "; "
+ }), this.myDebug);
+ }
+ }
+ bool ageWeightedPeriod = this.Props.ageWeightedPeriod;
+ if (ageWeightedPeriod)
+ {
+ }
+ Tools.Warn(string.Concat(new string[]
+ {
+ "ageWeightedPeriod:",
+ this.Props.ageWeightedPeriod.ToString(),
+ "; olderSmallerPeriod:",
+ this.Props.olderSmallerPeriod.ToString(),
+ "; ",
+ this.myDebug.ToString()
+ }), false);
+ }
+
+ private void CalculateValues()
+ {
+ float num = Tools.GetPawnAgeOverlifeExpectancyRatio(this.parent.pawn, this.myDebug);
+ num = ((num > 1f) ? 1f : num);
+ this.calculatedMinDaysB4Next = this.Props.minDaysB4Next;
+ this.calculatedMaxDaysB4Next = this.Props.maxDaysB4Next;
+ bool ageWeightedPeriod = this.Props.ageWeightedPeriod;
+ if (ageWeightedPeriod)
+ {
+ float num2 = this.Props.olderSmallerPeriod ? (-num) : num;
+ this.calculatedMinDaysB4Next = this.Props.minDaysB4Next * (1f + num2);
+ this.calculatedMaxDaysB4Next = this.Props.maxDaysB4Next * (1f + num2);
+ Tools.Warn(string.Concat(new object[]
+ {
+ " ageWeightedPeriod: ",
+ this.Props.ageWeightedPeriod.ToString(),
+ " ageRatio: ",
+ num,
+ " minDaysB4Next: ",
+ this.Props.minDaysB4Next,
+ " maxDaysB4Next: ",
+ this.Props.maxDaysB4Next,
+ " daysAgeRatio: ",
+ num2,
+ " calculatedMinDaysB4Next: ",
+ this.calculatedMinDaysB4Next,
+ "; calculatedMaxDaysB4Next: ",
+ this.calculatedMaxDaysB4Next,
+ "; "
+ }), this.myDebug);
+ }
+ this.calculatedQuantity = this.Props.spawnCount;
+ bool ageWeightedQuantity = this.Props.ageWeightedQuantity;
+ if (ageWeightedQuantity)
+ {
+ float num3 = this.Props.olderBiggerQuantity ? num : (-num);
+ Tools.Warn("quantityAgeRatio: " + num3, this.myDebug);
+ this.calculatedQuantity = checked((int)Math.Round(unchecked((double)this.Props.spawnCount * (double)(1f + num3))));
+ bool exponentialQuantity = this.Props.exponentialQuantity;
+ if (exponentialQuantity)
+ {
+ num3 = 1f - num;
+ bool flag = num3 == 0f;
+ if (flag)
+ {
+ Tools.Warn(">ERROR< quantityAgeRatio is f* up : " + num3, this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ return;
+ }
+ float num4 = this.Props.olderBiggerQuantity ? (1f / num3) : (num3 * num3);
+ bool flag2 = false;
+ bool flag3 = false;
+ bool flag4 = num4 > (float)this.Props.exponentialRatioLimit;
+ if (flag4)
+ {
+ num4 = (float)this.Props.exponentialRatioLimit;
+ flag2 = true;
+ }
+ this.calculatedQuantity = checked((int)Math.Round(unchecked((double)this.Props.spawnCount * (double)num4)));
+ bool flag5 = this.calculatedQuantity < 1;
+ if (flag5)
+ {
+ this.calculatedQuantity = 1;
+ flag3 = true;
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ " exponentialQuantity: ",
+ this.Props.exponentialQuantity.ToString(),
+ "; expoFactor: ",
+ num4,
+ "; gotLimited: ",
+ flag2.ToString(),
+ "; gotAugmented: ",
+ flag3.ToString()
+ }), this.myDebug);
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ "; Props.spawnCount: ",
+ this.Props.spawnCount,
+ "; calculatedQuantity: ",
+ this.calculatedQuantity
+ }), this.myDebug);
+ }
+ }
+
+ private void CheckCalculatedValues()
+ {
+ bool flag = this.calculatedQuantity > this.errorSpawnCount;
+ if (flag)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ ">ERROR< calculatedQuantity is too high: ",
+ this.calculatedQuantity,
+ "(>",
+ this.errorSpawnCount,
+ "), check and adjust your hediff props"
+ }), this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ else
+ {
+ bool flag2 = this.calculatedMinDaysB4Next >= this.calculatedMaxDaysB4Next;
+ if (flag2)
+ {
+ Tools.Warn(">ERROR< calculatedMinDaysB4Next should be lower than calculatedMaxDaysB4Next", this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ else
+ {
+ bool flag3 = this.calculatedMinDaysB4Next < this.errorMinDaysB4Next;
+ if (flag3)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ ">ERROR< calculatedMinDaysB4Next is too low: ",
+ this.Props.minDaysB4Next,
+ "(<",
+ this.errorMinDaysB4Next,
+ "), check and adjust your hediff props"
+ }), this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ }
+ }
+ }
+
+ private void TraceCalculatedValues()
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "<<< ",
+ this.Props.ageWeightedPeriod ? ("Props.olderMoreOften: " + this.Props.olderSmallerPeriod.ToString() + "; ") : "",
+ this.Props.ageWeightedQuantity ? ("Props.olderBiggerquantities: " + this.Props.olderBiggerQuantity.ToString() + "; ") : "",
+ " Props.minDaysB4Next: ",
+ this.Props.minDaysB4Next,
+ "; Props.maxDaysB4Next: ",
+ this.Props.maxDaysB4Next,
+ "; calculatedMinDaysB4Next: ",
+ this.calculatedMinDaysB4Next,
+ "; calculatedMaxDaysB4Next: ",
+ this.calculatedMaxDaysB4Next,
+ "; Props.spawnCount: ",
+ this.Props.spawnCount,
+ "; CalculatedQuantity: ",
+ this.calculatedQuantity,
+ "; "
+ }), this.myDebug);
+ }
+
+ private void CheckProps()
+ {
+ bool flag = this.Props.spawnCount > this.errorSpawnCount;
+ if (flag)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "SpawnCount is too high: ",
+ this.Props.spawnCount,
+ "(>",
+ this.errorSpawnCount,
+ "), some people just want to see the world burn"
+ }), this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ else
+ {
+ bool flag2 = this.Props.minDaysB4Next >= this.Props.maxDaysB4Next;
+ if (flag2)
+ {
+ Tools.Warn("minDaysB4Next should be lower than maxDaysB4Next", this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ else
+ {
+ bool flag3 = this.Props.minDaysB4Next < this.errorMinDaysB4Next;
+ if (flag3)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "minDaysB4Next is too low: ",
+ this.Props.minDaysB4Next,
+ "(<",
+ this.errorMinDaysB4Next,
+ "), some people just want to see the world burn"
+ }), this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ else
+ {
+ bool animalThing = this.Props.animalThing;
+ if (animalThing)
+ {
+ bool flag4 = this.Props.animalToSpawn == null || this.Props.animalToSpawn.defName.NullOrEmpty();
+ if (flag4)
+ {
+ Tools.Warn("Props.animalThing=" + this.Props.animalThing.ToString() + "; but no Props.animalName", this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ return;
+ }
+ Tools.Warn("Found animal PawnKindDef.defName=" + this.Props.animalToSpawn.defName, this.myDebug);
+ }
+ else
+ {
+ ThingDef thingDef = (from b in DefDatabase.AllDefs
+ where b == this.Props.thingToSpawn
+ select b).RandomElement();
+ bool flag5 = thingDef == null;
+ if (flag5)
+ {
+ Tools.Warn("Could not find Props.thingToSpawn in DefDatabase", this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ return;
+ }
+ Tools.Warn("Found ThingDef for " + this.Props.thingToSpawn.defName + "in DefDatabase", this.myDebug);
+ }
+ bool flag6 = !this.Props.ageWeightedPeriod;
+ if (flag6)
+ {
+ bool olderSmallerPeriod = this.Props.olderSmallerPeriod;
+ if (olderSmallerPeriod)
+ {
+ Tools.Warn("olderSmallerPeriod ignored since ageWeightedPeriod is false ", this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ return;
+ }
+ }
+ bool flag7 = !this.Props.ageWeightedQuantity;
+ if (flag7)
+ {
+ bool olderBiggerQuantity = this.Props.olderBiggerQuantity;
+ if (olderBiggerQuantity)
+ {
+ Tools.Warn("olderBiggerQuantity ignored since ageWeightedQuantity is false ", this.myDebug);
+ }
+ bool exponentialQuantity = this.Props.exponentialQuantity;
+ if (exponentialQuantity)
+ {
+ Tools.Warn("exponentialQuantity ignored since ageWeightedQuantity is false ", this.myDebug);
+ }
+ bool flag8 = this.Props.olderBiggerQuantity || this.Props.exponentialQuantity;
+ if (flag8)
+ {
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ return;
+ }
+ }
+ bool flag9 = this.Props.exponentialQuantity && this.Props.exponentialRatioLimit > this.errorExponentialLimit;
+ if (flag9)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "expoRatioLimit too low while expoQuantity is set: ",
+ this.Props.exponentialRatioLimit,
+ "(>",
+ this.errorExponentialLimit,
+ "), some people just want to see the world burn"
+ }), this.myDebug);
+ this.blockSpawn = true;
+ Tools.DestroyParentHediff(this.parent, this.myDebug);
+ }
+ }
+ }
+ }
+ }
+
+ private bool CheckShouldSpawn()
+ {
+ this.pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(this.pawn);
+ checked
+ {
+ bool result;
+ if (flag)
+ {
+ Tools.Warn("CheckShouldSpawn pawn Null", this.myDebug);
+ result = false;
+ }
+ else
+ {
+ this.ticksUntilSpawn--;
+ bool flag2 = this.ticksUntilSpawn <= 0;
+ if (flag2)
+ {
+ Tools.Warn("TryDoSpawn: " + this.TryDoSpawn().ToString(), this.myDebug);
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ return result;
+ }
+ }
+
+ private PawnKindDef MyPawnKindDefNamed(string myDefName)
+ {
+ PawnKindDef result = null;
+ foreach (PawnKindDef pawnKindDef in DefDatabase.AllDefs)
+ {
+ bool flag = pawnKindDef.defName == myDefName;
+ if (flag)
+ {
+ return pawnKindDef;
+ }
+ }
+ return result;
+ }
+
+ public bool TryDoSpawn()
+ {
+ this.pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(this.pawn);
+ checked
+ {
+ bool result;
+ if (flag)
+ {
+ Tools.Warn("TryDoSpawn - pawn null", this.myDebug);
+ result = false;
+ }
+ else
+ {
+ bool animalThing = this.Props.animalThing;
+ if (animalThing)
+ {
+ Faction faction = this.Props.factionOfPlayerAnimal ? Faction.OfPlayer : null;
+ PawnGenerationRequest request = new PawnGenerationRequest(this.Props.animalToSpawn, faction, PawnGenerationContext.NonPlayer, -1, false, true, false, true, false, 1f, false, true, false, true, true, false, false, false, false, 0f, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null, false, false, false, false, null, null, null, null, null, 0f, DevelopmentalStage.Adult, null, null, null, false, false, false, -1, 0, false);
+ for (int i = 0; i < this.calculatedQuantity; i++)
+ {
+ Pawn newThing = PawnGenerator.GeneratePawn(request);
+ GenSpawn.Spawn(newThing, this.parent.pawn.Position, this.parent.pawn.Map, WipeMode.Vanish);
+ FilthMaker.TryMakeFilth(this.parent.pawn.Position, this.parent.pawn.Map, ThingDefOf.Filth_AmnioticFluid, 1, FilthSourceFlags.None, true);
+ }
+ result = true;
+ }
+ else
+ {
+ bool flag2 = this.Props.spawnMaxAdjacent >= 0;
+ if (flag2)
+ {
+ int num = 0;
+ for (int j = 0; j < 9; j++)
+ {
+ IntVec3 c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[j];
+ bool flag3 = !c.InBounds(this.pawn.Map);
+ if (!flag3)
+ {
+ List thingList = c.GetThingList(this.pawn.Map);
+ for (int k = 0; k < thingList.Count; k++)
+ {
+ bool flag4 = thingList[k].def == this.Props.thingToSpawn;
+ if (flag4)
+ {
+ num += thingList[k].stackCount;
+ bool flag5 = num >= this.Props.spawnMaxAdjacent;
+ if (flag5)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ }
+ int l = 0;
+ int num2 = this.calculatedQuantity;
+ int num3 = 0;
+ while (l < this.calculatedQuantity)
+ {
+ IntVec3 intVec;
+ bool flag6 = this.TryFindSpawnCell(out intVec);
+ if (flag6)
+ {
+ Thing thing = ThingMaker.MakeThing(this.Props.thingToSpawn, null);
+ thing.stackCount = num2;
+ bool flag7 = thing.def.stackLimit > 0;
+ if (flag7)
+ {
+ bool flag8 = thing.stackCount > thing.def.stackLimit;
+ if (flag8)
+ {
+ thing.stackCount = thing.def.stackLimit;
+ }
+ }
+ l += thing.stackCount;
+ num2 -= thing.stackCount;
+ Thing t;
+ GenPlace.TryPlaceThing(thing, intVec, this.pawn.Map, ThingPlaceMode.Direct, ref t, null, null, default(Rot4));
+ bool spawnForbidden = this.Props.spawnForbidden;
+ if (spawnForbidden)
+ {
+ t.SetForbidden(true, true);
+ }
+ }
+ bool flag9 = num3++ > 10;
+ if (flag9)
+ {
+ Tools.Warn("Had to break the loop", this.myDebug);
+ return false;
+ }
+ }
+ bool flag10 = num2 <= 0;
+ result = flag10;
+ }
+ }
+ return result;
+ }
+ }
+
+ private bool TryFindSpawnCell(out IntVec3 result)
+ {
+ this.pawn = this.parent.pawn;
+ bool flag = !Tools.OkPawn(this.pawn);
+ checked
+ {
+ bool result2;
+ if (flag)
+ {
+ result = IntVec3.Invalid;
+ Tools.Warn("TryFindSpawnCell Null - pawn null", this.myDebug);
+ result2 = false;
+ }
+ else
+ {
+ foreach (IntVec3 intVec in GenAdj.CellsAdjacent8Way(this.pawn).InRandomOrder(null))
+ {
+ bool flag2 = intVec.Walkable(this.pawn.Map);
+ if (flag2)
+ {
+ Building edifice = intVec.GetEdifice(this.pawn.Map);
+ bool flag3 = edifice == null || !this.Props.thingToSpawn.IsEdifice();
+ if (flag3)
+ {
+ Building_Door building_Door;
+ bool flag4 = (building_Door = (edifice as Building_Door)) == null || building_Door.FreePassage;
+ if (flag4)
+ {
+ bool flag5 = GenSight.LineOfSight(this.pawn.Position, intVec, this.pawn.Map, false, null, 0, 0);
+ if (flag5)
+ {
+ bool flag6 = false;
+ List thingList = intVec.GetThingList(this.pawn.Map);
+ for (int i = 0; i < thingList.Count; i++)
+ {
+ Thing thing = thingList[i];
+ bool flag7 = thing.def.category == ThingCategory.Item;
+ if (flag7)
+ {
+ bool flag8 = thing.def != this.Props.thingToSpawn || thing.stackCount > this.Props.thingToSpawn.stackLimit - this.calculatedQuantity;
+ if (flag8)
+ {
+ flag6 = true;
+ break;
+ }
+ }
+ }
+ bool flag9 = !flag6;
+ if (flag9)
+ {
+ result = intVec;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ Tools.Warn("TryFindSpawnCell Null - no spawn cell found", this.myDebug);
+ result = IntVec3.Invalid;
+ result2 = false;
+ }
+ return result2;
+ }
+ }
+
+ private void ResetCountdown()
+ {
+ this.ticksUntilSpawn = (this.initialTicksUntilSpawn = checked((int)(unchecked(this.RandomDays2wait() * 60000f))));
+ }
+
+ private float RandomDays2wait()
+ {
+ return Rand.Range(this.calculatedMinDaysB4Next, this.calculatedMaxDaysB4Next);
+ }
+
+ private float RandomGraceDays()
+ {
+ return this.Props.graceDays * Rand.Range(0f, 1f);
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string text = string.Empty;
+ bool flag = this.graceTicks > 0;
+ if (flag)
+ {
+ bool animalThing = this.Props.animalThing;
+ if (animalThing)
+ {
+ text = " No " + this.Props.animalToSpawn.defName + " for " + this.graceTicks.ToStringTicksToPeriod(true, false, true, true, false);
+ }
+ else
+ {
+ text = " No " + this.Props.thingToSpawn.label + " for " + this.graceTicks.ToStringTicksToPeriod(true, false, true, true, false);
+ }
+ bool flag2 = this.hungerReset > 0;
+ if (flag2)
+ {
+ text += "(hunger)";
+ }
+ else
+ {
+ bool flag3 = this.healthReset > 0;
+ if (flag3)
+ {
+ text += "(injury)";
+ }
+ else
+ {
+ text += "(grace period)";
+ }
+ }
+ }
+ else
+ {
+ text = this.ticksUntilSpawn.ToStringTicksToPeriod(true, false, true, true, false) + " before ";
+ bool animalThing2 = this.Props.animalThing;
+ if (animalThing2)
+ {
+ text += this.Props.animalToSpawn.defName;
+ }
+ else
+ {
+ text += this.Props.thingToSpawn.label;
+ }
+ text = string.Concat(new object[]
+ {
+ text,
+ " ",
+ this.Props.spawnVerb,
+ "(",
+ this.calculatedQuantity,
+ "x)"
+ });
+ }
+ return text;
+ }
+ }
+
+ private int ticksUntilSpawn;
+
+ private int initialTicksUntilSpawn = 0;
+
+ private int hungerReset = 0;
+
+ private int healthReset = 0;
+
+ private int graceTicks = 0;
+
+ private Pawn pawn = null;
+
+ private float calculatedMaxDaysB4Next = 2f;
+
+ private float calculatedMinDaysB4Next = 1f;
+
+ private int calculatedQuantity = 1;
+
+ private bool blockSpawn = false;
+
+ private bool myDebug = false;
+
+ private readonly float errorMinDaysB4Next = 0.001f;
+
+ private readonly int errorExponentialLimit = 20;
+
+ private readonly int errorSpawnCount = 750;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Steamer.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Steamer.cs
new file mode 100644
index 0000000..13cef1a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_Steamer.cs
@@ -0,0 +1,80 @@
+using System;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_Steamer : HediffComp
+ {
+ private bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ private Map MyMap
+ {
+ get
+ {
+ return base.Pawn.Map;
+ }
+ }
+
+ public HediffCompProperties_Steamer Props
+ {
+ get
+ {
+ return (HediffCompProperties_Steamer)this.props;
+ }
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ checked
+ {
+ if (flag)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("null pawn");
+ }
+ }
+ else
+ {
+ bool flag2 = this.sprayTicksLeft <= 0;
+ if (flag2)
+ {
+ bool flag3 = Rand.Chance(this.Props.puffingChance);
+ if (flag3)
+ {
+ FleckMaker.ThrowAirPuffUp(base.Pawn.TrueCenter(), this.MyMap);
+ GenTemperature.PushHeat(base.Pawn.Position, this.MyMap, this.Props.temperatureIncreasePerPuff);
+ }
+ this.sprayTicksLeft = (this.ticksUntilSpray = Rand.RangeInclusive(this.Props.MinTicksBetweenSprays, this.Props.MaxTicksBetweenSprays));
+ }
+ else
+ {
+ this.sprayTicksLeft--;
+ }
+ }
+ }
+ }
+
+ public override string CompTipStringExtra
+ {
+ get
+ {
+ string empty = string.Empty;
+ return empty + "Puff in " + this.sprayTicksLeft.ToStringTicksToPeriod(true, false, true, true, false);
+ }
+ }
+
+ private int ticksUntilSpray = 500;
+
+ private int sprayTicksLeft;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_TrailLeaver.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_TrailLeaver.cs
new file mode 100644
index 0000000..71e118e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffComp_TrailLeaver.cs
@@ -0,0 +1,236 @@
+using System;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffComp_TrailLeaver : HediffComp
+ {
+ public Map MyMap
+ {
+ get
+ {
+ return base.Pawn.Map;
+ }
+ }
+
+ public bool NullMap
+ {
+ get
+ {
+ return this.MyMap == null;
+ }
+ }
+
+ public bool MyDebug
+ {
+ get
+ {
+ return this.Props.debug;
+ }
+ }
+
+ public HediffCompProperties_TrailLeaver Props
+ {
+ get
+ {
+ return (HediffCompProperties_TrailLeaver)this.props;
+ }
+ }
+
+ public bool HasMotePool
+ {
+ get
+ {
+ return this.Props.HasMotePool;
+ }
+ }
+
+ public TerrainRestriction TerrainRestriction
+ {
+ get
+ {
+ return (!this.Props.HasRestriction || !this.Props.restriction.HasTerrainRestriction) ? null : this.Props.restriction.terrain;
+ }
+ }
+
+ public bool HasTerrainRestriction
+ {
+ get
+ {
+ return this.TerrainRestriction != null;
+ }
+ }
+
+ public Restriction PawnRestriction
+ {
+ get
+ {
+ return (!this.Props.HasRestriction) ? null : this.Props.restriction;
+ }
+ }
+
+ public bool HasPawnRestriction
+ {
+ get
+ {
+ return this.TerrainRestriction != null;
+ }
+ }
+
+ public override void CompPostMake()
+ {
+ this.PropsCheck();
+ }
+
+ public void NewPeriod()
+ {
+ this.currentPeriod = this.Props.period.RandomInRange;
+ }
+
+ public override void CompPostTick(ref float severityAdjustment)
+ {
+ bool flag = base.Pawn.Negligible();
+ if (flag)
+ {
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("null pawn");
+ }
+ }
+ else
+ {
+ bool flag2 = this.currentPeriod == 0;
+ if (flag2)
+ {
+ this.NewPeriod();
+ }
+ bool flag3 = !base.Pawn.IsHashIntervalTick(this.currentPeriod);
+ if (!flag3)
+ {
+ bool flag4 = !this.IsTerrainAllowed(base.Pawn.Position.GetTerrain(this.MyMap));
+ if (flag4)
+ {
+ bool myDebug2 = this.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning("terrain does not allow motes");
+ }
+ }
+ else
+ {
+ bool flag5 = !this.IsPawnActivityCompatible();
+ if (flag5)
+ {
+ bool myDebug3 = this.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning("pawn activity does not allow motes");
+ }
+ }
+ else
+ {
+ this.TryPlaceMote();
+ this.NewPeriod();
+ }
+ }
+ }
+ }
+ }
+
+ public void PropsCheck()
+ {
+ bool flag = !this.MyDebug;
+ if (!flag)
+ {
+ bool flag2 = !this.HasMotePool;
+ if (flag2)
+ {
+ Log.Warning("Mote pool is empty, trailLeaver needs at least 1 mote");
+ }
+ bool flag3 = !this.Props.HasOffset;
+ if (flag3)
+ {
+ Log.Warning("no offset per body type found, will use default:" + this.Props.defaultOffset);
+ }
+ else
+ {
+ string text = "BodyTypeOffsets dump => ";
+ foreach (BodyTypeOffset bodyTypeOffset in this.Props.offSetPerBodyType)
+ {
+ text = string.Concat(new object[]
+ {
+ text,
+ bodyTypeOffset.bodyType.defName,
+ ":",
+ bodyTypeOffset.offset,
+ "; "
+ });
+ }
+ Log.Warning(text);
+ }
+ bool usesFootPrints = this.Props.UsesFootPrints;
+ if (usesFootPrints)
+ {
+ Log.Warning("footprints => " + this.Props.footprint.Dump());
+ }
+ }
+ }
+
+ private void TryPlaceMote()
+ {
+ bool flag = !this.HasMotePool;
+ if (!flag)
+ {
+ Vector3 drawPos = base.Pawn.DrawPos;
+ bool flag2 = base.Pawn.Position.InBounds(this.MyMap);
+ if (flag2)
+ {
+ Vector3 vector;
+ float moteRotation = this.GetMoteRotation(drawPos, out vector);
+ Vector3 vector2 = drawPos + this.GetBodyTypeOffset() + this.GetFootPrintOffset(vector);
+ bool myDebug = this.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ base.Pawn.ThingID,
+ " ",
+ this.parent.def.defName,
+ " TryPlaceMote - dynRot:",
+ this.Props.dynamicRotation.ToString(),
+ " footprint:",
+ this.Props.UsesFootPrints.ToString(),
+ " drawPos:",
+ drawPos,
+ " offset:",
+ vector2,
+ " rot:",
+ moteRotation,
+ " normalized:",
+ vector
+ }));
+ }
+ float randomInRange = this.Props.randomScale.RandomInRange;
+ ThingDef moteDef = this.Props.motePool.RandomElementWithFallback(null);
+ Mote mote;
+ bool flag3 = (mote = (vector2.TryAnyMoteSpawn(this.MyMap, moteRotation, randomInRange, moteDef, this.MyDebug) as Mote)) != null;
+ if (flag3)
+ {
+ this.ChangeMoteColor(mote);
+ }
+ }
+ this.RecordMotePos(drawPos);
+ }
+ }
+
+ public int currentPeriod = 0;
+
+ public Vector3 lastMotePos;
+
+ public Color lastColor = Color.black;
+
+ public bool lastFootprintRight;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCondition.cs
new file mode 100644
index 0000000..6c26eaa
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffCondition.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace MoharHediffs
+{
+ public class HediffCondition
+ {
+ public bool HasPawnCondition
+ {
+ get
+ {
+ return this.pawn != null;
+ }
+ }
+
+ public bool HasBodypartCondition
+ {
+ get
+ {
+ return this.bodyPart != null && this.bodyPart.HasBPCondition;
+ }
+ }
+
+ public PawnCondition pawn;
+
+ public BodyPartCondition bodyPart;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffIntersect.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffIntersect.cs
new file mode 100644
index 0000000..12f9500
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffIntersect.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class HediffIntersect
+ {
+ public static bool RemoveHediffAndReturnTrue(Pawn p, Hediff h, bool debug = false)
+ {
+ string warning = debug ? string.Concat(new string[]
+ {
+ p.LabelShort,
+ " - ",
+ p.def.defName,
+ " - RemoveHediff ",
+ h.def.defName
+ }) : "";
+ Tools.Warn(warning, debug);
+ p.health.RemoveHediff(h);
+ return true;
+ }
+
+ public static bool TreatLightCondition(this Pawn p, LightCondition LC, Hediff h, float lightLevel, bool outside, bool debug = false)
+ {
+ bool flag = (LC.RequiresLightLevel && !LC.level.Value.Includes(lightLevel)) || (LC.requiresOutside && !outside) || (LC.requiresInside && outside);
+ return flag && HediffIntersect.RemoveHediffAndReturnTrue(p, h, debug);
+ }
+
+ public static bool TreatNeedCondition(this Pawn p, List needs, Hediff h, bool debug = false)
+ {
+ string str = debug ? (p.LabelShort + " TreatNeedCondition - ") : "";
+ using (List.Enumerator enumerator = needs.GetEnumerator())
+ {
+ while (enumerator.MoveNext())
+ {
+ NeedCondition NC = enumerator.Current;
+ Tools.Warn(str + string.Format("checking {0} => {1} > x > {2}", NC.needDef.defName, NC.level.min, NC.level.max), debug);
+ Need need = (from n in p.needs.AllNeeds
+ where n.def == NC.needDef && !NC.level.Includes(n.CurLevelPercentage)
+ select n).FirstOrFallback(null);
+ bool flag = need == null;
+ if (!flag)
+ {
+ Tools.Warn(str + string.Format("Found {0} out of range: {1}", need.def.defName, need.CurLevelPercentage), debug);
+ return HediffIntersect.RemoveHediffAndReturnTrue(p, h, debug);
+ }
+ }
+ }
+ return false;
+ }
+
+ public static bool TreatHediffSeverityCondition(this Pawn p, List destroyingHediffs, Hediff h, bool debug = false)
+ {
+ using (List.Enumerator enumerator = destroyingHediffs.GetEnumerator())
+ {
+ while (enumerator.MoveNext())
+ {
+ HediffSeverityCondition HSC = enumerator.Current;
+ Hediff hediff = (from dh in p.health.hediffSet.hediffs
+ where dh.def == HSC.hediffDef && !HSC.acceptableSeverity.Includes(dh.Severity)
+ select dh).FirstOrFallback(null);
+ bool flag = hediff == null;
+ if (!flag)
+ {
+ return HediffIntersect.RemoveHediffAndReturnTrue(p, hediff, debug);
+ }
+ }
+ }
+ return false;
+ }
+
+ public static bool TreatRelevantHediffsAndReportIfStillHediffsToCheck(this HediffComp_OnTheCarpet comp)
+ {
+ bool myDebug = comp.MyDebug;
+ bool flag = false;
+ Pawn pawn = comp.Pawn;
+ string text = myDebug ? (pawn.LabelShort + " TreatRelevant - ") : "";
+ Tools.Warn(text + " Entering", myDebug);
+ float ambientTemperature = pawn.AmbientTemperature;
+ float lightLevel = pawn.Map.glowGrid.GroundGlowAt(pawn.Position, false, false);
+ Room room = pawn.GetRoom(RegionType.Set_All);
+ bool outside = room == null || room.PsychologicallyOutdoors;
+ List hediffs = comp.Pawn.health.hediffSet.hediffs;
+ checked
+ {
+ int num = hediffs.Count - 1;
+ while (num >= 0 && !hediffs.NullOrEmpty())
+ {
+ Hediff H = hediffs[num];
+ IEnumerable hediffPool = comp.Props.hediffPool;
+ Func predicate;
+ Func <>9__0;
+ if ((predicate = <>9__0) == null)
+ {
+ predicate = (<>9__0 = ((HediffItemToRemove h) => h.hediffDef == H.def));
+ }
+ foreach (HediffItemToRemove hediffItemToRemove in hediffPool.Where(predicate))
+ {
+ Tools.Warn(text + " found intersect hediff: " + H.def.defName, myDebug);
+ HediffKeepingCondition defaultPlusSpecificHediffCondition = HediffRemovalConditionBuilder.GetDefaultPlusSpecificHediffCondition(comp.Props.defaultCondition, hediffItemToRemove.specificCondition, myDebug);
+ bool flag2 = false;
+ bool hasLightCondition = defaultPlusSpecificHediffCondition.HasLightCondition;
+ if (hasLightCondition)
+ {
+ Tools.Warn(text + H.def.defName + "checking light", myDebug);
+ flag2 = pawn.TreatLightCondition(defaultPlusSpecificHediffCondition.light, H, lightLevel, outside, myDebug);
+ }
+ else
+ {
+ bool flag3 = defaultPlusSpecificHediffCondition.HasTemperatureCondition && !defaultPlusSpecificHediffCondition.temperature.Value.Includes(ambientTemperature);
+ if (flag3)
+ {
+ Tools.Warn(text + H.def.defName + "checking temperature", myDebug);
+ flag2 = HediffIntersect.RemoveHediffAndReturnTrue(pawn, H, myDebug);
+ }
+ else
+ {
+ bool hasNeedCondition = defaultPlusSpecificHediffCondition.HasNeedCondition;
+ if (hasNeedCondition)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ H.def.defName,
+ "checking ",
+ defaultPlusSpecificHediffCondition.needs.Count,
+ "need"
+ }), myDebug);
+ flag2 = pawn.TreatNeedCondition(defaultPlusSpecificHediffCondition.needs, H, myDebug);
+ }
+ else
+ {
+ bool hasDestroyingHediffs = defaultPlusSpecificHediffCondition.HasDestroyingHediffs;
+ if (hasDestroyingHediffs)
+ {
+ Tools.Warn(text + H.def.defName + "checking other hediffs", myDebug);
+ flag2 = pawn.TreatHediffSeverityCondition(defaultPlusSpecificHediffCondition.destroyingHediffs, H, myDebug);
+ }
+ }
+ }
+ }
+ flag |= !flag2;
+ bool flag4 = flag2;
+ if (flag4)
+ {
+ return true;
+ }
+ }
+ num--;
+ }
+ Tools.Warn(text + "exiting", myDebug);
+ return flag;
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItem.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItem.cs
new file mode 100644
index 0000000..301523b
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItem.cs
@@ -0,0 +1,26 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffItem
+ {
+ public bool HasSpecific
+ {
+ get
+ {
+ return this.specificCondition != null;
+ }
+ }
+
+ public HediffDef hediffDef;
+
+ public FloatRange applyChance = new FloatRange(1f, 1f);
+
+ public FloatRange severity = new FloatRange(0.1f, 0.2f);
+
+ public float weight = 1f;
+
+ public HediffCondition specificCondition;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItemToRemove.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItemToRemove.cs
new file mode 100644
index 0000000..f46b375
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffItemToRemove.cs
@@ -0,0 +1,20 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffItemToRemove
+ {
+ public bool HasSpecificCondition
+ {
+ get
+ {
+ return this.specificCondition != null;
+ }
+ }
+
+ public HediffDef hediffDef;
+
+ public HediffKeepingCondition specificCondition;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffKeepingCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffKeepingCondition.cs
new file mode 100644
index 0000000..fc886fb
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffKeepingCondition.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffKeepingCondition
+ {
+ public bool HasTemperatureCondition
+ {
+ get
+ {
+ return this.temperature != null;
+ }
+ }
+
+ public bool HasLightCondition
+ {
+ get
+ {
+ return this.light != null;
+ }
+ }
+
+ public bool HasNeedCondition
+ {
+ get
+ {
+ return !this.needs.NullOrEmpty();
+ }
+ }
+
+ public bool HasDestroyingHediffs
+ {
+ get
+ {
+ bool result;
+ if (!this.destroyingHediffs.NullOrEmpty())
+ {
+ result = this.destroyingHediffs.Any((HediffSeverityCondition dh) => !dh.HasHediffDef);
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ public FloatRange? temperature = null;
+
+ public LightCondition light;
+
+ public List needs;
+
+ public List destroyingHediffs;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRemovalConditionBuilder.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRemovalConditionBuilder.cs
new file mode 100644
index 0000000..e159a8e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRemovalConditionBuilder.cs
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class HediffRemovalConditionBuilder
+ {
+ public static void CopyHediffKeepingCondition(HediffKeepingCondition source, HediffKeepingCondition dest, bool debug = false)
+ {
+ string str = debug ? "CopyHediffCondition - " : "";
+ bool hasTemperatureCondition = source.HasTemperatureCondition;
+ if (hasTemperatureCondition)
+ {
+ Tools.Warn(str + "found HasTemperatureCondition, copying", debug);
+ dest.temperature = source.temperature;
+ }
+ bool hasLightCondition = source.HasLightCondition;
+ if (hasLightCondition)
+ {
+ Tools.Warn(str + "found HasLightCondition, copying", debug);
+ dest.light = new LightCondition(source.light);
+ }
+ bool hasNeedCondition = source.HasNeedCondition;
+ if (hasNeedCondition)
+ {
+ Tools.Warn(str + "found HasNeedCondition, copying", debug);
+ using (List.Enumerator enumerator = source.needs.GetEnumerator())
+ {
+ while (enumerator.MoveNext())
+ {
+ NeedCondition nc = enumerator.Current;
+ bool flag = dest.needs.Any((NeedCondition n) => n.needDef == nc.needDef);
+ if (flag)
+ {
+ (from n in dest.needs
+ where n.needDef == nc.needDef
+ select n).First().level = nc.level;
+ }
+ else
+ {
+ dest.needs.Add(new NeedCondition(nc));
+ }
+ }
+ }
+ }
+ bool hasDestroyingHediffs = source.HasDestroyingHediffs;
+ if (hasDestroyingHediffs)
+ {
+ Tools.Warn(str + "found HasDestroyingHediffs, copying", debug);
+ using (List.Enumerator enumerator2 = source.destroyingHediffs.GetEnumerator())
+ {
+ while (enumerator2.MoveNext())
+ {
+ HediffSeverityCondition hsc = enumerator2.Current;
+ bool flag2 = dest.destroyingHediffs.Any((HediffSeverityCondition dh) => dh.hediffDef == hsc.hediffDef);
+ if (flag2)
+ {
+ (from dh in dest.destroyingHediffs
+ where dh.hediffDef == hsc.hediffDef
+ select dh).First().acceptableSeverity = hsc.acceptableSeverity;
+ }
+ else
+ {
+ dest.destroyingHediffs.Add(new HediffSeverityCondition(hsc));
+ }
+ }
+ }
+ }
+ }
+
+ public static HediffKeepingCondition GetDefaultPlusSpecificHediffCondition(HediffKeepingCondition defaultHKC, HediffKeepingCondition specificHKC, bool debug = false)
+ {
+ string text = debug ? "GetDefaultPlusSpecificHediffCondition - " : "";
+ Tools.Warn(text + "allocating answerHC", debug);
+ HediffKeepingCondition hediffKeepingCondition = new HediffKeepingCondition
+ {
+ needs = new List()
+ };
+ bool flag = defaultHKC != null;
+ if (flag)
+ {
+ Tools.Warn(text + "found defaultHKC, copying", debug);
+ HediffRemovalConditionBuilder.CopyHediffKeepingCondition(defaultHKC, hediffKeepingCondition, debug);
+ }
+ bool flag2 = specificHKC != null;
+ if (flag2)
+ {
+ Tools.Warn(text + "found specificHKC, copying", debug);
+ HediffRemovalConditionBuilder.CopyHediffKeepingCondition(specificHKC, hediffKeepingCondition, debug);
+ }
+ Tools.Warn(string.Concat(new object[]
+ {
+ text,
+ string.Format("HasDestroyingHediffs:{0} - ", hediffKeepingCondition.HasDestroyingHediffs),
+ hediffKeepingCondition.HasDestroyingHediffs ? hediffKeepingCondition.destroyingHediffs.Count() : 0,
+ string.Format("HasLightCondition:{0} - ", hediffKeepingCondition.HasLightCondition),
+ hediffKeepingCondition.HasLightCondition ? ("reqIn:" + hediffKeepingCondition.light.requiresInside.ToString() + " reqOut:" + hediffKeepingCondition.light.requiresOutside.ToString()) : "",
+ string.Format("HasNeedCondition:{0}", hediffKeepingCondition.HasNeedCondition),
+ hediffKeepingCondition.HasNeedCondition ? hediffKeepingCondition.needs.Count() : 0,
+ string.Format("HasTemperatureCondition:{0}", hediffKeepingCondition.HasTemperatureCondition)
+ }), debug);
+ return hediffKeepingCondition;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRequirementSettings.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRequirementSettings.cs
new file mode 100644
index 0000000..28532cd
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffRequirementSettings.cs
@@ -0,0 +1,20 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffRequirementSettings
+ {
+ public bool HasHediffDef
+ {
+ get
+ {
+ return this.hediffDef != null;
+ }
+ }
+
+ public HediffDef hediffDef;
+
+ public FloatRange severity = new FloatRange(0f, 1f);
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffSeverityCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffSeverityCondition.cs
new file mode 100644
index 0000000..573549a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/HediffSeverityCondition.cs
@@ -0,0 +1,30 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class HediffSeverityCondition
+ {
+ public bool HasHediffDef
+ {
+ get
+ {
+ return this.hediffDef != null;
+ }
+ }
+
+ public HediffSeverityCondition(HediffSeverityCondition copyMe)
+ {
+ this.hediffDef = copyMe.hediffDef;
+ this.acceptableSeverity = copyMe.acceptableSeverity;
+ }
+
+ public HediffSeverityCondition()
+ {
+ }
+
+ public HediffDef hediffDef;
+
+ public FloatRange acceptableSeverity = new FloatRange(0f, 0.5f);
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineDef.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineDef.cs
new file mode 100644
index 0000000..1831fbf
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineDef.cs
@@ -0,0 +1,25 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class InnerShineDef : Def
+ {
+ public override string ToString()
+ {
+ return this.defName;
+ }
+
+ public InnerShineDef Named(string name)
+ {
+ return DefDatabase.GetNamed(name, true);
+ }
+
+ public override int GetHashCode()
+ {
+ return this.defName.GetHashCode();
+ }
+
+ public InnerShineItem item;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineItem.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineItem.cs
new file mode 100644
index 0000000..415ed01
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineItem.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class InnerShineItem
+ {
+ public bool HasSpawningRules
+ {
+ get
+ {
+ return this.spawningRules != null;
+ }
+ }
+
+ public bool HasRestriction
+ {
+ get
+ {
+ return this.restriction != null;
+ }
+ }
+
+ public bool HasMotePool
+ {
+ get
+ {
+ return !this.motePool.NullOrEmpty();
+ }
+ }
+
+ public bool HasBodyTypeDrawRules
+ {
+ get
+ {
+ return !this.bodyTypeDrawRules.NullOrEmpty();
+ }
+ }
+
+ public bool HasDefaultDrawRules
+ {
+ get
+ {
+ return this.defaultDrawRules != null;
+ }
+ }
+
+ public bool HasColorRange
+ {
+ get
+ {
+ return this.colorRange != null;
+ }
+ }
+
+ public string Dump()
+ {
+ return string.Concat(new string[]
+ {
+ "label:",
+ this.label,
+ string.Format(" HasSpawningRules:{0} HasRestriction:{1}", this.HasSpawningRules, this.HasRestriction),
+ string.Format(" HasMotePool:{0} HasBodyTypeDrawRules:{1} HasDefaultDrawRules:{2}", this.HasMotePool, this.HasBodyTypeDrawRules, this.HasDefaultDrawRules),
+ string.Format(" HasColorRange:{0}", this.HasColorRange),
+ string.Format(" debug:{0}", this.debug)
+ });
+ }
+
+ public string label;
+
+ public SpawnRules spawningRules;
+
+ public List motePool;
+
+ public MoteLink.Nature linkType;
+
+ public List bodyTypeDrawRules;
+
+ public DrawingSpecificities defaultDrawRules;
+
+ public ActivityRestriction restriction;
+
+ public ColorRange colorRange;
+
+ public bool debug = false;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineRecord.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineRecord.cs
new file mode 100644
index 0000000..27e6724
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShineRecord.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class InnerShineRecord
+ {
+ public InnerShineRecord(InnerShineItem ISI)
+ {
+ this.label = ISI.label;
+ this.spawned = new List();
+ this.ticksLeft = ISI.NewPeriod();
+ this.lastColor = Color.black;
+ }
+
+ public string Dump
+ {
+ get
+ {
+ string format = "label:{0} spawned:{1} ticksLeft:{2} lastColor:{3}";
+ object[] array = new object[4];
+ array[0] = this.label;
+ int num = 1;
+ List list = this.spawned;
+ array[num] = ((list != null) ? new int?(list.CountAllowNull()) : null);
+ array[2] = this.ticksLeft;
+ array[3] = this.lastColor;
+ return string.Format(format, array);
+ }
+ }
+
+ public string label;
+
+ public List spawned;
+
+ public int ticksLeft;
+
+ public Color lastColor;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShinerUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShinerUtils.cs
new file mode 100644
index 0000000..31e0c7a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/InnerShinerUtils.cs
@@ -0,0 +1,189 @@
+using System;
+using System.Linq;
+using RimWorld;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class InnerShinerUtils
+ {
+ public static InnerShineItem RetrieveISI(this HediffComp_InnerShine comp, string label)
+ {
+ bool hasRawShinePool = comp.Props.HasRawShinePool;
+ if (hasRawShinePool)
+ {
+ InnerShineItem result;
+ bool flag = (result = (from i in comp.Props.innerShinePool
+ where i.label == label
+ select i).FirstOrFallback(null)) != null;
+ if (flag)
+ {
+ return result;
+ }
+ }
+ bool hasShineDefPool = comp.Props.HasShineDefPool;
+ if (hasShineDefPool)
+ {
+ InnerShineDef innerShineDef;
+ bool flag2 = (innerShineDef = (from i in comp.Props.innerShineDefPool
+ where i.item.label == label
+ select i).FirstOrFallback(null)) != null;
+ if (flag2)
+ {
+ return innerShineDef.item;
+ }
+ }
+ return null;
+ }
+
+ public static void SelfDestroy(this HediffComp_InnerShine comp)
+ {
+ comp.parent.Severity = 0f;
+ comp.Pawn.health.RemoveHediff(comp.parent);
+ }
+
+ public static void ChangeMoteColor(this InnerShineItem ISI, InnerShineRecord ISR, Mote mote)
+ {
+ bool flag = !ISI.HasColorRange || mote == null;
+ if (!flag)
+ {
+ bool flag2 = ISR.lastColor == Color.black;
+ if (flag2)
+ {
+ ISR.lastColor = ISI.colorRange.colorA;
+ }
+ ISR.lastColor = ISI.colorRange.RandomPickColor(ISR.lastColor, ISI.debug);
+ mote.instanceColor = ISR.lastColor;
+ }
+ }
+
+ public static void GetSpecifities(this InnerShineItem ISI, Pawn p, out Vector3 offset, out float scale)
+ {
+ offset = Vector3.zero;
+ scale = 1f;
+ Pawn_StoryTracker story = p.story;
+ bool flag = ((story != null) ? story.bodyType : null) == null || !ISI.HasBodyTypeDrawRules;
+ if (flag)
+ {
+ bool hasDefaultDrawRules = ISI.HasDefaultDrawRules;
+ if (hasDefaultDrawRules)
+ {
+ offset = ISI.defaultDrawRules.GetRotationOffset(p);
+ scale = ISI.defaultDrawRules.randomScale.RandomInRange;
+ }
+ }
+ else
+ {
+ BodyTypeSpecificities bodyTypeSpecificities = (from b in ISI.bodyTypeDrawRules
+ where b.bodyTypeDef == p.story.bodyType
+ select b).FirstOrFallback(null);
+ bool flag2 = bodyTypeSpecificities == null;
+ if (flag2)
+ {
+ bool hasDefaultDrawRules2 = ISI.HasDefaultDrawRules;
+ if (hasDefaultDrawRules2)
+ {
+ offset = ISI.defaultDrawRules.GetRotationOffset(p);
+ scale = ISI.defaultDrawRules.randomScale.RandomInRange;
+ }
+ }
+ else
+ {
+ offset = bodyTypeSpecificities.drawRules.GetRotationOffset(p);
+ scale = bodyTypeSpecificities.drawRules.randomScale.RandomInRange;
+ }
+ }
+ }
+
+ public static bool ShouldSpawnMote(this InnerShineItem ISI, InnerShineRecord ISR, Pawn p)
+ {
+ bool flag = !ISI.HasCompatibleActivity(p);
+ bool result;
+ if (flag)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag2 = ISI.HasMoteNumLimit();
+ result = (!flag2 || !ISR.AlreadyReachedMax(ISI.spawningRules.spawnedMax));
+ }
+ return result;
+ }
+
+ public static Vector3 GetDrawOffset(this InnerShineItem ISI, Pawn p)
+ {
+ Pawn_StoryTracker story = p.story;
+ bool flag = ((story != null) ? story.bodyType : null) == null || !ISI.HasBodyTypeDrawRules;
+ Vector3 result;
+ if (flag)
+ {
+ bool hasDefaultDrawRules = ISI.HasDefaultDrawRules;
+ if (hasDefaultDrawRules)
+ {
+ result = ISI.defaultDrawRules.GetRotationOffset(p);
+ }
+ else
+ {
+ result = Vector3.zero;
+ }
+ }
+ else
+ {
+ BodyTypeSpecificities bodyTypeSpecificities = (from b in ISI.bodyTypeDrawRules
+ where b.bodyTypeDef == p.story.bodyType
+ select b).FirstOrFallback(null);
+ bool flag2 = bodyTypeSpecificities == null;
+ if (flag2)
+ {
+ result = (ISI.HasDefaultDrawRules ? ISI.defaultDrawRules.GetRotationOffset(p) : Vector3.zero);
+ }
+ else
+ {
+ result = bodyTypeSpecificities.drawRules.GetRotationOffset(p);
+ }
+ }
+ return result;
+ }
+
+ public static bool AlreadyReachedMax(this InnerShineRecord ISR, int max)
+ {
+ bool flag = ISR.spawned.NullOrEmpty();
+ return !flag && ISR.spawned.Count() >= max;
+ }
+
+ public static bool HasCompatibleActivity(this InnerShineItem ISI, Pawn p)
+ {
+ bool flag = !ISI.HasRestriction;
+ bool result;
+ if (flag)
+ {
+ result = true;
+ }
+ else
+ {
+ ActivityRestriction restriction = ISI.restriction;
+ bool flag2 = restriction.HasPostureRestriction && !restriction.allowedPostures.Contains(p.GetPosture());
+ if (flag2)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag3 = restriction.HasJobRestriction && p.CurJob != null && !restriction.allowedJobs.Contains(p.CurJob.def);
+ if (flag3)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag4 = restriction.HasAllowedRotation && !restriction.allowedRotation.Contains(p.Rotation);
+ result = !flag4;
+ }
+ }
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ItemParameter.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ItemParameter.cs
new file mode 100644
index 0000000..b2dd1be
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ItemParameter.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class ItemParameter
+ {
+ public bool ThingSpawner
+ {
+ get
+ {
+ return this.thingToSpawn != null && this.pawnKindToSpawn == null;
+ }
+ }
+
+ public bool PawnSpawner
+ {
+ get
+ {
+ return this.thingToSpawn == null && this.pawnKindToSpawn != null;
+ }
+ }
+
+ public bool HasFactionParams
+ {
+ get
+ {
+ return !this.randomFactionParameters.NullOrEmpty();
+ }
+ }
+
+ public bool HasGraceChance
+ {
+ get
+ {
+ return this.graceChance != 0f;
+ }
+ }
+
+ public bool HasFilth
+ {
+ get
+ {
+ return this.filthDef != null;
+ }
+ }
+
+ public void LogParams(bool myDebug = false)
+ {
+ Tools.Warn(string.Concat(new object[]
+ {
+ "ThingSpawner:",
+ this.ThingSpawner.ToString(),
+ "; ",
+ this.ThingSpawner ? this.thingToSpawn.defName : "",
+ "PawnSpawner:",
+ this.PawnSpawner.ToString(),
+ "; ",
+ this.PawnSpawner ? this.pawnKindToSpawn.defName : "",
+ "spawnCount:",
+ this.spawnCount,
+ "; weight:",
+ this.weight,
+ "; "
+ }), myDebug);
+ }
+
+ public void ComputeRandomParameters(out int calculatedTickUntilSpawn, out int calculatedGraceTicks, out int calculatedSpawnCount)
+ {
+ checked
+ {
+ calculatedTickUntilSpawn = (int)(unchecked(this.daysB4Next.RandomInRange * 60000f));
+ calculatedSpawnCount = this.spawnCount.RandomInRange;
+ calculatedGraceTicks = 0;
+ bool flag = this.HasGraceChance && Rand.Chance(this.graceChance);
+ if (flag)
+ {
+ calculatedGraceTicks = (int)(unchecked(this.graceDays.RandomInRange * 60000f));
+ }
+ }
+ }
+
+ public ThingDef thingToSpawn = null;
+
+ public PawnKindDef pawnKindToSpawn = null;
+
+ public IntRange spawnCount = new IntRange(1, 1);
+
+ public ThingDef filthDef = null;
+
+ public List randomFactionParameters;
+
+ public FloatRange daysB4Next = new FloatRange(1f, 2f);
+
+ public float graceChance = 0f;
+
+ public FloatRange graceDays = new FloatRange(1f, 2f);
+
+ public float weight = 0f;
+
+ public string spawnVerb = "delivery";
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/KeepingConditionCompatibility.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/KeepingConditionCompatibility.cs
new file mode 100644
index 0000000..1f175d7
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/KeepingConditionCompatibility.cs
@@ -0,0 +1,69 @@
+using System;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class KeepingConditionCompatibility
+ {
+ public static bool IsPawnNeedConditionCompatible(this Pawn p, HediffKeepingCondition HKC, bool debug = false)
+ {
+ string str = debug ? (p.Label + " IsPawnNeedConditionCompatible - ") : "";
+ bool hasNeedCondition = HKC.HasNeedCondition;
+ if (hasNeedCondition)
+ {
+ foreach (NeedCondition needCondition in HKC.needs)
+ {
+ bool flag = false;
+ foreach (Need need in p.needs.AllNeeds)
+ {
+ Tools.Warn(str + needCondition.needDef.defName + " found in pawn needs, ok", debug);
+ flag |= (need.def == needCondition.needDef);
+ }
+ bool flag2 = !flag;
+ if (flag2)
+ {
+ Tools.Warn(str + needCondition.needDef.defName + " not found in pawn needs, exiting", debug);
+ return false;
+ }
+ }
+ }
+ Tools.Warn(str + "is need compatible, ok", debug);
+ return true;
+ }
+
+ public static bool IsPawnNeedCompatible(this HediffCompProperties_OnTheCarpet Props, Pawn p)
+ {
+ bool debug = Props.debug;
+ string str = debug ? (p.Label + " IsPawnNeedCompatible - ") : "";
+ bool hasDefaultCondition = Props.HasDefaultCondition;
+ if (hasDefaultCondition)
+ {
+ Tools.Warn(str + "checking default condition", debug);
+ bool flag = !p.IsPawnNeedConditionCompatible(Props.defaultCondition, debug);
+ if (flag)
+ {
+ Tools.Warn(str + "defaultCondition not compatible with pawn, exiting", debug);
+ return false;
+ }
+ Tools.Warn(str + " Compatible with defaultCondition", debug);
+ }
+ foreach (HediffItemToRemove hediffItemToRemove in Props.hediffPool)
+ {
+ bool hasSpecificCondition = hediffItemToRemove.HasSpecificCondition;
+ if (hasSpecificCondition)
+ {
+ Tools.Warn(str + "checking " + hediffItemToRemove.hediffDef.defName + " specific condition", debug);
+ bool flag2 = !p.IsPawnNeedConditionCompatible(hediffItemToRemove.specificCondition, debug);
+ if (flag2)
+ {
+ Tools.Warn(str + "specificCondition not compatible with pawn, exiting", debug);
+ return false;
+ }
+ Tools.Warn(str + " Compatible with specificCondition", debug);
+ }
+ }
+ return true;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/LightCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/LightCondition.cs
new file mode 100644
index 0000000..40ae3fd
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/LightCondition.cs
@@ -0,0 +1,29 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class LightCondition
+ {
+ public bool RequiresLightLevel
+ {
+ get
+ {
+ return this.level != null;
+ }
+ }
+
+ public LightCondition(LightCondition copyMe)
+ {
+ this.requiresInside = copyMe.requiresInside;
+ this.requiresOutside = copyMe.requiresOutside;
+ this.level = copyMe.level;
+ }
+
+ public bool requiresOutside = true;
+
+ public bool requiresInside = false;
+
+ public FloatRange? level;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStateOption.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStateOption.cs
new file mode 100644
index 0000000..abedb6d
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStateOption.cs
@@ -0,0 +1,24 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class MentalStateOption
+ {
+ public void Dump()
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ "MentalStateDef:",
+ this.mentalDef.defName,
+ "; weight:",
+ this.weight,
+ "; "
+ }));
+ }
+
+ public MentalStateDef mentalDef;
+
+ public float weight = 1f;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStatePicker.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStatePicker.cs
new file mode 100644
index 0000000..7d4bf08
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MentalStatePicker.cs
@@ -0,0 +1,87 @@
+using System;
+using System.Collections.Generic;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class MentalStatePicker
+ {
+ public static float MSTotalWeight(this List MSO)
+ {
+ float num = 0f;
+ for (int i = 0; i < MSO.Count; i = checked(i + 1))
+ {
+ num += MSO[i].weight;
+ }
+ return num;
+ }
+
+ public static void ComputeRandomMentalState(this HediffComp_RandySpawnUponDeath comp)
+ {
+ bool flag = !comp.ChosenItem.HasMentalStateParams;
+ if (!flag)
+ {
+ MentalStateDef weightedRandomMentalState = comp.GetWeightedRandomMentalState();
+ bool flag2 = weightedRandomMentalState == null;
+ if (flag2)
+ {
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("ComputeRandomMentalState - found no MentalStateDef");
+ }
+ }
+ else
+ {
+ comp.RandomMS = weightedRandomMentalState;
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ string str = "ComputeRandomFaction - found:";
+ Faction randomFaction = comp.RandomFaction;
+ Log.Warning(str + ((randomFaction != null) ? randomFaction.GetCallLabel() : null));
+ }
+ }
+ }
+ }
+
+ public static MentalStateDef GetWeightedRandomMentalState(this HediffComp_RandySpawnUponDeath comp)
+ {
+ bool flag = !comp.HasChosenPawn || !comp.ChosenItem.HasMentalStateParams;
+ checked
+ {
+ MentalStateDef result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ List mentalState = comp.ChosenItem.mentalState;
+ float num = Rand.Range(0f, mentalState.MSTotalWeight());
+ for (int i = 0; i < mentalState.Count; i++)
+ {
+ bool flag2 = unchecked(num -= mentalState[i].weight) < 0f;
+ if (flag2)
+ {
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("GetWeightedRandomIndex : returning " + i);
+ }
+ return mentalState[i].mentalDef;
+ }
+ }
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning("GetWeightedRandomMentalState : failed to return proper index, returning null");
+ }
+ result = null;
+ }
+ return result;
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoharHediffs.csproj b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoharHediffs.csproj
new file mode 100644
index 0000000..a2e4e89
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoharHediffs.csproj
@@ -0,0 +1,151 @@
+
+
+
+ Debug
+ AnyCPU
+ {7ACFB1B0-3B20-48B9-BA73-48DD6353ABED}
+ Library
+ Properties
+ MoharHediffs
+ MoharHediffs
+ v4.8
+ 4096
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+ ..\..\..\..\..\..\..\..\..\..\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll
+
+
+ ..\..\..\..\..\..\..\..\..\..\Steam\steamapps\workshop\content\294100\2057001924\1.5\Assemblies\MoharGfx.dll
+
+
+ ..\..\..\..\..\..\..\..\..\..\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\System.Core.dll
+
+
+ ..\..\..\..\..\..\..\..\..\..\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteColorChangeUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteColorChangeUtils.cs
new file mode 100644
index 0000000..6757320
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteColorChangeUtils.cs
@@ -0,0 +1,63 @@
+using System;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class MoteColorChangeUtils
+ {
+ public static int GetProgressSign(float limA, float limB, float val)
+ {
+ bool flag = val <= limA && limA < limB;
+ int result;
+ if (flag)
+ {
+ result = 1;
+ }
+ else
+ {
+ bool flag2 = val >= limB && limB > limA;
+ if (flag2)
+ {
+ result = -1;
+ }
+ else
+ {
+ result = (Rand.Chance(0.5f) ? 1 : -1);
+ }
+ }
+ return result;
+ }
+
+ public static Color RandomPickColor(this ColorRange colorRange, Color oldColor, bool debug = false)
+ {
+ float variationPerIteration = colorRange.variationPerIteration;
+ float num = Rand.Range(0f, variationPerIteration);
+ float num2 = Rand.Range(0f, variationPerIteration - num);
+ float num3 = variationPerIteration - num - num2;
+ int progressSign = MoteColorChangeUtils.GetProgressSign(colorRange.colorA.r, colorRange.colorB.r, oldColor.r);
+ int progressSign2 = MoteColorChangeUtils.GetProgressSign(colorRange.colorA.g, colorRange.colorB.g, oldColor.g);
+ int progressSign3 = MoteColorChangeUtils.GetProgressSign(colorRange.colorA.b, colorRange.colorB.b, oldColor.b);
+ float num4 = Math.Abs(colorRange.colorA.r - colorRange.colorB.r) * num * (float)progressSign;
+ float num5 = Math.Abs(colorRange.colorA.g - colorRange.colorB.g) * num2 * (float)progressSign3;
+ float num6 = Math.Abs(colorRange.colorA.b - colorRange.colorB.b) * num3 * (float)progressSign2;
+ Color result = new Color((oldColor.r + num4).Clamp(colorRange.colorA.r, colorRange.colorB.r), (oldColor.g + num5).Clamp(colorRange.colorA.g, colorRange.colorB.g), (oldColor.b + num6).Clamp(colorRange.colorA.b, colorRange.colorB.b));
+ return result;
+ }
+
+ public static void ChangeMoteColor(this HediffComp_TrailLeaver comp, Mote mote)
+ {
+ bool flag = !comp.Props.HasColorRange || mote == null;
+ if (!flag)
+ {
+ bool flag2 = comp.lastColor == Color.black;
+ if (flag2)
+ {
+ comp.lastColor = comp.Props.colorRange.colorA;
+ }
+ comp.lastColor = comp.Props.colorRange.RandomPickColor(comp.lastColor, comp.MyDebug);
+ mote.instanceColor = comp.lastColor;
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteLink.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteLink.cs
new file mode 100644
index 0000000..95f3c33
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteLink.cs
@@ -0,0 +1,33 @@
+using System;
+using RimWorld;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class MoteLink
+ {
+ public static Vector3 GetLinkOffset(this Pawn p, MoteLink.Nature linkType)
+ {
+ Vector3 result;
+ if (linkType != MoteLink.Nature.head)
+ {
+ if (linkType != MoteLink.Nature.body)
+ {
+ }
+ result = Vector3.zero;
+ }
+ else
+ {
+ result = p.Drawer.renderer.BaseHeadOffsetAt((p.GetPosture() == PawnPosture.Standing) ? Rot4.North : p.Drawer.renderer.LayingFacing()).RotatedBy(p.Drawer.renderer.BodyAngle(PawnRenderFlags.Cache));
+ }
+ return result;
+ }
+
+ public enum Nature
+ {
+ head,
+ body
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteSpawnUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteSpawnUtils.cs
new file mode 100644
index 0000000..0b97de4
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MoteSpawnUtils.cs
@@ -0,0 +1,111 @@
+using System;
+using MoharGfx;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class MoteSpawnUtils
+ {
+ public static Thing TryMoteSpawn(this Vector3 loc, Map map, float rot, float scale, ThingDef moteDef, bool debug = false)
+ {
+ bool flag = loc.ForbiddenMote(map);
+ Thing result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ bool flag2 = moteDef == null;
+ if (flag2)
+ {
+ if (debug)
+ {
+ Log.Warning("null mote");
+ }
+ result = null;
+ }
+ else
+ {
+ MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(moteDef, null);
+ bool flag3 = moteThrown == null;
+ if (flag3)
+ {
+ result = null;
+ }
+ else
+ {
+ moteThrown.Scale = scale;
+ moteThrown.exactRotation = rot;
+ moteThrown.exactPosition = loc;
+ result = GenSpawn.Spawn(moteThrown, loc.ToIntVec3(), map, WipeMode.Vanish);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Thing TryAnyMoteSpawn(this Vector3 loc, Map map, float rot, float scale, ThingDef moteDef, bool debug = false)
+ {
+ bool flag = loc.ForbiddenMote(map);
+ Thing result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ bool flag2 = moteDef == null;
+ if (flag2)
+ {
+ if (debug)
+ {
+ Log.Warning("null mote");
+ }
+ result = null;
+ }
+ else
+ {
+ Type thingClass = moteDef.thingClass;
+ bool flag3 = thingClass == typeof(CustomTransformation_Mote);
+ if (flag3)
+ {
+ CustomTransformation_Mote mote = (CustomTransformation_Mote)ThingMaker.MakeThing(moteDef, null);
+ result = mote.FinalizeMoteSpawn(loc, map, rot, scale);
+ }
+ else
+ {
+ bool flag4 = thingClass == typeof(MoteThrown);
+ if (flag4)
+ {
+ MoteThrown mote2 = (MoteThrown)ThingMaker.MakeThing(moteDef, null);
+ result = mote2.FinalizeMoteSpawn(loc, map, rot, scale);
+ }
+ else
+ {
+ result = null;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Thing FinalizeMoteSpawn(this CustomTransformation_Mote mote, Vector3 loc, Map map, float rot, float scale)
+ {
+ mote.Scale = scale;
+ mote.exactRotation = rot;
+ mote.exactPosition = loc;
+ return GenSpawn.Spawn(mote, loc.ToIntVec3(), map, WipeMode.Vanish);
+ }
+
+ public static Thing FinalizeMoteSpawn(this MoteThrown mote, Vector3 loc, Map map, float rot, float scale)
+ {
+ mote.Scale = scale;
+ mote.exactRotation = rot;
+ mote.exactPosition = loc;
+ return GenSpawn.Spawn(mote, loc.ToIntVec3(), map, WipeMode.Vanish);
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyDefs.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyDefs.cs
new file mode 100644
index 0000000..bd030a0
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyDefs.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace MoharHediffs
+{
+ public static class MyDefs
+ {
+ public static int OneYearTicks = 3600000;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyGfx.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyGfx.cs
new file mode 100644
index 0000000..34c7652
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/MyGfx.cs
@@ -0,0 +1,24 @@
+using System;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ [StaticConstructorOnStartup]
+ public class MyGfx
+ {
+ public static Color Purple = new Color(1f, 0f, 1f);
+
+ public static Color Blue = new Color(0f, 0f, 1f);
+
+ public static Color Cyan = new Color(0f, 1f, 1f);
+
+ public static Color Green = new Color(0f, 1f, 0f);
+
+ public static Color Yellow = new Color(1f, 1f, 0f);
+
+ public static Color Orange = new Color(1f, 0.6f, 0f);
+
+ public static Color Red = new Color(1f, 0f, 1f);
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NeedCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NeedCondition.cs
new file mode 100644
index 0000000..d059309
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NeedCondition.cs
@@ -0,0 +1,23 @@
+using System;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class NeedCondition
+ {
+ public NeedCondition(NeedCondition copyMe)
+ {
+ this.needDef = copyMe.needDef;
+ this.level = copyMe.level;
+ }
+
+ public NeedCondition()
+ {
+ }
+
+ public NeedDef needDef;
+
+ public FloatRange level;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NoMsgRandHediffGiver.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NoMsgRandHediffGiver.cs
new file mode 100644
index 0000000..89afe7e
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/NoMsgRandHediffGiver.cs
@@ -0,0 +1,19 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class NoMsgRandHediffGiver : HediffGiver
+ {
+ public override void OnIntervalPassed(Pawn pawn, Hediff cause)
+ {
+ bool flag = Rand.MTBEventOccurs(this.mtbDays, 60000f, 60f);
+ if (flag)
+ {
+ base.TryApply(pawn, null);
+ }
+ }
+
+ public float mtbDays;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ParametersHandlingsUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ParametersHandlingsUtils.cs
new file mode 100644
index 0000000..e7ed5b4
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/ParametersHandlingsUtils.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Linq;
+using RimWorld;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class ParametersHandlingsUtils
+ {
+ public static bool IsTerrainAllowed(this HediffComp_TrailLeaver comp, TerrainDef terrain)
+ {
+ bool flag = terrain == null || comp.NullMap;
+ bool result;
+ if (flag)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag2 = !comp.HasTerrainRestriction;
+ if (flag2)
+ {
+ result = true;
+ }
+ else
+ {
+ TerrainRestriction terrainRestriction = comp.TerrainRestriction;
+ bool flag3 = !terrainRestriction.allowedInWater && terrain.IsWater;
+ if (flag3)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag4 = terrainRestriction.HasRelevantSnowRestriction && !terrainRestriction.allowedSnowDepth.Includes(comp.MyMap.snowGrid.GetDepth(comp.Pawn.Position));
+ if (flag4)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag5 = terrainRestriction.HasForbiddenTerrains && terrainRestriction.forbiddenTerrains.Contains(terrain);
+ result = !flag5;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static bool IsPawnActivityCompatible(this HediffComp_TrailLeaver comp)
+ {
+ bool flag = !comp.HasPawnRestriction;
+ bool result;
+ if (flag)
+ {
+ result = true;
+ }
+ else
+ {
+ Restriction pawnRestriction = comp.PawnRestriction;
+ bool flag2 = pawnRestriction.HasPostureRestriction && !pawnRestriction.allowedPostures.Contains(comp.Pawn.GetPosture());
+ if (flag2)
+ {
+ result = false;
+ }
+ else
+ {
+ bool flag3 = pawnRestriction.onlyWhenMoving && !comp.Pawn.pather.MovingNow;
+ result = !flag3;
+ }
+ }
+ return result;
+ }
+
+ public static Vector3 GetBodyTypeOffset(this HediffComp_TrailLeaver comp)
+ {
+ Pawn_StoryTracker story = comp.Pawn.story;
+ bool flag = ((story != null) ? story.bodyType : null) == null || !comp.Props.HasOffset;
+ Vector3 result;
+ if (flag)
+ {
+ result = comp.Props.defaultOffset;
+ }
+ else
+ {
+ BodyTypeOffset bodyTypeOffset = (from b in comp.Props.offSetPerBodyType
+ where b.bodyType == comp.Pawn.story.bodyType
+ select b).FirstOrFallback(null);
+ result = ((bodyTypeOffset == null) ? comp.Props.defaultOffset : bodyTypeOffset.offset);
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCondition.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCondition.cs
new file mode 100644
index 0000000..09eb125
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCondition.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using Verse;
+
+namespace MoharHediffs
+{
+ public class PawnCondition
+ {
+ public bool HasRace
+ {
+ get
+ {
+ return !this.race.NullOrEmpty();
+ }
+ }
+
+ public bool HasGender
+ {
+ get
+ {
+ return !this.gender.NullOrEmpty();
+ }
+ }
+
+ public List race;
+
+ public FloatRange ageRange = new FloatRange(0f, 999f);
+
+ public List gender;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCopyUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCopyUtils.cs
new file mode 100644
index 0000000..ca06390
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnCopyUtils.cs
@@ -0,0 +1,344 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using AlienRace;
+using RimWorld;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class PawnCopyUtils
+ {
+ public static void SetAge(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ ThingSettings chosenItem = comp.ChosenItem;
+ bool flag = chosenItem.IsCopier && chosenItem.copyParent.age;
+ if (flag)
+ {
+ LifeStageDef LSDef = comp.Pawn.ageTracker.CurLifeStage;
+ LifeStageAge lifeStageAge = (from LS in comp.Pawn.def.race.lifeStageAges
+ where LS.def == LSDef
+ select LS).FirstOrFallback(null);
+ bool flag2 = lifeStageAge == null;
+ if (!flag2)
+ {
+ newPawn.ageTracker.AgeBiologicalTicks = checked((long)(unchecked(lifeStageAge.minAge * (float)MyDefs.OneYearTicks)));
+ newPawn.ageTracker.AgeChronologicalTicks = Math.Max(comp.Pawn.ageTracker.AgeBiologicalTicks, comp.Pawn.ageTracker.AgeChronologicalTicks);
+ }
+ }
+ else
+ {
+ newPawn.ageTracker.AgeBiologicalTicks = (long)(checked(MyDefs.OneYearTicks * chosenItem.biologicalAgeRange.RandomInRange));
+ newPawn.ageTracker.AgeChronologicalTicks = checked(unchecked((long)(checked(MyDefs.OneYearTicks * chosenItem.chronologicalAgeRange.RandomInRange))) + newPawn.ageTracker.AgeBiologicalTicks);
+ }
+ }
+
+ public static void SetName(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool name = comp.ChosenItem.copyParent.name;
+ if (name)
+ {
+ newPawn.Name = comp.Pawn.Name;
+ }
+ }
+
+ public static void SetGender(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool gender = comp.ChosenItem.copyParent.gender;
+ if (gender)
+ {
+ newPawn.gender = comp.Pawn.gender;
+ }
+ }
+
+ public static void SetMelanin(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool melanin = comp.ChosenItem.copyParent.melanin;
+ if (melanin)
+ {
+ newPawn.story.SkinColorBase = comp.Pawn.story.SkinColorBase;
+ }
+ }
+
+ public static void SetAlienSkinColor(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ AlienPartGenerator.AlienComp alienComp = comp.Pawn.TryGetComp();
+ AlienPartGenerator.AlienComp alienComp2 = (newPawn != null) ? newPawn.TryGetComp() : null;
+ bool flag = alienComp == null || alienComp2 == null;
+ if (!flag)
+ {
+ Color first = alienComp.GetChannel("skin").first;
+ Color second = alienComp.GetChannel("skin").second;
+ alienComp2.GetChannel("skin").first = first;
+ alienComp2.GetChannel("skin").second = second;
+ }
+ }
+
+ public static void SetAlienBodyAndHeadType(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool flag = !comp.Pawn.IsAlien() || !newPawn.IsAlien();
+ if (!flag)
+ {
+ AlienPartGenerator.AlienComp alienComp = comp.Pawn.TryGetComp();
+ AlienPartGenerator.AlienComp alienComp2 = (newPawn != null) ? newPawn.TryGetComp() : null;
+ bool flag2 = alienComp == null || alienComp2 == null;
+ if (!flag2)
+ {
+ newPawn.story.headType = comp.Pawn.story.headType;
+ alienComp2.headMaskVariant = alienComp.headMaskVariant;
+ alienComp2.headVariant = alienComp.headVariant;
+ newPawn.story.bodyType = comp.Pawn.story.bodyType;
+ alienComp2.bodyMaskVariant = alienComp.bodyMaskVariant;
+ alienComp2.bodyVariant = alienComp.bodyVariant;
+ }
+ }
+ }
+
+ public static void SetHair(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool hair = comp.ChosenItem.copyParent.hair;
+ if (hair)
+ {
+ newPawn.story.hairDef = comp.Pawn.story.hairDef;
+ }
+ }
+
+ public static void SetHairColor(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool hairColor = comp.ChosenItem.copyParent.hairColor;
+ if (hairColor)
+ {
+ newPawn.story.HairColor = comp.Pawn.story.HairColor;
+ }
+ }
+
+ public static void SetHediff(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool flag = !comp.ChosenItem.copyParent.hediff;
+ if (!flag)
+ {
+ newPawn.health.hediffSet.hediffs = new List();
+ List hediffs = comp.ChosenItem.copyParent.HasHediffExclusion ? (from h in comp.Pawn.health.hediffSet.hediffs.ListFullCopy()
+ where !comp.ChosenItem.copyParent.excludeHediff.Contains(h.def) && (!comp.ChosenItem.copyParent.excludeTendableHediffs || !h.def.tendable) && (!comp.ChosenItem.copyParent.excludePermanentHediffs || h.TryGetComp() == null)
+ select h).ToList() : comp.Pawn.health.hediffSet.hediffs.ListFullCopy();
+ newPawn.health.hediffSet.hediffs = hediffs;
+ }
+ }
+
+ public static void SetSkills(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, bool debug = false)
+ {
+ bool flag = !comp.ChosenItem.copyParent.skills;
+ checked
+ {
+ if (!flag)
+ {
+ string text = newPawn.LabelShort + " - SetSkills - ";
+ for (int i = 0; i < newPawn.skills.skills.Count; i++)
+ {
+ float randomInRange = comp.ChosenItem.copyParent.skillDecay.RandomInRange;
+ int num = (int)(unchecked((float)comp.Pawn.skills.skills[i].levelInt * randomInRange));
+ if (debug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " browsing ",
+ comp.Pawn.skills.skills[i].def.defName,
+ " ori: ",
+ comp.Pawn.skills.skills[i].levelInt,
+ " new: ",
+ newPawn.skills.skills[i].levelInt,
+ " decayRatio: ",
+ randomInRange,
+ " wantedSkill: ",
+ num
+ }));
+ }
+ bool flag2 = num > newPawn.skills.skills[i].levelInt;
+ if (flag2)
+ {
+ if (debug)
+ {
+ Log.Warning(text + "Calling gainskill");
+ }
+ comp.GainSkill(newPawn, num, i, debug);
+ }
+ else
+ {
+ bool flag3 = num < newPawn.skills.skills[i].levelInt;
+ if (flag3)
+ {
+ if (debug)
+ {
+ Log.Warning(text + "Calling loseskill");
+ }
+ comp.LoseSkill(newPawn, num, i, debug);
+ }
+ }
+ if (debug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " copied skill [",
+ i,
+ "]:",
+ comp.Pawn.skills.skills[i].def.defName,
+ " new: ",
+ newPawn.skills.skills[i].levelInt
+ }));
+ }
+ }
+ }
+ }
+ }
+
+ public static void GainSkill(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, int wantedLevel, int index, bool debug = false)
+ {
+ string text = newPawn.LabelShort + " - GainSkill - ";
+ if (debug)
+ {
+ Log.Warning(text + "Entering");
+ }
+ int num = 20;
+ checked
+ {
+ while (wantedLevel > newPawn.skills.skills[index].levelInt && num > 0)
+ {
+ float xpRequiredForLevelUp = newPawn.skills.skills[index].XpRequiredForLevelUp;
+ if (debug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " loop: ",
+ num,
+ " xpInjected: ",
+ xpRequiredForLevelUp,
+ " ori: ",
+ comp.Pawn.skills.skills[index].levelInt,
+ " new: ",
+ newPawn.skills.skills[index].levelInt
+ }));
+ }
+ newPawn.skills.skills[index].Learn(xpRequiredForLevelUp, true, false);
+ num--;
+ }
+ }
+ }
+
+ public static void LoseSkill(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, int wantedLevel, int index, bool debug = false)
+ {
+ string text = newPawn.LabelShort + " - LoseSkill - ";
+ if (debug)
+ {
+ Log.Warning(text + "Entering");
+ }
+ int num = 20;
+ checked
+ {
+ while (wantedLevel < newPawn.skills.skills[index].levelInt && num > 0)
+ {
+ float num2 = (float)(0 - newPawn.skills.skills[index].levelInt * 1000);
+ if (debug)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ " loop: ",
+ num,
+ " xpInjected: ",
+ num2,
+ " ori: ",
+ comp.Pawn.skills.skills[index].levelInt,
+ " new: ",
+ newPawn.skills.skills[index].levelInt
+ }));
+ }
+ newPawn.skills.skills[index].Learn(num2, true, false);
+ num--;
+ }
+ }
+ }
+
+ public static void SetPassions(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, bool debug = false)
+ {
+ bool flag = !comp.ChosenItem.copyParent.passions;
+ checked
+ {
+ if (!flag)
+ {
+ for (int i = 0; i < newPawn.skills.skills.Count; i++)
+ {
+ newPawn.skills.skills[i].passion = comp.Pawn.skills.skills[i].passion;
+ }
+ }
+ }
+ }
+
+ public static void InitRememberBackstories(out BackstoryDef childBS, out BackstoryDef adultBS)
+ {
+ BackstoryDef backstoryDef;
+ adultBS = (backstoryDef = null);
+ childBS = backstoryDef;
+ }
+
+ public static void ResetBackstories(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ newPawn.story.Childhood = null;
+ newPawn.story.Adulthood = null;
+ }
+
+ public static void RememberBackstories(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, out BackstoryDef childBS, out BackstoryDef adultBS)
+ {
+ childBS = newPawn.story.Childhood;
+ adultBS = newPawn.story.Adulthood;
+ }
+
+ public static void ReinjectBackstories(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn, BackstoryDef childBS, BackstoryDef adultBS)
+ {
+ newPawn.story.Childhood = childBS;
+ newPawn.story.Adulthood = adultBS;
+ }
+
+ public static void SetBackstories(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool childBS = comp.ChosenItem.copyParent.childBS;
+ if (childBS)
+ {
+ newPawn.story.Childhood = comp.Pawn.story.Childhood;
+ }
+ bool adultBS = comp.ChosenItem.copyParent.adultBS;
+ if (adultBS)
+ {
+ newPawn.story.Adulthood = comp.Pawn.story.Adulthood;
+ }
+ }
+
+ public static void SetTraits(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool flag = !comp.ChosenItem.copyParent.traits;
+ checked
+ {
+ if (!flag)
+ {
+ for (int i = newPawn.story.traits.allTraits.Count - 1; i >= 0; i--)
+ {
+ newPawn.story.traits.allTraits.RemoveAt(i);
+ }
+ newPawn.story.traits.allTraits = comp.Pawn.story.traits.allTraits.ListFullCopy();
+ }
+ }
+ }
+
+ public static void UpdateDisabilities(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool flag = newPawn.skills == null;
+ if (!flag)
+ {
+ newPawn.skills.Notify_SkillDisablesChanged();
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnRedressUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnRedressUtils.cs
new file mode 100644
index 0000000..1928302
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/PawnRedressUtils.cs
@@ -0,0 +1,63 @@
+using System;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class PawnRedressUtils
+ {
+ public static void DestroyInventory(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool destroyInventory = comp.ChosenItem.redressNewPawn.destroyInventory;
+ if (destroyInventory)
+ {
+ newPawn.inventory.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish);
+ }
+ }
+
+ public static void DestroyEquipment(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool destroyEquipment = comp.ChosenItem.redressNewPawn.destroyEquipment;
+ if (destroyEquipment)
+ {
+ newPawn.equipment.DestroyAllEquipment(DestroyMode.Vanish);
+ }
+ }
+
+ public static void DestroyApparel(this HediffComp_RandySpawnUponDeath comp, Pawn newPawn)
+ {
+ bool destroyApparel = comp.ChosenItem.redressNewPawn.destroyApparel;
+ if (destroyApparel)
+ {
+ newPawn.apparel.DestroyAll(DestroyMode.Vanish);
+ }
+ }
+
+ public static bool StripCorpse(this HediffComp_RandySpawnUponDeath comp, Corpse corpse)
+ {
+ bool result = false;
+ bool flag = comp.Props.HasParentRedress && comp.Props.redressParent.strip && !corpse.Negligible();
+ if (flag)
+ {
+ result = true;
+ bool flag2 = corpse.AnythingToStrip();
+ if (flag2)
+ {
+ corpse.Strip(true);
+ }
+ }
+ return result;
+ }
+
+ public static bool DestroyCorpse(this HediffComp_RandySpawnUponDeath comp, Corpse corpse)
+ {
+ bool result = false;
+ bool flag = comp.Props.HasParentRedress && comp.Props.redressParent.destroyCorpse && !corpse.Negligible();
+ if (flag)
+ {
+ result = true;
+ corpse.DeSpawn(DestroyMode.Vanish);
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Properties/AssemblyInfo.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..205d85b
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/Properties/AssemblyInfo.cs
@@ -0,0 +1,9 @@
+using System;
+using System.Diagnostics;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.Versioning;
+
+[assembly: AssemblyVersion("0.0.0.0")]
+[assembly: AssemblyTitle("MoharHediffs")]
+[assembly: AssemblyProduct("MoharHediffs")]
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomFactionParameter.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomFactionParameter.cs
new file mode 100644
index 0000000..051277a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomFactionParameter.cs
@@ -0,0 +1,96 @@
+using System;
+using RimWorld;
+
+namespace MoharHediffs
+{
+ public class RandomFactionParameter
+ {
+ public bool HasInheritedFaction
+ {
+ get
+ {
+ return this.inheritedFaction;
+ }
+ }
+
+ public bool HasForcedFaction
+ {
+ get
+ {
+ return this.forcedFaction != null;
+ }
+ }
+
+ public bool HasPlayerFaction
+ {
+ get
+ {
+ return this.playerFaction;
+ }
+ }
+
+ public bool HasNoFaction
+ {
+ get
+ {
+ return this.noFaction;
+ }
+ }
+
+ public bool HasDefaultPawnKindFaction
+ {
+ get
+ {
+ return this.defaultPawnKindFaction;
+ }
+ }
+
+ public bool IsLegitRandomFactionParameter()
+ {
+ int num = 0;
+ bool hasInheritedFaction = this.HasInheritedFaction;
+ checked
+ {
+ if (hasInheritedFaction)
+ {
+ num++;
+ }
+ bool hasForcedFaction = this.HasForcedFaction;
+ if (hasForcedFaction)
+ {
+ num++;
+ }
+ bool hasPlayerFaction = this.HasPlayerFaction;
+ if (hasPlayerFaction)
+ {
+ num++;
+ }
+ bool hasNoFaction = this.HasNoFaction;
+ if (hasNoFaction)
+ {
+ num++;
+ }
+ bool hasDefaultPawnKindFaction = this.HasDefaultPawnKindFaction;
+ if (hasDefaultPawnKindFaction)
+ {
+ num++;
+ }
+ return num == 1;
+ }
+ }
+
+ public bool inheritedFaction = false;
+
+ public FactionDef forcedFaction = null;
+
+ public bool playerFaction = false;
+
+ public bool defaultPawnKindFaction = false;
+
+ public bool noFaction = false;
+
+ public bool newBorn = false;
+
+ public float weight;
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomPicker.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomPicker.cs
new file mode 100644
index 0000000..36d8f83
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandomPicker.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class RandomPicker
+ {
+ public static List GetCompatibleItems(this HediffComp_AnotherRandom comp)
+ {
+ List list = new List();
+ foreach (HediffItem hediffItem in comp.Props.hediffPool)
+ {
+ HediffCompProperties_AnotherRandom props = comp.Props;
+ HediffCondition defaultPlusSpecificHediffCondition = ConditionBuilder.GetDefaultPlusSpecificHediffCondition(((props != null) ? props.defaultCondition : null) ?? null, ((hediffItem != null) ? hediffItem.specificCondition : null) ?? null, comp.HighVerbosity);
+ BodyPartRecord bodyPartRecord;
+ bool flag = defaultPlusSpecificHediffCondition.HasBodypartCondition ? defaultPlusSpecificHediffCondition.bodyPart.GetBPRFromHediffCondition(comp.Pawn, out bodyPartRecord, false) : (!defaultPlusSpecificHediffCondition.HasPawnCondition || defaultPlusSpecificHediffCondition.pawn.ValidateCompatibilityOfHediffWithPawn(comp.Pawn, false));
+ if (flag)
+ {
+ list.Add(hediffItem);
+ }
+ }
+ bool flag2 = !list.NullOrEmpty();
+ List result;
+ if (flag2)
+ {
+ result = list;
+ }
+ else
+ {
+ result = null;
+ }
+ return result;
+ }
+
+ public static List GetRemainingItems(this List hediffItems, List AlreadyPickedItems)
+ {
+ return (from hi in hediffItems
+ where !AlreadyPickedItems.Contains(hi)
+ select hi).ToList();
+ }
+
+ public static float GetWeight(this List HL)
+ {
+ float num = 0f;
+ foreach (HediffItem hediffItem in HL)
+ {
+ num += hediffItem.weight;
+ }
+ return num;
+ }
+
+ public static HediffItem PickRandomWeightedItem(this List HL, bool debug = false)
+ {
+ float weight = HL.GetWeight();
+ float num = Rand.Range(0f, weight);
+ checked
+ {
+ for (int i = 0; i < HL.Count; i++)
+ {
+ bool flag = unchecked(num -= HL[i].weight) < 0f;
+ if (flag)
+ {
+ Tools.Warn("PickRandomWeightedItem : returning " + i, debug);
+ return HL[i];
+ }
+ }
+ return null;
+ }
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandyPickerUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandyPickerUtils.cs
new file mode 100644
index 0000000..f05680a
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandyPickerUtils.cs
@@ -0,0 +1,281 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using AlienRace;
+using UnityEngine;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class RandyPickerUtils
+ {
+ public static float ThingsTotalWeight(this HediffComp_RandySpawnUponDeath comp, List TSList)
+ {
+ string text = comp.MyDebug ? (comp.Pawn.LabelShort + " ThingsTotalWeight ") : "";
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(text + " searching total weights thing list");
+ }
+ float num = 0f;
+ for (int i = 0; i < TSList.Count; i = checked(i + 1))
+ {
+ num += TSList[i].weight;
+ }
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(text + " found: " + num);
+ }
+ return num;
+ }
+
+ public static bool SameColorAs(this Color colorA, Color colorB)
+ {
+ bool flag = (double)Math.Abs(colorA.r - colorB.r) < 0.01;
+ bool flag2 = (double)Math.Abs(colorA.g - colorB.g) < 0.01;
+ bool flag3 = (double)Math.Abs(colorA.b - colorB.b) < 0.01;
+ bool flag4 = (double)Math.Abs(colorA.a - colorB.a) < 0.01;
+ return flag && flag2 && flag3 && flag4;
+ }
+
+ public static Color PickAlienColor(this AlienPartGenerator.AlienComp a, string channelName, int channelNum)
+ {
+ return (channelNum == 1) ? a.GetChannel(channelName).first : ((channelNum == 2) ? a.GetChannel(channelName).second : Color.white);
+ }
+
+ public static Color PickStuffColor(this ThingDef tDef)
+ {
+ StuffProperties stuffProps = tDef.stuffProps;
+ bool flag;
+ if (stuffProps == null)
+ {
+ flag = false;
+ }
+ else
+ {
+ Color color = stuffProps.color;
+ flag = true;
+ }
+ bool flag2 = flag;
+ Color result;
+ if (flag2)
+ {
+ result = tDef.stuffProps.color;
+ }
+ else
+ {
+ ThingDefCountClass thingDefCountClass = tDef.butcherProducts.FirstOrDefault() ?? null;
+ bool flag3 = thingDefCountClass == null;
+ if (flag3)
+ {
+ result = Color.black;
+ }
+ else
+ {
+ ThingDef thingDef = thingDefCountClass.thingDef;
+ bool flag4;
+ if (thingDef == null)
+ {
+ flag4 = true;
+ }
+ else
+ {
+ StuffProperties stuffProps2 = thingDef.stuffProps;
+ Color? color2 = (stuffProps2 != null) ? new Color?(stuffProps2.color) : null;
+ flag4 = (color2 == null);
+ }
+ bool flag5 = flag4;
+ if (flag5)
+ {
+ result = Color.black;
+ }
+ else
+ {
+ result = thingDef.stuffProps.color;
+ }
+ }
+ }
+ return result;
+ }
+
+ public static List ThingSettingsWithColor(this HediffComp_RandySpawnUponDeath comp)
+ {
+ string text = comp.MyDebug ? (comp.Pawn.LabelShort + " ThingSettingsWithColor -") : "";
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning(text + " creating thing list with color");
+ }
+ bool flag = !comp.HasColorCondition || !comp.Pawn.IsAlien();
+ List result;
+ if (flag)
+ {
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(text + "Found no color condition or pawn is not alien");
+ }
+ result = null;
+ }
+ else
+ {
+ AlienPartGenerator.AlienComp alien = Tools.GetAlien(comp.Pawn);
+ bool flag2 = alien == null;
+ if (flag2)
+ {
+ bool myDebug3 = comp.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning(text + "Found no AlienPartGenerator.AlienComp");
+ }
+ result = null;
+ }
+ else
+ {
+ bool myDebug4 = comp.MyDebug;
+ if (myDebug4)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ "colors=> skin.first:",
+ alien.GetChannel("skin").first,
+ " skin.second:",
+ alien.GetChannel("skin").second
+ }));
+ }
+ List list = (from t in comp.FullOptionList
+ where t.IsThingSpawner && t.HasColorCondition
+ select t).ToList();
+ bool myDebug5 = comp.MyDebug;
+ if (myDebug5)
+ {
+ Log.Warning("Option num:" + list.Count);
+ }
+ Color PawnColor = alien.GetChannel("skin").first;
+ foreach (ThingSettings thingSettings in list)
+ {
+ bool myDebug6 = comp.MyDebug;
+ if (myDebug6)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ " TS.Def: ",
+ thingSettings.thingToSpawn.defName,
+ "; TS.color: ",
+ thingSettings.thingToSpawn.PickStuffColor(),
+ "; P.color: ",
+ PawnColor,
+ "; equals: ",
+ PawnColor.SameColorAs(thingSettings.thingToSpawn.PickStuffColor()).ToString()
+ }));
+ }
+ }
+ List list2 = new List();
+ list2 = (from t in comp.FullOptionList
+ where t.IsThingSpawner && t.HasColorCondition && PawnColor.SameColorAs(t.thingToSpawn.PickStuffColor())
+ select t).ToList();
+ bool myDebug7 = comp.MyDebug;
+ if (myDebug7)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ text,
+ "Found ",
+ list2.Count,
+ " things with color"
+ }));
+ }
+ result = list2;
+ }
+ }
+ return result;
+ }
+
+ public static List ThingSettingsWithExclusion(this HediffComp_RandySpawnUponDeath comp, List TSList, List AlreadyPickedOptions)
+ {
+ List list = new List();
+ list = comp.Props.settings.things.ListFullCopy();
+ foreach (int index in AlreadyPickedOptions)
+ {
+ list.RemoveAt(index);
+ }
+ return list;
+ }
+
+ public static int GetWeightedRandomIndex(this HediffComp_RandySpawnUponDeath comp, List AlreadyPickedOptions)
+ {
+ bool flag = !comp.Props.settings.HasSomethingToSpawn;
+ int result;
+ if (flag)
+ {
+ result = -1;
+ }
+ else
+ {
+ bool hasColorCondition = comp.HasColorCondition;
+ List list;
+ if (hasColorCondition)
+ {
+ list = comp.ThingSettingsWithColor();
+ }
+ else
+ {
+ list = comp.FullOptionList;
+ }
+ bool flag2 = !AlreadyPickedOptions.NullOrEmpty();
+ if (flag2)
+ {
+ list = comp.ThingSettingsWithExclusion(list, AlreadyPickedOptions);
+ }
+ float num = Rand.Range(0f, comp.ThingsTotalWeight(list));
+ int i = 0;
+ while (i < list.Count)
+ {
+ bool flag3 = (num -= list[i].weight) < 0f;
+ checked
+ {
+ if (flag3)
+ {
+ bool myDebug = comp.MyDebug;
+ if (myDebug)
+ {
+ Log.Warning("GetWeightedRandomIndex : returning thing " + i);
+ }
+ bool flag4 = AlreadyPickedOptions.NullOrEmpty() && !comp.HasColorCondition;
+ if (flag4)
+ {
+ return i;
+ }
+ int num2 = comp.Props.settings.things.IndexOf(list[i]);
+ bool myDebug2 = comp.MyDebug;
+ if (myDebug2)
+ {
+ Log.Warning(string.Concat(new object[]
+ {
+ "GetWeightedRandomIndex : returning thing ",
+ i,
+ " normalized:",
+ num2
+ }));
+ }
+ return num2;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ }
+ bool myDebug3 = comp.MyDebug;
+ if (myDebug3)
+ {
+ Log.Warning("GetWeightedRandomIndex : failed to return proper index, returning -1");
+ }
+ result = -1;
+ }
+ return result;
+ }
+ }
+}
diff --git a/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandySpawnerUtils.cs b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandySpawnerUtils.cs
new file mode 100644
index 0000000..dca77a6
--- /dev/null
+++ b/1.6/Core/Assemblies/FULLMOHAR/MoharHediffs/RandySpawnerUtils.cs
@@ -0,0 +1,348 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RimWorld;
+using Verse;
+
+namespace MoharHediffs
+{
+ public static class RandySpawnerUtils
+ {
+ public static float TotalWeight(this HediffComp_RandySpawner comp)
+ {
+ float num = 0f;
+ List itemParameters = comp.Props.itemParameters;
+ for (int i = 0; i < itemParameters.Count; i = checked(i + 1))
+ {
+ num += itemParameters[i].weight;
+ }
+ return num;
+ }
+
+ public static float TotalWeight(this List RFP)
+ {
+ float num = 0f;
+ for (int i = 0; i < RFP.Count; i = checked(i + 1))
+ {
+ num += RFP[i].weight;
+ }
+ return num;
+ }
+
+ public static void ComputeRandomFaction(this HediffComp_RandySpawner comp)
+ {
+ bool hasFactionParams = comp.CurIP.HasFactionParams;
+ if (hasFactionParams)
+ {
+ int weightedRandomFaction = comp.GetWeightedRandomFaction();
+ bool flag = weightedRandomFaction == -1;
+ if (flag)
+ {
+ Tools.Warn("ComputeRandomFaction - found no index", comp.MyDebug);
+ }
+ else
+ {
+ comp.newBorn = comp.CurIP.randomFactionParameters[weightedRandomFaction].newBorn;
+ RandomFactionParameter rfp = comp.CurIP.randomFactionParameters[weightedRandomFaction];
+ comp.Itemfaction = comp.GetFaction(rfp);
+ string str = "ComputeRandomFaction - found:";
+ Faction itemfaction = comp.Itemfaction;
+ Tools.Warn(str + ((itemfaction != null) ? itemfaction.GetCallLabel() : null), comp.MyDebug);
+ }
+ }
+ }
+
+ public static int GetWeightedRandomIndex(this HediffComp_RandySpawner comp)
+ {
+ float num = Rand.Range(0f, comp.TotalWeight());
+ List itemParameters = comp.Props.itemParameters;
+ checked
+ {
+ for (int i = 0; i < itemParameters.Count; i++)
+ {
+ bool flag = unchecked(num -= itemParameters[i].weight) < 0f;
+ if (flag)
+ {
+ Tools.Warn("GetWeightedRandomIndex : returning " + i, comp.MyDebug);
+ return i;
+ }
+ }
+ Tools.Warn("GetWeightedRandomIndex : failed to return proper index, returning -1", comp.MyDebug);
+ return -1;
+ }
+ }
+
+ public static int GetWeightedRandomFaction(this HediffComp_RandySpawner comp)
+ {
+ bool flag = !comp.HasValidIP || !comp.CurIP.HasFactionParams;
+ checked
+ {
+ int result;
+ if (flag)
+ {
+ result = -1;
+ }
+ else
+ {
+ List randomFactionParameters = comp.CurIP.randomFactionParameters;
+ float num = Rand.Range(0f, randomFactionParameters.TotalWeight());
+ for (int i = 0; i < randomFactionParameters.Count; i++)
+ {
+ bool flag2 = unchecked(num -= randomFactionParameters[i].weight) < 0f;
+ if (flag2)
+ {
+ Tools.Warn("GetWeightedRandomIndex : returning " + i, comp.MyDebug);
+ return i;
+ }
+ }
+ Tools.Warn("GetWeightedRandomFaction : failed to return proper index, returning -1", comp.MyDebug);
+ result = -1;
+ }
+ return result;
+ }
+ }
+
+ public static bool SetRequirementGraceTicks(this HediffComp_RandySpawner comp)
+ {
+ bool requiresFood = comp.RequiresFood;
+ bool requiresHealth = comp.RequiresHealth;
+ bool flag = requiresFood || requiresHealth;
+ checked
+ {
+ bool result;
+ if (flag)
+ {
+ bool flag2 = requiresFood;
+ if (flag2)
+ {
+ comp.hungerReset++;
+ }
+ else
+ {
+ comp.healthReset++;
+ }
+ bool hasValidIP = comp.HasValidIP;
+ if (hasValidIP)
+ {
+ comp.graceTicks = (int)(unchecked(comp.CurIP.graceDays.RandomInRange * 60000f));
+ }
+ result = true;
+ }
+ else
+ {
+ comp.hungerReset = (comp.healthReset = 0);
+ result = false;
+ }
+ return result;
+ }
+ }
+
+ public static void CheckProps(this HediffComp_RandySpawner comp)
+ {
+ bool flag = comp.Props.itemParameters.NullOrEmpty