Merge branch 'telehub'

iar_mods
BlueWall 2012-01-23 11:10:42 -05:00
commit 0037577814
1 changed files with 63 additions and 61 deletions

View File

@ -35,44 +35,22 @@ namespace OpenSim.Region.CoreModules.World.Estate
{ {
public class TelehubManager public class TelehubManager
{ {
private UUID ObjectID;
private string ObjectName;
private Vector3 ObjectPosition;
Quaternion ObjectRotation;
List<Vector3> SpawnPoint = new List<Vector3>();
UUID EstateID;
bool m_HasTelehub = false;
Scene m_Scene; Scene m_Scene;
// This will get an option...
Vector3 InitialSpawnPoint = new Vector3(0.0f,0.0f,0.0f);
public bool HasTelehub
{
get { return m_HasTelehub; }
}
public TelehubManager(Scene scene) public TelehubManager(Scene scene)
{ {
m_Scene = scene; m_Scene = scene;
} }
// Fill our Telehub struct with values
// public Telehub TelehubVals()
// {
// // Telehub telehub = new Telehub();
// EstateSettings telehub = m_EstateSettings;
//
// telehub.TelehubObject = ObjectID;
// telehub.TelehubName = ObjectName;
// telehub.TelehubPos = ObjectPosition;
// telehub.TelehubRot = ObjectRotation;
// telehub. = SpawnPoint;
// return telehub;
// }
// Connect the Telehub // Connect the Telehub
public bool Connect(SceneObjectPart part) public bool Connect(SceneObjectPart part)
{
bool result = false;
if (m_Scene.RegionInfo.RegionSettings.HasTelehub)
return result;
try
{ {
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints(); m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
@ -80,37 +58,42 @@ namespace OpenSim.Region.CoreModules.World.Estate
m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name; m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition; m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation(); m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f));
// Clear this for now
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint);
m_Scene.RegionInfo.RegionSettings.HasTelehub = true; m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
m_Scene.RegionInfo.RegionSettings.Save(); m_Scene.RegionInfo.RegionSettings.Save();
return true;
}
// Disconnect the Telehub: Clear it out for now, look at just disableing
public bool DisConnect(SceneObjectPart part)
{
bool result = false;
try{
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
// This is probably wrong! But, HasTelehub will block access
m_Scene.RegionInfo.RegionSettings.TelehubRot = Quaternion.Identity;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
m_Scene.RegionInfo.RegionSettings.Save();
result = true; result = true;
} }
catch (Exception ex) catch (Exception ex)
{ {
result = false; result = false;
} }
finally
{
return result;
}
// Disconnect the Telehub:
public bool DisConnect(SceneObjectPart part)
{
bool result = false;
if (!m_Scene.RegionInfo.RegionSettings.HasTelehub)
return result;
try
{
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
m_Scene.RegionInfo.RegionSettings.Save();
result = true;
}
catch (Exception ex)
{
result = false;
} }
return result; return result;
@ -119,19 +102,38 @@ namespace OpenSim.Region.CoreModules.World.Estate
// Add a SpawnPoint to the Telehub // Add a SpawnPoint to the Telehub
public bool AddSpawnPoint(Vector3 point) public bool AddSpawnPoint(Vector3 point)
{ {
bool result = false;
float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point); if (!m_Scene.RegionInfo.RegionSettings.HasTelehub)
Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos); return result;
try
{
Vector3 thPos = m_Scene.RegionInfo.RegionSettings.TelehubPos;
Quaternion thRot = m_Scene.RegionInfo.RegionSettings.TelehubRot;
float dist = (float) Util.GetDistanceTo(thPos, point);
Vector3 nvec = Util.GetNormalizedVector(point - thPos);
Vector3 spoint = nvec * dist; Vector3 spoint = nvec * dist;
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint); m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
m_Scene.RegionInfo.RegionSettings.Save(); m_Scene.RegionInfo.RegionSettings.Save();
return true; result = true;
}
catch (Exception ex)
{
result = false;
}
return result;
} }
// Remove a SpawnPoint from the Telehub // Remove a SpawnPoint from the Telehub
public bool RemoveSpawnPoint(int spawnpoint) public bool RemoveSpawnPoint(int spawnpoint)
{ {
if (!m_Scene.RegionInfo.RegionSettings.HasTelehub)
return false;
m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint); m_Scene.RegionInfo.RegionSettings.RemoveSpawnPoint(spawnpoint);
m_Scene.RegionInfo.RegionSettings.Save(); m_Scene.RegionInfo.RegionSettings.Save();