コード例 #1
0
    private int currentIndex  = 0;                                  //< The index of the current node this fish is moving to

    /*
     * Start is called prior to the first frame update
     */
    private void Start()
    {
        spawner = FindObjectOfType <GenericSpawner>();

        destination = spawner.initialDestinations[Random.Range(0, 5)];
        Vector3 lookPosition = destination.destinationPosition - transform.position;

        destinationDirection = Quaternion.LookRotation(lookPosition);
        path.Add(destination);
        Destination currentNode = destination;

        while (craftingPath)
        {
            Destination newNode = currentNode.destinations[Random.Range(0, 5)];
            if (newNode.finalDestination == true)
            {
                path.Add(newNode);
                craftingPath = false;
            }
            else
            {
                path.Add(newNode);
                currentNode = newNode;
            }
        }
    }
コード例 #2
0
 public static void GetSpawnersSpawns()
 {
     if (Core.GenericSpawners != null && Core.GenericSpawners.Length != 0)
     {
         int num = 0;
         GenericSpawner[] genericSpawners = Core.GenericSpawners;
         for (int i = 0; i < genericSpawners.Length; i++)
         {
             GenericSpawner genericSpawner = genericSpawners[i];
             foreach (GenericSpawnerSpawnList.GenericSpawnInstance current in genericSpawner._spawnList)
             {
                 num += current.spawned.Count;
             }
         }
         Core.GenericSpawnsCount = num;
     }
 }
コード例 #3
0
 public void OnGenericSpawnLoad(GenericSpawner gs)
 {
     this.Invoke("On_GenericSpawnLoad", new object[] { gs });
 }
コード例 #4
0
 public void SetSpawner(GameObject spawner)
 {
     this._mySpawner = spawner.GetComponent <GenericSpawner>();
 }
コード例 #5
0
 public void OnGenericSpawnLoad(GenericSpawner gs)
 {
     Invoke("On_GenericSpawnLoad", gs);
 }
コード例 #6
0
 private static void smethod_0()
 {
     using (StreamWriter streamWriter = File.CreateText(Spawns.OverrideFile))
     {
         streamWriter.WriteLine("// Format & Help:");
         streamWriter.WriteLine("//  Lootable->Position - Position of spawn for create lootable object");
         streamWriter.WriteLine("//  Lootable->SpawnTimeMin - Minimum time in seconds to re-spawn a lootable object");
         streamWriter.WriteLine("//  Lootable->SpawnTimeMax - Maximum time in seconds to re-spawn a lootable object");
         streamWriter.WriteLine("//  Lootable->SpawnOnStart - Enable/disable for spawn after server start");
         streamWriter.WriteLine("//  Lootable->SpawnObject = Name, Weight, LifeTime, LootCycle");
         streamWriter.WriteLine("//  Lootable->SpawnObject->Name - Name of object to spawn, can be only (BoxLoot, AmmoLootBox, MedicalLootBox, WeaponLootBox)");
         streamWriter.WriteLine("//  Lootable->SpawnObject->Weight - Weight as chance for creation, in relation to other objects in list");
         streamWriter.WriteLine("//  Lootable->SpawnObject->LifeTime - Time of life of loot, loot will be removed after the expiration of time");
         streamWriter.WriteLine("//  Lootable->SpawnObject->LootCycle - Changes loot after specified time, regular");
         streamWriter.WriteLine();
         streamWriter.WriteLine("//  Generic->Position - Position of generic spawner for create objects around him");
         streamWriter.WriteLine("//  Generic->SpawnRadius - Spawn radius around current position of generic spawner");
         streamWriter.WriteLine("//  Generic->UpdateDelay - Delay in seconds to update spawns around generic spawner");
         streamWriter.WriteLine("//  Generic->SpawnObject = Prefab, TargetPopulation, NumToSpawnPerTick, UseNavmeshSample");
         streamWriter.WriteLine("//  Generic->SpawnObject->Prefab - Prefab name of object to spawn");
         streamWriter.WriteLine("//  Generic->SpawnObject->TargetPopulation - Maximum count of objects to spawn around spawner");
         streamWriter.WriteLine("//  Generic->SpawnObject->NumToSpawnPerTick - Amount of objects to spawn per time (specified in UpdateDelay)");
         streamWriter.WriteLine("//  Generic->SpawnObject->StaticInstantiate - Mark as static instantiated (when object is not movable: boxes, resources and etc.)");
         streamWriter.WriteLine("//  Generic->SpawnObject->UseNavmeshSample - Using navmesh checks of position, where spawn will be created");
         LootableObjectSpawner[] lootable = Spawns.Lootable;
         for (int i = 0; i < lootable.Length; i++)
         {
             LootableObjectSpawner lootableObjectSpawner = lootable[i];
             streamWriter.WriteLine();
             streamWriter.WriteLine("[Lootable]");
             streamWriter.WriteLine("Position=" + lootableObjectSpawner.transform.position.AsString());
             streamWriter.WriteLine("SpawnTimeMin=" + lootableObjectSpawner.spawnTimeMin);
             streamWriter.WriteLine("SpawnTimeMax=" + lootableObjectSpawner.spawnTimeMax);
             streamWriter.WriteLine("SpawnOnStart=" + lootableObjectSpawner.spawnOnStart.ToString());
             LootableObjectSpawner.ChancePick[] lootableChances = lootableObjectSpawner._lootableChances;
             for (int j = 0; j < lootableChances.Length; j++)
             {
                 LootableObjectSpawner.ChancePick chancePick = lootableChances[j];
                 string text = new string('\t', 2 - (chancePick.obj.name.Length + 5) / 8 + 1);
                 streamWriter.WriteLine(string.Concat(new object[]
                 {
                     "SpawnObject=",
                     chancePick.obj.name,
                     ",",
                     text,
                     chancePick.weight,
                     ",\t",
                     chancePick.obj.lifeTime,
                     ",\t",
                     chancePick.obj.LootCycle
                 }));
             }
         }
         GenericSpawner[] generic = Spawns.Generic;
         for (int i = 0; i < generic.Length; i++)
         {
             GenericSpawner genericSpawner = generic[i];
             streamWriter.WriteLine();
             streamWriter.WriteLine("[Generic]");
             streamWriter.WriteLine("Position=" + genericSpawner.transform.position.AsString());
             streamWriter.WriteLine("SpawnRadius=" + genericSpawner.radius);
             streamWriter.WriteLine("UpdateDelay=" + genericSpawner.thinkDelay);
             foreach (GenericSpawnerSpawnList.GenericSpawnInstance current in genericSpawner._spawnList)
             {
                 string text2 = new string('\t', 2 - (current.prefabName.Length + 5) / 8 + 1);
                 streamWriter.WriteLine(string.Concat(new object[]
                 {
                     "SpawnObject=",
                     current.prefabName,
                     ",",
                     text2,
                     current.targetPopulation,
                     ",\t",
                     current.numToSpawnPerTick,
                     ",\t",
                     current.forceStaticInstantiate.ToString(),
                     ",\t",
                     current.useNavmeshSample.ToString()
                 }));
             }
         }
     }
 }
コード例 #7
0
ファイル: ResourceObject.cs プロジェクト: HexHash/LegacyRust
 public void SetSpawner(GameObject spawner)
 {
     this._mySpawner = spawner.GetComponent<GenericSpawner>();
 }
コード例 #8
0
        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);
        }