public GenericSpawnerSpawnList.GenericSpawnInstance Clone()
 {
     GenericSpawnerSpawnList.GenericSpawnInstance genericSpawnInstance = new GenericSpawnerSpawnList.GenericSpawnInstance()
     {
         prefabName             = this.prefabName,
         targetPopulation       = this.targetPopulation,
         numToSpawnPerTick      = this.numToSpawnPerTick,
         forceStaticInstantiate = this.forceStaticInstantiate,
         spawned = new List <GameObject>()
     };
     return(genericSpawnInstance);
 }
 public GenericSpawnerSpawnList.GenericSpawnInstance Clone()
 {
     GenericSpawnerSpawnList.GenericSpawnInstance genericSpawnInstance = new GenericSpawnerSpawnList.GenericSpawnInstance()
     {
         prefabName = this.prefabName,
         targetPopulation = this.targetPopulation,
         numToSpawnPerTick = this.numToSpawnPerTick,
         forceStaticInstantiate = this.forceStaticInstantiate,
         spawned = new List<GameObject>()
     };
     return genericSpawnInstance;
 }
Esempio n. 3
0
        void PathResources()
        {
            int count = 0;

            foreach (GenericSpawner spawner in UnityEngine.Resources.FindObjectsOfTypeAll <GenericSpawner>())
            {
                GameObject.Destroy(spawner);
            }
            foreach (KeyValuePair <string, object> spawnlist in SpawnLists)
            {
                var currentSpawnlist = (Dictionary <string, object>)spawnlist.Value;
                var newlist          = new List <GenericSpawnerSpawnList.GenericSpawnInstance>();
                foreach (object pair in (List <object>)currentSpawnlist["spawnList"])
                {
                    var currentspawninstance = (Dictionary <string, object>)pair;
                    var newspawnlistdata     = new GenericSpawnerSpawnList.GenericSpawnInstance();
                    newspawnlistdata.forceStaticInstantiate = false;
                    newspawnlistdata.numToSpawnPerTick      = Convert.ToInt32(currentspawninstance["numToSpawnPerTick"]);
                    newspawnlistdata.prefabName             = currentspawninstance["prefabName"].ToString();

                    newspawnlistdata.targetPopulation = Convert.ToInt32(currentspawninstance["targetPopulation"]);
                    newspawnlistdata.useNavmeshSample = true;
                    newspawnlistdata.spawned          = new List <UnityEngine.GameObject>();
                    newlist.Add(newspawnlistdata);
                }
                var gameobject = new UnityEngine.GameObject();
                var generic    = gameobject.AddComponent <GenericSpawner>();
                generic.transform.position = new Vector3(Convert.ToSingle(currentSpawnlist["position_x"]), Convert.ToSingle(currentSpawnlist["position_y"]), Convert.ToSingle(currentSpawnlist["position_z"]));
                generic.initialSpawn       = true;
                generic._spawnList         = newlist;
                generic.radius             = Convert.ToSingle(currentSpawnlist["radius"]);
                genericspawn_serverload.Invoke(generic, new object[] { });
                generic.SpawnThink();
                count++;
            }
            Puts(string.Format("{0} custom resource spawns where loaded!", count.ToString()));
        }
        private static bool smethod_5()
        {
            foreach (GenericSpawner spawner in UnityEngine.Object.FindObjectsOfType <GenericSpawner>())
            {
                UnityEngine.Object.Destroy(spawner);
            }
            System.Collections.Generic.List <string> list = File.ReadAllLines(SpawnsFile).ToList <string>();
            if (list.Count == 0)
            {
                return(false);
            }
            GenericSpawner spawner2 = null;

            GenericSpawnerSpawnList.GenericSpawnInstance item = null;
            foreach (string str in list)
            {
                string str2 = str.Trim();
                if (!string.IsNullOrEmpty(str2) && !str2.StartsWith("//"))
                {
                    if (str2.Contains("//"))
                    {
                        str2 = str2.Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim();
                    }
                    if (!string.IsNullOrEmpty(str2))
                    {
                        if (str2.StartsWith("[") && str2.EndsWith("]"))
                        {
                            str2.Substring(1, str2.Length - 2);
                            spawner2 = null;
                        }
                        else if (str2.Contains("=") && (spawner2 != null))
                        {
                            string   str3;
                            string[] strArray = str2.Replace(" ", "").Split(new char[] { '=' });
                            if ((strArray.Length >= 2) && ((str3 = strArray[0].ToUpper()) != null))
                            {
                                if (str3 == "RADIUS")
                                {
                                    if (!float.TryParse(strArray[1], out spawner2.radius))
                                    {
                                        spawner2.radius = 50f;
                                    }
                                }
                                else if (str3 == "THINKDELAY")
                                {
                                    if (!float.TryParse(strArray[1], out spawner2.thinkDelay))
                                    {
                                        spawner2.thinkDelay = 60f;
                                    }
                                }
                                else if (str3 == "POSITION")
                                {
                                    strArray = strArray[1].Replace(" ", "").Split(new char[] { ',' });
                                    if (strArray.Length < 3)
                                    {
                                        UnityEngine.Object.Destroy(spawner2);
                                        spawner2 = null;
                                    }
                                    else
                                    {
                                        float result = 0f;
                                        if (!float.TryParse(strArray[0], out result))
                                        {
                                            UnityEngine.Object.Destroy(spawner2);
                                            spawner2 = null;
                                        }
                                        else
                                        {
                                            float num2 = 0f;
                                            if (!float.TryParse(strArray[1], out num2))
                                            {
                                                UnityEngine.Object.Destroy(spawner2);
                                                spawner2 = null;
                                            }
                                            else
                                            {
                                                float num3 = 0f;
                                                if (!float.TryParse(strArray[2], out num3))
                                                {
                                                    UnityEngine.Object.Destroy(spawner2);
                                                    spawner2 = null;
                                                }
                                                else
                                                {
                                                    spawner2.transform.position = new Vector3(result, num2, num3);
                                                }
                                            }
                                        }
                                    }
                                }
                                else if (str3 == "SPAWN")
                                {
                                    strArray = strArray[1].Replace(" ", "").Split(new char[] { ',' });
                                    item     = new GenericSpawnerSpawnList.GenericSpawnInstance();
                                    if (strArray.Length > 0)
                                    {
                                        item.prefabName = strArray[0];
                                    }
                                    if ((strArray.Length > 1) && int.TryParse(strArray[1], out item.targetPopulation))
                                    {
                                        item.targetPopulation = 1;
                                    }
                                    if ((strArray.Length > 2) && int.TryParse(strArray[2], out item.numToSpawnPerTick))
                                    {
                                        item.numToSpawnPerTick = 1;
                                    }
                                    if (item.numToSpawnPerTick > item.targetPopulation)
                                    {
                                        item.numToSpawnPerTick = item.targetPopulation;
                                    }
                                    if ((strArray.Length > 3) && bool.TryParse(strArray[3], out item.useNavmeshSample))
                                    {
                                        item.useNavmeshSample = false;
                                    }
                                    if ((strArray.Length > 4) && bool.TryParse(strArray[4], out item.forceStaticInstantiate))
                                    {
                                        item.forceStaticInstantiate = false;
                                    }
                                    spawner2._spawnList.Add(item);
                                    SpawnsCount++;
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }