Пример #1
0
 public virtual void Initialize(AIProject.SaveData.AnimalData animalData)
 {
     if (animalData != null)
     {
         return;
     }
     this.SetState(AnimalState.Destroyed, (System.Action)null);
 }
Пример #2
0
 public void Initialize(AIProject.SaveData.AnimalData _animalData)
 {
     AIProject.SaveData.AnimalData animalData = _animalData;
     this.AnimalData = animalData;
     if (animalData != null)
     {
         return;
     }
     this.SetState(AnimalState.Destroyed, (Action)null);
 }
Пример #3
0
 public override void Initialize(AIProject.SaveData.AnimalData animalData)
 {
     AIProject.SaveData.AnimalData animalData1 = animalData;
     this.AnimalData = animalData1;
     if (animalData1 == null)
     {
         this.SetState(AnimalState.Destroyed, (Action)null);
     }
     else
     {
         animalData.AnimalID = this.AnimalID;
         int registerId = animalData.RegisterID;
     }
 }
Пример #4
0
        private void NameChanged(AIProject.SaveData.Environment.ChickenInfo info)
        {
            if (info == null || info.AnimalData == null)
            {
                return;
            }
            AIProject.SaveData.AnimalData        animalData = info.AnimalData;
            ReadOnlyDictionary <int, AnimalBase> source     = !Singleton <AnimalManager> .IsInstance() ? (ReadOnlyDictionary <int, AnimalBase>)null : Singleton <AnimalManager> .Instance.AnimalTable;

            AnimalBase animalBase;

            if (source.IsNullOrEmpty <int, AnimalBase>() || !source.TryGetValue(animalData.AnimalID, ref animalBase) || !(animalBase is PetChicken))
            {
                return;
            }
            (animalBase as PetChicken).Nickname = info.name;
        }
Пример #5
0
        private void End()
        {
            int desireKey = Desire.GetDesireKey(this.Agent.RuntimeDesire);

            if (desireKey != -1)
            {
                this.Agent.SetDesire(desireKey, 0.0f);
            }
            this.Agent.RuntimeDesire = Desire.Type.None;
            if (this.animal is IPetAnimal animal)
            {
                AIProject.SaveData.AnimalData animalData = animal.AnimalData;
                if (animalData != null)
                {
                    double num = (double)animalData.AddFavorability(this.Agent.ID, 1f);
                }
            }
            this.ReleaseAnimal();
        }
Пример #6
0
        protected override void Initialize()
        {
            base.Initialize();
            if (Object.op_Equality((Object)this.bodyObject, (Object)null))
            {
                return;
            }
            GameObject loop = this.bodyObject.get_transform().FindLoop(this._materialTargetObjectName);

            if (Object.op_Equality((Object)loop, (Object)null))
            {
                return;
            }
            Renderer component = (Renderer)loop.GetComponent <Renderer>();

            if (Object.op_Equality((Object)component, (Object)null))
            {
                return;
            }
            Material material = component.get_material();

            if (Object.op_Equality((Object)material, (Object)null) || !material.HasProperty(this._textureKeyName))
            {
                return;
            }
            AIProject.SaveData.AnimalData animalData = this.AnimalData;
            if (!Singleton <Resources> .IsInstance())
            {
                return;
            }
            Dictionary <int, Dictionary <int, ValueTuple <Texture2D, Color[]> > > textureTable = Singleton <Resources> .Instance.AnimalTable.TextureTable;

            if (((IReadOnlyDictionary <int, Dictionary <int, ValueTuple <Texture2D, Color[]> > >)textureTable).IsNullOrEmpty <int, Dictionary <int, ValueTuple <Texture2D, Color[]> > >())
            {
                return;
            }
            int animalTypeId = this.AnimalTypeID;
            Dictionary <int, ValueTuple <Texture2D, Color[]> > dictionary;

            if (!textureTable.TryGetValue(animalTypeId, out dictionary) || ((IReadOnlyDictionary <int, ValueTuple <Texture2D, Color[]> >)dictionary).IsNullOrEmpty <int, ValueTuple <Texture2D, Color[]> >())
            {
                return;
            }
            if (animalData.First || !dictionary.ContainsKey(animalData.TextureID))
            {
                List <int> source = ListPool <int> .Get();

                source.AddRange((IEnumerable <int>)dictionary.Keys);
                animalData.TextureID = source.Rand <int>();
            }
            ValueTuple <Texture2D, Color[]> valueTuple = dictionary[animalData.TextureID];

            material.SetTexture(this._textureKeyName, (Texture)valueTuple.Item1);
            Color[] colorArray = (Color[])valueTuple.Item2;
            if (((IReadOnlyList <Color>)colorArray).IsNullOrEmpty <Color>() || ((IReadOnlyList <string>) this._colorKeyNames).IsNullOrEmpty <string>())
            {
                return;
            }
            for (int index = 0; index < colorArray.Length && index < this._colorKeyNames.Length; ++index)
            {
                string colorKeyName = this._colorKeyNames[index];
                if (material.HasProperty(colorKeyName))
                {
                    material.SetColor(colorKeyName, colorArray[index]);
                }
            }
        }
