Exemple #1
0
        public static string Serialize(Telehub settings)
        {
            StringWriter  sw  = new StringWriter();
            XmlTextWriter xtw = new XmlTextWriter(sw)
            {
                Formatting = Formatting.Indented
            };

            xtw.WriteStartDocument();

            xtw.WriteStartElement("Telehub");
            if (settings.ObjectUUID != UUID.Zero)
            {
                xtw.WriteElementString("TelehubObject", settings.ObjectUUID.ToString());
                xtw.WriteElementString("TelehubName", settings.Name);
                foreach (var point in settings.SpawnPos)
                {
                    xtw.WriteElementString("SpawnPoint", point.ToString());
                }
            }
            xtw.WriteEndElement();

            xtw.Close();

            return(sw.ToString());
        }
        public void AddTelehub(Telehub telehub, ulong regionhandle)
        {
            object remoteValue = DoRemote(telehub, regionhandle);
            if (remoteValue != null || m_doRemoteOnly)
                return;

            //Look for a telehub first.
            if (FindTelehub(new UUID(telehub.RegionID), 0) != null)
            {
                Dictionary<string, object> values = new Dictionary<string, object>();
                values["TelehubLocX"] = telehub.TelehubLocX;
                values["TelehubLocY"] = telehub.TelehubLocY;
                values["TelehubLocZ"] = telehub.TelehubLocZ;
                values["TelehubRotX"] = telehub.TelehubRotX;
                values["TelehubRotY"] = telehub.TelehubRotY;
                values["TelehubRotZ"] = telehub.TelehubRotZ;
                values["Spawns"] = telehub.BuildFromList(telehub.SpawnPos);
                values["ObjectUUID"] = telehub.ObjectUUID;
                values["Name"] = telehub.Name;

                QueryFilter filter = new QueryFilter();
                filter.andFilters["RegionID"] = telehub.RegionID;

                //Found one, time to update it.
                GD.Update("telehubs", values, null, filter, null, null);
            }
            else
            {
                //Make a new one
                GD.Insert("telehubs", new object[]
                                          {
                                              telehub.RegionID,
                                              telehub.RegionLocX,
                                              telehub.RegionLocY,
                                              telehub.TelehubLocX,
                                              telehub.TelehubLocY,
                                              telehub.TelehubLocZ,
                                              telehub.TelehubRotX,
                                              telehub.TelehubRotY,
                                              telehub.TelehubRotZ,
                                              telehub.BuildFromList(telehub.SpawnPos),
                                              telehub.ObjectUUID,
                                              telehub.Name
                                          });
            }
        }
Exemple #3
0
        public static Telehub Deserialize(string serializedSettings, UUID RegionID)
        {
            Telehub settings = new Telehub();

            StringReader  sr  = new StringReader(serializedSettings);
            XmlTextReader xtr = new XmlTextReader(sr);


            xtr.ReadEndElement();
            xtr.ReadStartElement("Telehub");

            //  OAR 0.8 format addition
            while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
            {
                switch (xtr.Name)
                {
                case "TelehubObject":
                {
                    settings.RegionID   = RegionID;
                    settings.ObjectUUID = UUID.Parse(xtr.ReadElementContentAsString());
                    break;
                }

                case "SpawnPoint":
                    settings.SpawnPos.Add(Vector3.Parse(xtr.ReadElementContentAsString()));
                    break;

                case "TelehubName":
                    settings.Name = xtr.ReadElementContentAsString();
                    break;
                }
            }

            xtr.ReadEndElement();
            xtr.Close();

            return(settings);
        }
        public void GodlikeMessage(IClientAPI client, UUID requester, string Method, List<string> Parameters)
        {
            if (RegionConnector == null)
                return;
            IScenePresence Sp = client.Scene.GetScenePresence(client.AgentId);
            if (!client.Scene.Permissions.CanIssueEstateCommand(client.AgentId, false))
                return;

            string parameter1 = Parameters[0];
            if (Method == "telehub")
            {
                if (parameter1 == "spawnpoint remove")
                {
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID,
                                                                  client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                        return;
                    //Remove the one we sent at X
                    telehub.SpawnPos.RemoveAt(int.Parse(Parameters[1]));
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "spawnpoint add")
                {
                    ISceneChildEntity part = Sp.Scene.GetSceneObjectPart(uint.Parse(Parameters[1]));
                    if (part == null)
                        return;
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID,
                                                                  client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                        return;
                    telehub.RegionLocX = client.Scene.RegionInfo.RegionLocX;
                    telehub.RegionLocY = client.Scene.RegionInfo.RegionLocY;
                    telehub.RegionID = client.Scene.RegionInfo.RegionID;
                    Vector3 pos = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                    if (telehub.TelehubLocX == 0 && telehub.TelehubLocY == 0)
                        return; //No spawns without a telehub
                    telehub.SpawnPos.Add(part.AbsolutePosition - pos); //Spawns are offsets
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "delete")
                {
                    RegionConnector.RemoveTelehub(client.Scene.RegionInfo.RegionID, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }
                if (parameter1 == "connect")
                {
                    ISceneChildEntity part = Sp.Scene.GetSceneObjectPart(uint.Parse(Parameters[1]));
                    if (part == null)
                        return;
                    Telehub telehub = RegionConnector.FindTelehub(client.Scene.RegionInfo.RegionID,
                                                                  client.Scene.RegionInfo.RegionHandle);
                    if (telehub == null)
                        telehub = new Telehub();
                    telehub.RegionLocX = client.Scene.RegionInfo.RegionLocX;
                    telehub.RegionLocY = client.Scene.RegionInfo.RegionLocY;
                    telehub.RegionID = client.Scene.RegionInfo.RegionID;
                    telehub.TelehubLocX = part.AbsolutePosition.X;
                    telehub.TelehubLocY = part.AbsolutePosition.Y;
                    telehub.TelehubLocZ = part.AbsolutePosition.Z;
                    telehub.TelehubRotX = part.ParentEntity.Rotation.X;
                    telehub.TelehubRotY = part.ParentEntity.Rotation.Y;
                    telehub.TelehubRotZ = part.ParentEntity.Rotation.Z;
                    telehub.ObjectUUID = part.UUID;
                    telehub.Name = part.Name;
                    RegionConnector.AddTelehub(telehub, client.Scene.RegionInfo.RegionHandle);
                    SendTelehubInfo(client);
                }

                if (parameter1 == "info ui")
                    SendTelehubInfo(client);
            }
        }