Cleanup unused parts, add some error handling
parent
74c1ed77a4
commit
39c9b656c8
|
@ -35,82 +35,65 @@ 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)
|
||||||
{
|
|
||||||
m_Scene.RegionInfo.RegionSettings.ClearSpawnPoints();
|
|
||||||
|
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID;
|
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
|
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
|
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
|
|
||||||
|
|
||||||
// Clear this for now
|
|
||||||
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(InitialSpawnPoint);
|
|
||||||
m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
|
|
||||||
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;
|
bool result = false;
|
||||||
|
|
||||||
try{
|
if (m_Scene.RegionInfo.RegionSettings.HasTelehub)
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubObject = UUID.Zero;
|
return result;
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubName = String.Empty;
|
|
||||||
m_Scene.RegionInfo.RegionSettings.TelehubPos = Vector3.Zero;
|
try
|
||||||
// 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.ClearSpawnPoints();
|
||||||
m_Scene.RegionInfo.RegionSettings.HasTelehub = false;
|
|
||||||
|
m_Scene.RegionInfo.RegionSettings.TelehubObject = part.UUID;
|
||||||
|
m_Scene.RegionInfo.RegionSettings.TelehubName = part.Name;
|
||||||
|
m_Scene.RegionInfo.RegionSettings.TelehubPos = part.AbsolutePosition;
|
||||||
|
m_Scene.RegionInfo.RegionSettings.TelehubRot = part.GetWorldRotation();
|
||||||
|
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(new Vector3(0.0f,0.0f,0.0f));
|
||||||
|
m_Scene.RegionInfo.RegionSettings.HasTelehub = true;
|
||||||
m_Scene.RegionInfo.RegionSettings.Save();
|
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,35 @@ 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;
|
||||||
Vector3 spoint = nvec * dist;
|
|
||||||
|
|
||||||
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
|
try
|
||||||
m_Scene.RegionInfo.RegionSettings.Save();
|
{
|
||||||
return true;
|
float dist = (float) Util.GetDistanceTo(m_Scene.RegionInfo.RegionSettings.TelehubPos, point);
|
||||||
|
Vector3 nvec = Util.GetNormalizedVector(point - m_Scene.RegionInfo.RegionSettings.TelehubPos);
|
||||||
|
Vector3 spoint = nvec * dist;
|
||||||
|
|
||||||
|
m_Scene.RegionInfo.RegionSettings.AddSpawnPoint(spoint);
|
||||||
|
m_Scene.RegionInfo.RegionSettings.Save();
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue