private void CreateDefaultSpawnPointFile()
        {
            Log.Warn("Creating default CustomPlayerSpawns file.");
            var roleSize = Enum.GetNames(typeof(RoleType)).Length - 1;

            for (int i = 0; i < roleSize; i++)
            {
                var roleType = (RoleType)i;

                GameObject[] spawns = GetDefaultSpawnPoints(roleType);

                GameObject[] GetDefaultSpawnPoints(RoleType role)
                {
                    switch (role)
                    {
                    case RoleType.Scp106: return(GameObject.FindGameObjectsWithTag("SP_106"));

                    case RoleType.Scp049: return(GameObject.FindGameObjectsWithTag("SP_049"));

                    case RoleType.Scp079: return(GameObject.FindGameObjectsWithTag("SP_079"));

                    case RoleType.Scp096: return(GameObject.FindGameObjectsWithTag("SCP_096"));

                    case RoleType.Scp173: return(GameObject.FindGameObjectsWithTag("SP_173"));

                    case RoleType.Scp93953: return(GameObject.FindGameObjectsWithTag("SCP_939"));

                    case RoleType.FacilityGuard: return(GameObject.FindGameObjectsWithTag("SP_GUARD"));

                    case RoleType.NtfCadet: return(GameObject.FindGameObjectsWithTag("SP_MTF"));

                    case RoleType.ChaosInsurgency: return(GameObject.FindGameObjectsWithTag("SP_CI"));

                    case RoleType.Scientist: return(GameObject.FindGameObjectsWithTag("SP_RSC"));

                    case RoleType.ClassD: return(GameObject.FindGameObjectsWithTag("SP_CDP"));

                    case RoleType.Tutorial: return(new[] { GameObject.Find("TUT Spawn") });

                    default: return(new GameObject[0]);
                    }
                }

                var spawnCount = spawns.Length;
                for (int j = 0; j < spawnCount; j++)
                {
                    var spawnPoint     = spawns[j];
                    var room           = Map.FindParentRoom(spawnPoint);
                    var spawnTransform = spawnPoint.transform;
                    var roomTransform  = room.transform;
                    var position       = roomTransform.InverseTransformPoint(spawnTransform.position);
                    var rotation       = roomTransform.InverseTransformDirection(spawnTransform.eulerAngles);
                    _pointList.RawPoints.Add(new RawPoint(i.ToString(), room.Type, position, rotation));
                }
            }

            PointIO.Save(_pointList, PointDataFilePath);
            _pointList.FixData();
            _spawnFileExists = true;
        }
Ejemplo n.º 2
0
        private static bool Save()
        {
            if (_currentLoadedPointList != null)
            {
                PointIO.Save(_currentLoadedPointList, Path.Combine(PointIO.FolderPath, _currentLoadedName) + ".txt");
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public void TryCreateFile()
        {
            PointList pointList = Points.GetPointList(CustomEscape.Singleton.Config.PointsFileName);

            if (FileManager.FileExists(Path.Combine(PointIO.FolderPath, PointsFileName) + ".txt"))
            {
                return;
            }
            Log.Info("Creating new EscapePoint file using default spawn points.");

            pointList.RawPoints.Add(
                new RawPoint("escape0", RoomType.Surface,
                             new Vector3(170f, -16.6f, 25f), new Vector3(0f, 0f, 0f))
                );
            PointIO.Save(pointList, Path.Combine(PointIO.FolderPath, PointsFileName) + ".txt");
            pointList.FixData();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads all the data from the text files into <see cref="PointLists"/>.
        /// </summary>
        public static void LoadData()
        {
            PointLists.Clear();

            Directory.CreateDirectory(PointIO.FolderPath);

            var files      = Directory.GetFiles(PointIO.FolderPath, "*.txt");
            var fileLength = files.Length;

            for (var i = 0; i < fileLength; i++)
            {
                var filePath = files[i];
                var list     = PointIO.Open(filePath);

                PointLists.Add(Path.GetFileNameWithoutExtension(filePath), list);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Returns true if it found the points.
        /// </summary>
        public static bool LoadPoints(string name)
        {
            if (!Directory.Exists(PointIO.FolderPath))
            {
                Directory.CreateDirectory(PointIO.FolderPath);
            }

            var pointList = PointIO.Open(Path.Combine(PointIO.FolderPath, name) + ".txt") ?? new PointList();

            _currentLoadedPointList = pointList;
            _currentLoadedName      = name;

            if (PointManager.PointLists.ContainsKey(name))
            {
                PointManager.PointLists[name] = pointList;
                return(true);
            }

            PointManager.PointLists.Add(name, pointList);
            return(false);
        }