Exemplo n.º 1
0
        public SceneObject PickCameraSpawnPoint(string spawnGroups)
        {
            SimObject spawnPoint = spawnGroups.Split(' ')
                                   .ToList()
                                   .Select((group) => Sim.FindObjectByName <SimSet>(group)?.GetRandom())
                                   .ToList()
                                   .Find((x) => x != null && Global.IsObject(x.GetId().ToString()));

            if (spawnPoint != null)
            {
                return(spawnPoint.As <SceneObject>());
            }

            // Didn't find a spawn point by looking for the groups
            // so let's return the "default" SpawnSphere
            // First create it if it doesn't already exist
            SpawnSphere spawn;

            if (!Global.IsObject("DefaultCameraSpawnSphere"))
            {
                spawn = new SpawnSphere("DefaultCameraSpawnSphere")
                {
                    DataBlock      = Sim.FindObjectByName <GameBaseData>("SpawnSphereMarker"),
                    SpawnClass     = Global.GetConsoleString("Game::DefaultCameraClass"),
                    SpawnDatablock = Global.GetConsoleString("Game::DefaultCameraDataBlock"),
                };
                spawn.RegisterObject();

                // Add it to the MissionCleanup group so that it
                // doesn't get saved to the Mission (and gets cleaned
                // up of course)
                Core.SimObjects.Collections.MissionCleanup.Add(spawn);
            }
            else
            {
                spawn = Sim.FindObjectByName <SpawnSphere>("DefaultCameraSpawnSphere");
            }

            return(spawn);
        }
    void SpawnObjects()
    {
        int amount = Random.Range((int)_spawnRange.x, (int)_spawnRange.y);

        for (int i = 0; i < _segmentCollection.Count; i++)
        {
            TableSegment current = _segmentCollection[i];
            SpawnSphere  spawner = current.SpawnLocation;

            Vector3    pos;
            Quaternion rot;

            for (int j = 0; j < amount; j++)
            {
                spawner.GetSpawn(out pos, out rot);
                GameObject newObject = Instantiate(GetRandomEdiblePrefab(), pos, rot, _objectContainer);
                _edibles.Add(newObject);

                // IObjective stuff

                NetworkServer.Spawn(newObject);
            }
        }
    }