Ejemplo n.º 1
0
        public void Load(MySqlConnection connection)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM portal_book_coords WHERE `owner` = @owner";
                command.Parameters.AddWithValue("@owner", Owner.Id);
                command.Prepare();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var template = new Portal
                        {
                            Id        = reader.GetUInt32("id"),
                            Name      = reader.GetString("name"),
                            X         = reader.GetFloat("x"),
                            Y         = reader.GetFloat("y"),
                            Z         = reader.GetFloat("z"),
                            ZoneId    = reader.GetUInt32("zone_id"),
                            ZRot      = reader.GetFloat("z_rot"),
                            SubZoneId = reader.GetUInt32("sub_zone_id"),
                            Owner     = reader.GetUInt32("owner")
                        };
                        PrivatePortals.Add(template.Id, template);
                    }
                }
            }

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM portal_visited_district WHERE `owner` = @owner";
                command.Parameters.AddWithValue("@owner", Owner.Id);
                command.Prepare();
                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var template = new VisitedDistrict
                        {
                            Id      = reader.GetUInt32("id"),
                            SubZone = reader.GetUInt32("subzone"),
                            Owner   = reader.GetUInt32("owner")
                        };
                        VisitedDistricts.Add(template.SubZone, template);
                    }
                }
            }

            PopulateDistrictPortals();
        }
Ejemplo n.º 2
0
 public void RemoveFromBookPortal(Portal portal, bool isPrivate)
 {
     if (isPrivate)
     {
         if (PrivatePortals.ContainsKey(portal.Id) && PrivatePortals.Remove(portal.Id))
         {
             _removedPrivatePortals.Add(portal.Id);
             //Owner.SendMessage("Recorded Portal deleted.");
         }
     }
     else
     {
         if (VisitedDistricts.ContainsKey(portal.SubZoneId) && VisitedDistricts.Remove(portal.SubZoneId))
         {
             _removedVisitedDistricts.Add(portal.SubZoneId);
             //Owner.SendMessage("Default Portal deleted.");
         }
     }
 }
Ejemplo n.º 3
0
 public void NotifySubZone(uint subZoneId)
 {
     if (!VisitedDistricts.ContainsKey(subZoneId))
     {
         var portal = PortalManager.Instance.GetPortalBySubZoneId(subZoneId);
         if (portal != null)
         {
             var newVisitedDistrict = new VisitedDistrict()
             {
                 Id      = VisitedSubZoneIdManager.Instance.GetNextId(),
                 SubZone = subZoneId,
                 Owner   = Owner.Id
             };
             VisitedDistricts.Add(subZoneId, newVisitedDistrict);
             PopulateDistrictPortals();
             Send();
             _log.Info("{0}:{1} added to return district list ", portal.Name, subZoneId);
         }
     }
 }