/// <summary> /// Generate a SpawnPoint from a string /// </summary> /// <param name="str"></param> public static SpawnPoint Parse(string str) { string[] parts = str.Split(','); if (parts.Length != 3) throw new ArgumentException("Invalid string: " + str); SpawnPoint sp = new SpawnPoint(); sp.Yaw = float.Parse(parts[0]); sp.Pitch = float.Parse(parts[1]); sp.Distance = float.Parse(parts[2]); return sp; }
// Add a SpawnPoint to the Telehub public void AddSpawnPoint(Vector3 point) { if (m_Scene.RegionInfo.RegionSettings.TelehubObject == UUID.Zero) return; SceneObjectGroup grp = m_Scene.GetSceneObjectGroup(m_Scene.RegionInfo.RegionSettings.TelehubObject); if (grp == null) return; SpawnPoint sp = new SpawnPoint(); sp.SetLocation(grp.AbsolutePosition, grp.GroupRotation, point); m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(sp); m_Scene.RegionInfo.RegionSettings.Save(); }
private void LoadSpawnPoints(RegionSettings rs) { rs.ClearSpawnPoints(); string sql = @"SELECT ""Yaw"", ""Pitch"", ""Distance"" FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID"; using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) { cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); conn.Open(); using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { SpawnPoint sp = new SpawnPoint(); sp.Yaw = (float)reader["Yaw"]; sp.Pitch = (float)reader["Pitch"]; sp.Distance = (float)reader["Distance"]; rs.AddSpawnPoint(sp); } } } }
// Add a SpawnPoint // ** These are not region coordinates ** // They are relative to the Telehub coordinates // public void AddSpawnPoint(SpawnPoint point) { l_SpawnPoints.Add(point); }
private void LoadSpawnPoints(RegionSettings rs) { rs.ClearSpawnPoints(); DataTable spawnpoints = ds.Tables["spawn_points"]; string byRegion = "RegionID = '" + rs.RegionUUID + "'"; DataRow[] spForRegion = spawnpoints.Select(byRegion); foreach (DataRow spRow in spForRegion) { SpawnPoint sp = new SpawnPoint(); sp.Pitch = (float)spRow["Pitch"]; sp.Yaw = (float)spRow["Yaw"]; sp.Distance = (float)spRow["Distance"]; rs.AddSpawnPoint(sp); } }