Пример #7
0
        public void CreateChicken()
        {
            if (this._farmKind != FarmPoint.FarmKind.ChickenCoop)
            {
                return;
            }
            if (this.ChickenList != null)
            {
                this.ChickenList.RemoveAll((Predicate <PetChicken>)(x => Object.op_Equality((Object)x, (Object)null)));
            }
            else
            {
                if (!Singleton <Game> .IsInstance() || !Singleton <AnimalManager> .IsInstance())
                {
                    return;
                }
                AIProject.SaveData.Environment environment = Singleton <Game> .Instance.Environment;
                if (environment == null)
                {
                    return;
                }
                this.ChickenList = ListPool <PetChicken> .Get();

                Dictionary <int, List <AIProject.SaveData.Environment.ChickenInfo> > chickenTable = environment.ChickenTable;
                if (chickenTable == null)
                {
                    return;
                }
                List <AIProject.SaveData.Environment.ChickenInfo> source1 = (List <AIProject.SaveData.Environment.ChickenInfo>)null;
                if (!chickenTable.TryGetValue(this.RegisterID, out source1) || source1.IsNullOrEmpty <AIProject.SaveData.Environment.ChickenInfo>())
                {
                    if (Singleton <Manager.Map> .IsInstance())
                    {
                        int mapId = Singleton <Manager.Map> .Instance.MapID;
                        int areaIdOnHousingArea = this.AreaIDOnHousingArea;
                        Dictionary <int, Dictionary <int, AIProject.SaveData.AnimalData> > source2;
                        Dictionary <int, AIProject.SaveData.AnimalData> source3;
                        if (!environment.HousingChickenDataTable.TryGetValue(mapId, out source2) || source2.IsNullOrEmpty <int, Dictionary <int, AIProject.SaveData.AnimalData> >() || (!source2.TryGetValue(areaIdOnHousingArea, out source3) || source3.IsNullOrEmpty <int, AIProject.SaveData.AnimalData>()))
                        {
                            return;
                        }
                        int num = source3.Keys.Max();
                        if (source1 == null)
                        {
                            chickenTable[this.RegisterID] = source1 = new List <AIProject.SaveData.Environment.ChickenInfo>();
                        }
                        while (source1.Count <= num)
                        {
                            source1.Add((AIProject.SaveData.Environment.ChickenInfo)null);
                        }
                        for (int index = 0; index < source1.Count; ++index)
                        {
                            source1[index] = (AIProject.SaveData.Environment.ChickenInfo)null;
                        }
                        foreach (KeyValuePair <int, AIProject.SaveData.AnimalData> keyValuePair in source3)
                        {
                            int key = keyValuePair.Key;
                            AIProject.SaveData.AnimalData animalData = keyValuePair.Value;
                            if (animalData == null)
                            {
                                source1[key] = (AIProject.SaveData.Environment.ChickenInfo)null;
                            }
                            else
                            {
                                source1[key] = new AIProject.SaveData.Environment.ChickenInfo()
                                {
                                    name       = animalData.Nickname,
                                    AnimalData = animalData
                                }
                            };
                        }
                    }
                    if (source1.IsNullOrEmpty <AIProject.SaveData.Environment.ChickenInfo>())
                    {
                        return;
                    }
                }
                for (int index = 0; index < source1.Count; ++index)
                {
                    AIProject.SaveData.AnimalData animalData = source1.GetElement <AIProject.SaveData.Environment.ChickenInfo>(index)?.AnimalData;
                    if (animalData != null)
                    {
                        if (!animalData.InitAnimalTypeID || animalData.AnimalTypeID < 0)
                        {
                            animalData.AnimalTypeID     = AIProject.Animal.AnimalData.GetAnimalTypeID(animalData.AnimalType);
                            animalData.InitAnimalTypeID = true;
                        }
                        AnimalBase animalBase = Singleton <AnimalManager> .Instance.CreateBase(animalData.AnimalTypeID, (int)animalData.BreedingType);

                        if (!Object.op_Equality((Object)animalBase, (Object)null))
                        {
                            ((Component)animalBase).get_transform().SetParent(this.AnimalRoot, true);
                            animalData.AnimalID = animalBase.AnimalID;
                            if (animalBase is IPetAnimal petAnimal)
                            {
                                petAnimal.AnimalData = animalData;
                            }
                            PetChicken chicken = animalBase as PetChicken;
                            this.AddChicken(index, chicken);
                            if (Object.op_Inequality((Object)chicken, (Object)null))
                            {
                                chicken.Initialize(this);
                            }
                        }
                    }
                }
            }
        }