mirror of
				https://gitgud.io/c0ffeeeeeeee/rjw-events.git
				synced 2024-08-14 23:57:42 +00:00 
			
		
		
		
	Add psychic lust mechanic, works like psychic drone
This commit is contained in:
		
							parent
							
								
									06122c2b18
								
							
						
					
					
						commit
						60a4205e6f
					
				
					 11 changed files with 383 additions and 0 deletions
				
			
		
							
								
								
									
										22
									
								
								Source/DefOfs/GameConditionDefOf.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Source/DefOfs/GameConditionDefOf.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
    [DefOf]
 | 
			
		||||
    public static class GameConditionDefOf
 | 
			
		||||
    {
 | 
			
		||||
        static GameConditionDefOf()
 | 
			
		||||
        {
 | 
			
		||||
            DefOfHelper.EnsureInitializedInCtor(typeof(GameConditionDefOf));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static GameConditionDef PsychicArouse;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using Verse;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
    public static class GameConditionManagerExtension
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public static PsychicDroneLevel GetHighestPsychicArouseLevelFor(this GameConditionManager g, Gender gender)
 | 
			
		||||
        {
 | 
			
		||||
			PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;
 | 
			
		||||
			for (int i = 0; i < g.ActiveConditions.Count; i++)
 | 
			
		||||
			{
 | 
			
		||||
				GameCondition_PsychicArouse gameCondition_PsychicEmanation = g.ActiveConditions[i] as GameCondition_PsychicArouse;
 | 
			
		||||
				if (gameCondition_PsychicEmanation != null && gameCondition_PsychicEmanation.gender == gender && gameCondition_PsychicEmanation.level > psychicDroneLevel)
 | 
			
		||||
				{
 | 
			
		||||
					psychicDroneLevel = gameCondition_PsychicEmanation.level;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			return psychicDroneLevel;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										123
									
								
								Source/GameConditions/GameCondition_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										123
									
								
								Source/GameConditions/GameCondition_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,123 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
using Verse.Grammar;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
    public class GameCondition_PsychicArouse : GameCondition
 | 
			
		||||
    {
 | 
			
		||||
		// Token: 0x17000EA2 RID: 3746
 | 
			
		||||
		// (get) Token: 0x06005437 RID: 21559 RVA: 0x001C44F0 File Offset: 0x001C26F0
 | 
			
		||||
		public override string Label
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				if (this.level == PsychicDroneLevel.GoodMedium)
 | 
			
		||||
				{
 | 
			
		||||
					return this.def.label + ": " + this.gender.GetLabel(false).CapitalizeFirst();
 | 
			
		||||
				}
 | 
			
		||||
				if (this.gender != Gender.None)
 | 
			
		||||
				{
 | 
			
		||||
					return string.Concat(new string[]
 | 
			
		||||
					{
 | 
			
		||||
						this.def.label,
 | 
			
		||||
						": ",
 | 
			
		||||
						this.level.GetLabel().CapitalizeFirst(),
 | 
			
		||||
						" (",
 | 
			
		||||
						this.gender.GetLabel(false).ToLower(),
 | 
			
		||||
						")"
 | 
			
		||||
					});
 | 
			
		||||
				}
 | 
			
		||||
				return this.def.label + ": " + this.level.GetLabel().CapitalizeFirst();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x17000EA3 RID: 3747
 | 
			
		||||
		// (get) Token: 0x06005438 RID: 21560 RVA: 0x001C45B4 File Offset: 0x001C27B4
 | 
			
		||||
		public override string LetterText
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				if (this.level == PsychicDroneLevel.GoodMedium)
 | 
			
		||||
				{
 | 
			
		||||
					return this.def.letterText.Formatted(this.gender.GetLabel(false).ToLower());
 | 
			
		||||
				}
 | 
			
		||||
				return this.def.letterText.Formatted(this.gender.GetLabel(false).ToLower(), this.level.GetLabel());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x17000EA4 RID: 3748
 | 
			
		||||
		// (get) Token: 0x06005439 RID: 21561 RVA: 0x001C4631 File Offset: 0x001C2831
 | 
			
		||||
		public override string Description
 | 
			
		||||
		{
 | 
			
		||||
			get
 | 
			
		||||
			{
 | 
			
		||||
				return base.Description.Formatted(this.gender.GetLabel(false).ToLower());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x0600543A RID: 21562 RVA: 0x001C4659 File Offset: 0x001C2859
 | 
			
		||||
		public override void PostMake()
 | 
			
		||||
		{
 | 
			
		||||
			base.PostMake();
 | 
			
		||||
			this.level = this.def.defaultDroneLevel;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x0600543B RID: 21563 RVA: 0x001C4674 File Offset: 0x001C2874
 | 
			
		||||
		public override void RandomizeSettings(float points, Map map, List<Rule> outExtraDescriptionRules, Dictionary<string, string> outExtraDescriptionConstants)
 | 
			
		||||
		{
 | 
			
		||||
			if (this.def.defaultDroneLevel == PsychicDroneLevel.GoodMedium)
 | 
			
		||||
			{
 | 
			
		||||
				this.level = PsychicDroneLevel.GoodMedium;
 | 
			
		||||
			}
 | 
			
		||||
			else if (points < 800f)
 | 
			
		||||
			{
 | 
			
		||||
				this.level = PsychicDroneLevel.BadLow;
 | 
			
		||||
			}
 | 
			
		||||
			else if (points < 2000f)
 | 
			
		||||
			{
 | 
			
		||||
				this.level = PsychicDroneLevel.BadMedium;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				this.level = PsychicDroneLevel.BadHigh;
 | 
			
		||||
			}
 | 
			
		||||
			if (map.mapPawns.FreeColonistsCount > 0)
 | 
			
		||||
			{
 | 
			
		||||
				this.gender = map.mapPawns.FreeColonists.RandomElement<Pawn>().gender;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				this.gender = Rand.Element<Gender>(Gender.Male, Gender.Female);
 | 
			
		||||
			}
 | 
			
		||||
			outExtraDescriptionRules.Add(new Rule_String("psychicArouseLevel", this.level.GetLabel()));
 | 
			
		||||
			outExtraDescriptionRules.Add(new Rule_String("psychicArouseGender", this.gender.GetLabel(false)));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x0600543C RID: 21564 RVA: 0x001C4730 File Offset: 0x001C2930
 | 
			
		||||
		public override void ExposeData()
 | 
			
		||||
		{
 | 
			
		||||
			base.ExposeData();
 | 
			
		||||
			Scribe_Values.Look<Gender>(ref this.gender, "psychicArouseGender", Gender.None, false);
 | 
			
		||||
			Scribe_Values.Look<PsychicDroneLevel>(ref this.level, "psychicArouseLevel", PsychicDroneLevel.None, false);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04003496 RID: 13462
 | 
			
		||||
		public Gender gender;
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04003497 RID: 13463
 | 
			
		||||
		public PsychicDroneLevel level = PsychicDroneLevel.BadMedium;
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04003498 RID: 13464
 | 
			
		||||
		public const float MaxPointsDroneLow = 800f;
 | 
			
		||||
 | 
			
		||||
		// Token: 0x04003499 RID: 13465
 | 
			
		||||
		public const float MaxPointsDroneMedium = 2000f;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										38
									
								
								Source/IncidentWorkers/IncidentWorker_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								Source/IncidentWorkers/IncidentWorker_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
    public class IncidentWorker_PsychicArouse : IncidentWorker_PsychicEmanation
 | 
			
		||||
    {
 | 
			
		||||
        protected override void DoConditionAndLetter(IncidentParms parms, Map map, int duration, Gender gender, float points)
 | 
			
		||||
        {
 | 
			
		||||
			PsychicDroneLevel level;
 | 
			
		||||
			if (points < 800f)
 | 
			
		||||
			{
 | 
			
		||||
				level = PsychicDroneLevel.BadLow;
 | 
			
		||||
			}
 | 
			
		||||
			else if (points < 2000f)
 | 
			
		||||
			{
 | 
			
		||||
				level = PsychicDroneLevel.BadMedium;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				level = PsychicDroneLevel.BadHigh;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			GameCondition_PsychicArouse gameCondition_PsychicEmanation = (GameCondition_PsychicArouse)GameConditionMaker.MakeCondition(GameConditionDefOf.PsychicArouse, duration);
 | 
			
		||||
 | 
			
		||||
			gameCondition_PsychicEmanation.gender = gender;
 | 
			
		||||
			gameCondition_PsychicEmanation.level = level;
 | 
			
		||||
 | 
			
		||||
			map.gameConditionManager.RegisterCondition(gameCondition_PsychicEmanation);
 | 
			
		||||
			base.SendStandardLetter(gameCondition_PsychicEmanation.LabelCap, gameCondition_PsychicEmanation.LetterText, gameCondition_PsychicEmanation.def.letterDef, parms, LookTargets.Invalid, Array.Empty<NamedArgument>());
 | 
			
		||||
		}
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										56
									
								
								Source/Patches/HarmonyPatch_Need_Sex.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								Source/Patches/HarmonyPatch_Need_Sex.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,56 @@
 | 
			
		|||
using HarmonyLib;
 | 
			
		||||
using rjw;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    [HarmonyPatch(typeof(Need_Sex), "fall_per_tick")]
 | 
			
		||||
    public static class HarmonyPatch_Need_Sex
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public static void Postfix(Pawn pawn, ref float __result)
 | 
			
		||||
        {
 | 
			
		||||
			PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;
 | 
			
		||||
			Map mapHeld = pawn.MapHeld;
 | 
			
		||||
			if (mapHeld != null)
 | 
			
		||||
			{
 | 
			
		||||
				PsychicDroneLevel highestPsychicDroneLevelFor = mapHeld.gameConditionManager.GetHighestPsychicArouseLevelFor(pawn.gender);
 | 
			
		||||
				if (highestPsychicDroneLevelFor > psychicDroneLevel)
 | 
			
		||||
				{
 | 
			
		||||
					psychicDroneLevel = highestPsychicDroneLevelFor;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			switch (psychicDroneLevel)
 | 
			
		||||
			{
 | 
			
		||||
				case PsychicDroneLevel.None:
 | 
			
		||||
					break;
 | 
			
		||||
				case PsychicDroneLevel.GoodMedium:
 | 
			
		||||
					__result *= 3;
 | 
			
		||||
					break;
 | 
			
		||||
				case PsychicDroneLevel.BadLow:
 | 
			
		||||
					__result *= 3;
 | 
			
		||||
					break;
 | 
			
		||||
				case PsychicDroneLevel.BadMedium:
 | 
			
		||||
					__result *= 6;
 | 
			
		||||
					break;
 | 
			
		||||
				case PsychicDroneLevel.BadHigh:
 | 
			
		||||
					__result *= 9;
 | 
			
		||||
					break;
 | 
			
		||||
				case PsychicDroneLevel.BadExtreme:
 | 
			
		||||
					__result *= 9;
 | 
			
		||||
					break;
 | 
			
		||||
				default:
 | 
			
		||||
					throw new NotImplementedException();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										46
									
								
								Source/ThoughtWorkers/ThoughtWorker_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								Source/ThoughtWorkers/ThoughtWorker_PsychicArouse.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,46 @@
 | 
			
		|||
using RimWorld;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Events
 | 
			
		||||
{
 | 
			
		||||
    class ThoughtWorker_PsychicArouse : ThoughtWorker
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        protected override ThoughtState CurrentStateInternal(Pawn p)
 | 
			
		||||
        {
 | 
			
		||||
			PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;
 | 
			
		||||
			Map mapHeld = p.MapHeld;
 | 
			
		||||
			if (mapHeld != null)
 | 
			
		||||
			{
 | 
			
		||||
				PsychicDroneLevel highestPsychicDroneLevelFor = mapHeld.gameConditionManager.GetHighestPsychicArouseLevelFor(p.gender);
 | 
			
		||||
				if (highestPsychicDroneLevelFor > psychicDroneLevel)
 | 
			
		||||
				{
 | 
			
		||||
					psychicDroneLevel = highestPsychicDroneLevelFor;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			switch (psychicDroneLevel)
 | 
			
		||||
			{
 | 
			
		||||
				case PsychicDroneLevel.None:
 | 
			
		||||
					return false;
 | 
			
		||||
				case PsychicDroneLevel.GoodMedium:
 | 
			
		||||
					return ThoughtState.ActiveAtStage(0);
 | 
			
		||||
				case PsychicDroneLevel.BadLow:
 | 
			
		||||
					return ThoughtState.ActiveAtStage(0);
 | 
			
		||||
				case PsychicDroneLevel.BadMedium:
 | 
			
		||||
					return ThoughtState.ActiveAtStage(1);
 | 
			
		||||
				case PsychicDroneLevel.BadHigh:
 | 
			
		||||
					return ThoughtState.ActiveAtStage(2);
 | 
			
		||||
				case PsychicDroneLevel.BadExtreme:
 | 
			
		||||
					return ThoughtState.ActiveAtStage(2);
 | 
			
		||||
				default:
 | 
			
		||||
					throw new NotImplementedException();
 | 
			
		||||
			}
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue