示例#1
0
        /// <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);
        }
示例#2
0
 public static void RJW_GenerateBabies_Prefix(Pawn ___pawn, Pawn ___father)
 {
     ParentReferences.Push(new ParentReferences.Record
     {
         Mother = ___pawn?.AnimalGenetics(),
         Father = ___father?.AnimalGenetics(),
     });
 }
示例#3
0
            public static void Prefix(ThingWithComps ___parent)
            {
                var comp = ___parent.TryGetComp <EggGeneticInformation>();

                ParentReferences.Push(new ParentReferences.Record {
                    This = comp.GeneticInformation
                });
            }
示例#4
0
            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
                });
            }
示例#5
0
 public static void RJW_GenerateBabies_Postfix(Pawn ___pawn)
 {
     ParentReferences.Pop();
 }
示例#6
0
 public static void Postfix()
 {
     ParentReferences.Pop();
 }
示例#7
0
 public static void RJW_GenerateBabies_Prefix(Pawn ___pawn, Pawn ___father)
 {
     ParentReferences.Push(new ParentReferences.Record {
         mother = ___pawn, father = ___father
     });
 }
示例#8
0
 static public void Prefix(Pawn mother, Pawn father)
 {
     ParentReferences.Push(new ParentReferences.Record {
         mother = mother, father = father
     });
 }