mirror of
				https://github.com/amevarashi/RJW-Sexperience.git
				synced 2024-08-14 23:54:08 +00:00 
			
		
		
		
	Removed GetGizmos patch. CompGetGizmosExtra now works for non-colonists!
This commit is contained in:
		
							parent
							
								
									9e0a461db3
								
							
						
					
					
						commit
						f363ed6c49
					
				
					 4 changed files with 17 additions and 44 deletions
				
			
		| 
						 | 
				
			
			@ -15,15 +15,16 @@ namespace RJWSexperience
 | 
			
		|||
				InjectRaces();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Roslynator", "RCS1146:Use conditional access.", Justification = "race != null is needed")]
 | 
			
		||||
		private static void InjectRaces()
 | 
			
		||||
		{
 | 
			
		||||
			IEnumerable<ThingDef> PawnDefs = DefDatabase<ThingDef>.AllDefs.Where(x => x.race != null && !x.race.IsMechanoid);
 | 
			
		||||
			if (PawnDefs.EnumerableNullOrEmpty())
 | 
			
		||||
				return;
 | 
			
		||||
 | 
			
		||||
			CompProperties comp = new CompProperties(typeof(SexHistoryComp));
 | 
			
		||||
			CompProperties compProperties = new CompProperties(typeof(SexHistoryComp));
 | 
			
		||||
			foreach (ThingDef def in PawnDefs)
 | 
			
		||||
				def.comps.Add(comp);
 | 
			
		||||
				def.comps.Add(compProperties);
 | 
			
		||||
 | 
			
		||||
			LogManager.GetLogger<DebugLogProvider>("StaticConstructorOnStartup").Message($"Injected SexHistoryComp into {PawnDefs.Count()} pawn Defs");
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,41 +0,0 @@
 | 
			
		|||
using HarmonyLib;
 | 
			
		||||
using RJWSexperience.SexHistory;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace RJWSexperience
 | 
			
		||||
{
 | 
			
		||||
	[HarmonyPatch(typeof(Pawn), nameof(Pawn.GetGizmos))]
 | 
			
		||||
	public static class Pawn_GetGizmos
 | 
			
		||||
	{
 | 
			
		||||
		private static Configurations Settings => SexperienceMod.Settings;
 | 
			
		||||
 | 
			
		||||
		public static bool Prepare() => Settings.EnableSexHistory;
 | 
			
		||||
 | 
			
		||||
		public static void Postfix(ref IEnumerable<Gizmo> __result, Pawn __instance)
 | 
			
		||||
		{
 | 
			
		||||
			if (Settings.HideGizmoWhenDrafted && __instance.Drafted)
 | 
			
		||||
				return;
 | 
			
		||||
 | 
			
		||||
			if (Find.Selector.NumSelected > 1)
 | 
			
		||||
				return;
 | 
			
		||||
 | 
			
		||||
			if (Settings.HideGizmoWithRJW && !rjw.RJWSettings.show_RJW_designation_box)
 | 
			
		||||
				return;
 | 
			
		||||
 | 
			
		||||
			SexHistoryComp history = __instance.TryGetComp<SexHistoryComp>();
 | 
			
		||||
			if (history == null)
 | 
			
		||||
				return;
 | 
			
		||||
 | 
			
		||||
			__result = AddHistoryGizmo(history.Gizmo, __result);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private static IEnumerable<Gizmo> AddHistoryGizmo(Gizmo historyGizmo, IEnumerable<Gizmo> gizmos)
 | 
			
		||||
		{
 | 
			
		||||
			foreach (Gizmo gizmo in gizmos)
 | 
			
		||||
				yield return gizmo;
 | 
			
		||||
 | 
			
		||||
			yield return historyGizmo;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue