Example #1
0
            public GameObject SpawnGeneric(Spawns.SpawnerGeneric.SpawnInstance instance)
            {
                Vector3 startPos = this.Position + UnityEngine.Random.insideUnitSphere * this.SpawnRadius;

                startPos.y = this.Position.y;
                Quaternion quaternion = Quaternion.Euler(new Vector3(0f, (float)UnityEngine.Random.Range(0, 360), 0f));
                Vector3    vector;

                if (instance.UseNavmeshSample && TransformHelpers.GetGroundInfoNavMesh(startPos, out vector, 15f, -1))
                {
                    startPos = vector;
                }
                Vector3    up;
                GameObject result;

                if (TransformHelpers.GetGroundInfoTerrainOnly(startPos, 300f, out vector, out up))
                {
                    vector.y += 0.05f;
                    if (instance.PrefabName == "BoxLoot")
                    {
                        vector.y += 0.35f;
                    }
                    quaternion = TransformHelpers.LookRotationForcedUp(quaternion * Vector3.forward, up);
                    GameObject gameObject;
                    if (!instance.StaticInstantiate && !instance.PrefabName.StartsWith(";"))
                    {
                        gameObject = NetCull.InstantiateDynamic(instance.PrefabName, vector, quaternion);
                    }
                    else
                    {
                        gameObject = NetCull.InstantiateStatic(instance.PrefabName, vector, quaternion);
                    }
                    if (gameObject != null)
                    {
                        instance.Spawned.Add(gameObject);
                    }
                    result = gameObject;
                }
                else
                {
                    result = null;
                }
                return(result);
            }
Example #2
0
 public static void smethod_96()
 {
     using (StreamReader streamReader = File.OpenText(Spawns.OverrideFile))
     {
         string a = string.Empty;
         Spawns.SpawnerGeneric  spawnerGeneric  = null;
         Spawns.SpawnerLootable spawnerLootable = null;
         string[] separator = new string[]
         {
             "//"
         };
         while (!streamReader.EndOfStream)
         {
             string text = streamReader.ReadLine().Trim();
             if (!string.IsNullOrEmpty(text) && text.Contains("//"))
             {
                 text = text.Split(separator, StringSplitOptions.RemoveEmptyEntries)[0];
                 text = text.Trim();
             }
             if (!string.IsNullOrEmpty(text))
             {
                 if (text.IndexOf('[') < text.IndexOf(']'))
                 {
                     a = text.Substring(1, text.Length - 2).ToLower();
                     if (spawnerGeneric != null && !spawnerGeneric.Initialized)
                     {
                         spawnerGeneric.Initialize();
                         Spawns.GenericSpawners.Add(spawnerGeneric);
                     }
                     if (spawnerLootable != null && !spawnerLootable.Initialized)
                     {
                         spawnerLootable.Initialize();
                         Spawns.LootableSpawners.Add(spawnerLootable);
                     }
                     if (a == "generic")
                     {
                         spawnerGeneric = new Spawns.SpawnerGeneric();
                     }
                     if (a == "lootable")
                     {
                         spawnerLootable = new Spawns.SpawnerLootable();
                     }
                 }
                 else
                 {
                     string[] array = text.Split(new char[]
                     {
                         '='
                     });
                     if (array.Length > 1)
                     {
                         string a2 = array[0].Trim().ToLower();
                         array = array[1].RemoveChars(new char[]
                         {
                             ' ',
                             '\t'
                         }).Split(new char[]
                         {
                             ','
                         });
                         if (a == "lootable" && spawnerLootable != null)
                         {
                             if (!(a2 == "position"))
                             {
                                 if (!(a2 == "spawntimemin"))
                                 {
                                     if (!(a2 == "spawntimemax"))
                                     {
                                         if (!(a2 == "spawnonstart"))
                                         {
                                             if (a2 == "spawnobject" && array.Length == 4)
                                             {
                                                 string prefab    = array[0];
                                                 float  weight    = float.Parse(array[1]);
                                                 float  lifetime  = float.Parse(array[2]);
                                                 float  lootcycle = float.Parse(array[3]);
                                                 spawnerLootable.AddLoot(prefab, weight, lifetime, lootcycle);
                                             }
                                         }
                                         else if (array.Length == 1)
                                         {
                                             spawnerLootable.SpawnOnStart = bool.Parse(array[0]);
                                         }
                                     }
                                     else if (array.Length == 1)
                                     {
                                         spawnerLootable.SpawnTimeMax = float.Parse(array[0]);
                                     }
                                 }
                                 else if (array.Length == 1)
                                 {
                                     spawnerLootable.SpawnTimeMin = float.Parse(array[0]);
                                 }
                             }
                             else if (array.Length == 3)
                             {
                                 float x = float.Parse(array[0]);
                                 float y = float.Parse(array[1]);
                                 float z = float.Parse(array[2]);
                                 spawnerLootable.SetPostition(new Vector3(x, y, z));
                             }
                         }
                         else if (a == "generic" && spawnerGeneric != null)
                         {
                             if (!(a2 == "position"))
                             {
                                 if (!(a2 == "spawnradius"))
                                 {
                                     if (!(a2 == "updatedelay"))
                                     {
                                         if (a2 == "spawnobject" && array.Length == 5)
                                         {
                                             Spawns.SpawnerGeneric.SpawnInstance spawnInstance = new Spawns.SpawnerGeneric.SpawnInstance();
                                             spawnInstance.PrefabName        = array[0];
                                             spawnInstance.TargetPopulation  = int.Parse(array[1]);
                                             spawnInstance.NumToSpawnPerTick = int.Parse(array[2]);
                                             spawnInstance.StaticInstantiate = bool.Parse(array[3]);
                                             spawnInstance.UseNavmeshSample  = bool.Parse(array[4]);
                                             spawnerGeneric.SpawnList.Add(spawnInstance);
                                         }
                                     }
                                     else if (array.Length == 1)
                                     {
                                         spawnerGeneric.ThinkDelay = float.Parse(array[0]);
                                     }
                                 }
                                 else if (array.Length == 1)
                                 {
                                     spawnerGeneric.SpawnRadius = float.Parse(array[0]);
                                 }
                             }
                             else if (array.Length == 3)
                             {
                                 float x2 = float.Parse(array[0]);
                                 float y2 = float.Parse(array[1]);
                                 float z2 = float.Parse(array[2]);
                                 spawnerGeneric.Position = new Vector3(x2, y2, z2);
                             }
                         }
                     }
                 }
             }
         }
         if (spawnerGeneric != null && !spawnerGeneric.Initialized)
         {
             spawnerGeneric.Initialize();
             Spawns.GenericSpawners.Add(spawnerGeneric);
         }
         if (spawnerLootable != null && !spawnerLootable.Initialized)
         {
             spawnerLootable.Initialize();
             Spawns.LootableSpawners.Add(spawnerLootable);
         }
     }
 }