Example #1
0
        public void TransferTo(GeneticTraitComponent componentChild)
        {
            if (componentChild.IsEgg())
            {
                Debug.Log("Component to pass on is an egg");
                if (componentChild == null)
                {
                    return;
                }

                var fromTraits = GetComponent <Klei.AI.Traits>();
                if (fromTraits == null)
                {
                    return;
                }

                var traitsToAdd = fromTraits.TraitList.Where(GeneticTraits.IsSupportedTrait);
                Debug.Log("traitsToAdd");

                componentChild.addTraits(traitsToAdd, gameObject);
            }
            else
            {
                if (componentChild.IsBaby())
                {
                    if (componentChild == null)
                    {
                        return;
                    }

                    var fromTraits = GetComponent <AIGeneticTraits>();
                    if (fromTraits == null)
                    {
                        return;
                    }

                    var traitsToAdd = fromTraits.TraitList.Where(GeneticTraits.IsSupportedTrait);
                    componentChild.addTraits(traitsToAdd, gameObject);
                }
                else
                {
                    if (componentChild == null)
                    {
                        return;
                    }

                    var fromTraits = GetComponent <Klei.AI.Traits>();
                    if (fromTraits == null)
                    {
                        return;
                    }

                    var traitsToAdd = fromTraits.TraitList.Where(GeneticTraits.IsSupportedTrait);
                    componentChild.addTraits(traitsToAdd, gameObject);
                }
            }
        }
Example #2
0
        private static void OnLayEgg(GeneticTraitComponent component, object data)
        {
            Debug.Log("OnLayEgg");
            var egg = (data as GameObject);

            Debug.Log(egg);
            //pass traits
            Debug.Log(egg.GetComponent <GeneticTraitComponent>());
            component.TransferTo((data as GameObject).GetComponent <GeneticTraitComponent>());
        }
Example #3
0
        //
        private static void OnSpawnedFrom(GeneticTraitComponent componentChild, object data)
        {
            var parent = (data as GameObject);

            Debug.Log("OnSpawnedFrom");
            Debug.Log(parent);

            /*if(parent.IsCritter())
             * {
             *      //heredar
             *  }
             * if(parent==machine){
             * //rollnewtraits
             * }*/
            (data as GameObject).GetComponent <GeneticTraitComponent>()?.TransferTo(componentChild);
        }