コード例 #1
0
        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;
        }
コード例 #2
0
ファイル: Configs.cs プロジェクト: 4310V343k/CustomEscape
        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();
        }