/// <summary> /// Gets all component references that match specified locator. /// </summary> /// <typeparam name="T">the class type</typeparam> /// <param name="locator">the locator to find a reference by.</param> /// <param name="required">forces to raise an exception if no reference is found.</param> /// <returns>a list with matching component references.</returns> public override List <T> Find <T>(object locator, bool required) { var components = base.Find <T>(locator, false); // Try to create component if (required && components.Count == 0) { var factory = FindFactory(locator); var component = Create(locator, factory); if (component is T) { locator = ClarifyLocator(locator, factory); ParentReferences.Put(locator, component); components.Add((T)component); } } // Throw exception is no required components found if (required && components.Count == 0) { throw new ReferenceException(locator); } return(components); }
public static void RJW_GenerateBabies_Prefix(Pawn ___pawn, Pawn ___father) { ParentReferences.Push(new ParentReferences.Record { Mother = ___pawn?.AnimalGenetics(), Father = ___father?.AnimalGenetics(), }); }
public static void Prefix(ThingWithComps ___parent) { var comp = ___parent.TryGetComp <EggGeneticInformation>(); ParentReferences.Push(new ParentReferences.Record { This = comp.GeneticInformation }); }
public static void Prefix(Pawn mother, Pawn father) { var motherGeneticInformation = mother?.AnimalGenetics(); var fatherGeneticInformation = father?.AnimalGenetics(); if (fatherGeneticInformation == null && motherGeneticInformation != null) { var fatherGeneticInformationComp = mother.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Pregnant) .TryGetComp <FatherGeneticInformation>(); fatherGeneticInformation = fatherGeneticInformationComp?.GeneticInformation; } ParentReferences.Push(new ParentReferences.Record { Mother = motherGeneticInformation, Father = fatherGeneticInformation }); }
public static void RJW_GenerateBabies_Postfix(Pawn ___pawn) { ParentReferences.Pop(); }
public static void Postfix() { ParentReferences.Pop(); }
public static void RJW_GenerateBabies_Prefix(Pawn ___pawn, Pawn ___father) { ParentReferences.Push(new ParentReferences.Record { mother = ___pawn, father = ___father }); }
static public void Prefix(Pawn mother, Pawn father) { ParentReferences.Push(new ParentReferences.Record { mother = mother, father = father }); }