Beispiel #1
0
        public void CreateZone(MClient c, MNetMessage m)
        {
            MServerZone zone = MServerZone.Deserialize <MServerZone>(m.Payload);

            MNetMessage mr = new MNetMessage();

            if (MRudeWords.IsRude(zone.Name) == true)
            {
                mr.Command = MNetMessage.ERROR;
                mr.Payload = "CreateZone:Not allowed";
                Send(c, "Message", mr.Serialize());
                return;
            }

            if (_ZoneHandler.Add(zone) == true)
            {
                mr.Command = MNetMessage.CREATEZONE;
                //TODO: Only send the zones we need
                mr.Payload = _ZoneHandler.GetObjectsAsString();
                SendToAllClients(c, mr.Serialize());
            }
            else
            {
                mr.Command = MNetMessage.ERROR;
                mr.Payload = "ZONE(" + zone.Name + ") already in Use";
                Send(c, "Message", mr.Serialize());
            }

            ZoneChanged?.Invoke(this, new ZoneEvent(zone));
        }
        public AddonReader(ILogger logger, DataConfig dataConfig, AreaDB areaDb, IAddonDataProvider addonDataProvider)
        {
            this.logger            = logger;
            this.addonDataProvider = addonDataProvider;

            this.squareReader = new SquareReader(this);

            this.CreatureHistory = new CreatureHistory(squareReader, 64, 65, 66, 67);

            this.ItemDb     = new ItemDB(logger, dataConfig);
            this.CreatureDb = new CreatureDB(logger, dataConfig);
            this.spellDb    = new SpellDB(logger, dataConfig);
            this.talentDB   = new TalentDB(logger, dataConfig, spellDb);

            this.EquipmentReader = new EquipmentReader(squareReader, 24, 25);
            this.BagReader       = new BagReader(squareReader, ItemDb, EquipmentReader, 20, 21, 22, 23);

            this.ActionBarCostReader = new ActionBarCostReader(squareReader, 36);

            this.GossipReader = new GossipReader(squareReader, 37);

            this.SpellBookReader = new SpellBookReader(squareReader, 71, spellDb);

            this.PlayerReader = new PlayerReader(squareReader);
            this.LevelTracker = new LevelTracker(PlayerReader);

            this.TalentReader = new TalentReader(squareReader, 72, PlayerReader, talentDB);

            this.AreaDb         = areaDb;
            this.WorldMapAreaDb = new WorldMapAreaDB(logger, dataConfig);

            UpdateLatencys = new CircularBuffer <double>(10);

            UIMapId.Changed += (object obj, EventArgs e) =>
            {
                this.AreaDb.Update(WorldMapAreaDb.GetAreaId(UIMapId.Value));
                ZoneChanged?.Invoke(this, EventArgs.Empty);
            };

            GlobalTime.Changed += (object obj, EventArgs e) =>
            {
                UpdateLatencys.Put((DateTime.Now - GlobalTime.LastChanged).TotalMilliseconds);
                AvgUpdateLatency = 0;
                for (int i = 0; i < UpdateLatencys.Size; i++)
                {
                    AvgUpdateLatency += UpdateLatencys.PeekAt(i);
                }
                AvgUpdateLatency /= UpdateLatencys.Size;
            };
        }
Beispiel #3
0
        public void ChangeLocation(string newLocationID)
        {
            if (newLocationID != CurrentLocation)
            {
                CurrentLocation = newLocationID;

                if (ZoneChanged != null)
                {
                    foreach (System.EventHandler e in ZoneChanged.GetInvocationList())
                    {
                        e.BeginInvoke(this, null, e.EndInvoke, null);
                    }
                }
            }
        }
        public void ChangeLocation(string newLocationID)
        {
            if (newLocationID != CurrentLocation)
            {
                CurrentLocation = newLocationID;

                if (ZoneChanged != null)
                {
                    foreach (System.EventHandler e in ZoneChanged.GetInvocationList())
                    {
                        Task.Run(() => e.Invoke(this, null));
                    }
                }
            }
        }
Beispiel #5
0
        public void UpdateZone(MClient c, MNetMessage m)
        {
            MServerZone zone = MServerZone.Deserialize <MServerZone>(m.Payload);
            MNetMessage mr   = new MNetMessage();

            if (_ZoneHandler.Update(c.Account.UserID, zone))
            {
                mr.Command = MNetMessage.UPDATEZONE;
                mr.Payload = zone.Serialize();
                Send(c, "Message", mr.Serialize());
            }
            else
            {
                mr.Command = MNetMessage.ERROR;
                mr.Payload = "You can't delete " + zone.Name + " because you are not the owner";
                Send(c, "Message", mr.Serialize());
            }
            ZoneChanged?.Invoke(this, new ZoneEvent(zone));
        }
        public void SetCurrentZone(Zone zoneId, bool silent = false)
        {
            if (zoneId == m_currentZoneId)
            {
                return;
            }

            m_isInside = (m_isInside && (zoneId == Zone.Estacionamiento || zoneId == Zone.Frente)) ?
                         false : (!m_isInside && zoneId == Zone.Principal);

            Transition?.Invoke(this, m_isInside);
            ZoneChanged?.Invoke(this, zoneId);

            m_currentZone   = zones[(int)zoneId];
            m_currentZoneId = zoneId;
            m_zoneToast.SetZone(m_currentZone);

            if (!m_debouncing && !silent)
            {
                m_debouncing = true;
                StartCoroutine(ShowZoneToast());
            }
        }
Beispiel #7
0
 public void SetZone(Zone?value, CardRepository repo)
 {
     CurrentZone = value;
     LoadDeck(repo);
     ZoneChanged?.Invoke();
 }
 void IZoneHandler <T> .OnZoneChanged(T zone)
 {
     ZoneChanged.InvokeSafe(zone);
 }
Beispiel #9
0
 private void OnZoneChanged(object sender, FileSystemEventArgs e)
 {
     ZoneChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #10
0
        private void MouseMoveCross(object sender, HookMouseEventArg e)
        {
            // TODO : if (e.Clicked) return;
            var pIn = e.Point;

            if (_oldZone.ContainsPx(pIn))
            {
                _oldPoint = pIn;
                e.Handled = false;
                return;
            }

            var  pInMmOld = _oldZone.Px2Mm(_oldPoint);
            var  pInMm    = _oldZone.Px2Mm(pIn);
            Zone zoneOut  = null;

            var trip    = new Segment(pInMmOld, pInMm);
            var minDist = double.PositiveInfinity;

            var pOutInMm = pInMm;

            foreach (var zone in _zones.All.Where(z => !ReferenceEquals(z, _oldZone)))
            {
                foreach (var p in trip.Line.Intersect(zone.Mm))
                {
                    var travel = new Segment(pInMmOld, p);
                    if (!travel.Rect.Contains(pInMm))
                    {
                        continue;
                    }
                    var dist = travel.SizeSquared;
                    if (dist > minDist)
                    {
                        continue;
                    }

                    minDist  = dist;
                    zoneOut  = zone;
                    pOutInMm = p;
                }
            }

            if (zoneOut == null)
            {
                LbmMouse.CursorPos = _oldZone.InsidePx(pIn);
                e.Handled          = true;
                return;
            }

            var pOut = zoneOut.Mm2Px(pOutInMm);

            pOut               = zoneOut.InsidePx(pOut);
            _oldZone           = zoneOut.Main;
            _oldPoint          = pOut;
            LbmMouse.CursorPos = pOut;
            ZoneChanged?.Invoke(this, new ZoneChangeEventArgs(_oldZone, zoneOut));
            e.Handled = true;
            return;

            //}

            //finally
            //{
            //    if (_count >= 0) _timer.Stop();
            //    _count++;
            //}
        }
Beispiel #11
0
        private void MouseMoveStraight(object sender, HookMouseEventArg e)
        {
            //TODO : if (e.Clicked) return;
            var pIn = e.Point;

            if (_oldZone.ContainsPx(pIn))
            {
                _oldPoint = pIn;
                e.Handled = false;
                return;
            }


            //Point oldpInMm = _oldZone.Px2Mm(_oldPoint);
            Point pInMm   = _oldZone.Px2Mm(pIn);
            Zone  zoneOut = null;

            var minDx = 0.0;
            var minDy = 0.0;

            if (pIn.Y > _oldZone.Px.Bottom)
            {
                foreach (var zone in _zones.All /*.Where(z => z.Mm.Top > _oldZone.Mm.Bottom)*/)
                {
                    if (zone.Mm.Left > pInMm.X || zone.Mm.Right < pInMm.X)
                    {
                        continue;
                    }
                    var dy = zone.Mm.Top - _oldZone.Mm.Bottom;

                    if (dy < 0)
                    {
                        continue;
                    }
                    if (dy > minDy && minDy > 0)
                    {
                        continue;
                    }


                    // = pInMm + new Vector(0, dy);
                    minDy   = dy;
                    zoneOut = zone;
                }
            }
            else if (pIn.Y < _oldZone.Px.Top)
            {
                foreach (var zone in _zones.All /*.Where(z => !ReferenceEquals(z, _oldZone))*/)
                {
                    if (zone.Mm.Left > pInMm.X || zone.Mm.Right < pInMm.X)
                    {
                        continue;
                    }
                    var dy = zone.Mm.Bottom - _oldZone.Mm.Top;

                    if (dy > 0)
                    {
                        continue;
                    }
                    if (dy < minDy && minDy < 0)
                    {
                        continue;
                    }

                    minDy   = dy;
                    zoneOut = zone;
                }
            }

            if (pIn.X > _oldZone.Px.Right)
            {
                foreach (var zone in _zones.All)
                {
                    if (zone.Mm.Top > pInMm.Y || zone.Mm.Bottom < pInMm.Y)
                    {
                        continue;
                    }
                    var dx = zone.Mm.Left - _oldZone.Mm.Right;

                    if (dx < 0)
                    {
                        continue;
                    }
                    if (dx > minDx && minDx > 0)
                    {
                        continue;
                    }

                    minDx   = dx;
                    zoneOut = zone;
                }
            }
            else if (pIn.X < _oldZone.Px.Left)
            {
                foreach (var zone in _zones.All)
                {
                    if (zone.Mm.Top > pInMm.Y || zone.Mm.Bottom < pInMm.Y)
                    {
                        continue;
                    }
                    var dx = zone.Mm.Right - _oldZone.Mm.Left;

                    if (dx < minDx && minDx < 0)
                    {
                        continue;
                    }
                    if (dx > 0)
                    {
                        continue;
                    }

                    minDx   = dx;
                    zoneOut = zone;
                }
            }

            if (zoneOut == null)
            {
                LbmMouse.CursorPos = _oldZone.InsidePx(pIn);
                e.Handled          = true;
                return;
            }

            var pOut = zoneOut.Mm2Px(new Point(pInMm.X + minDx, pInMm.Y + minDy));

            pOut      = zoneOut.InsidePx(pOut);
            _oldZone  = zoneOut.Main;
            _oldPoint = pOut;

            //IntPtr hwnd = OpenInputDesktop(0, false, DESKTOP_SWITCHDESKTOP);
            //SetThreadDesktop(hwnd);

            //var movement = new INPUT { Type = (UInt32)0 };
            //movement.Data.Mouse.Flags = (UInt32)(MouseFlag.Move | MouseFlag.Absolute | MouseFlag.VirtualDesk);
            //movement.Data.Mouse.X = (int)pOut.X;
            //movement.Data.Mouse.Y = (int)pOut.Y;

            //INPUT[] inputs = {movement};

            //SendInput((UInt32)inputs.Length, inputs, Marshal.SizeOf(typeof(INPUT)));

            LbmMouse.CursorPos = pOut;

            var p = LbmMouse.CursorPos;

            if (Math.Abs(pOut.X - p.X) >= 1 || Math.Abs(pOut.Y - p.Y) >= 1)
            {
                IntPtr hOldDesktop = GetThreadDesktop(GetCurrentThreadId());
                IntPtr hwnd        = OpenInputDesktop(0, true, (uint)DESKTOP_ACCESS.GENERIC_ALL);

                Thread t = new Thread(() =>
                {
                    SwitchDesktop(hwnd);
                    var b = SetThreadDesktop(hwnd);

                    var b2 = LbmMouse.MouseEvent(
                        NativeMethods.MOUSEEVENTF.ABSOLUTE | NativeMethods.MOUSEEVENTF.MOVE
                        | NativeMethods.MOUSEEVENTF.VIRTUALDESK
                        , pOut.X, pOut.Y);
                    if (b2 == 0)
                    {
                        var s = NativeMethods.GetLastError();
                    }

                    //LbmMouse.CursorPos = pOut;
                    var b3 = NativeMethods.SetCursorPos((int)pOut.X, (int)pOut.Y);

                    if (b3 == false)
                    {
                        var s = NativeMethods.GetLastError();
                    }

                    //    IList<string> list = new List<string>();
                    //    GCHandle gch = GCHandle.Alloc(list);
                    //    EnumWindowStationsDelegate childProc = new EnumWindowStationsDelegate(EnumWindowStationsCallback);

                    //    EnumWindowStations(childProc, GCHandle.ToIntPtr(gch));


                    //}
                });

                t.Start();
                t.Join();

                SwitchDesktop(hOldDesktop);

                //var w = new Window
                //{
                //    WindowStyle = WindowStyle.None,
                //    Visibility = Visibility.Collapsed,
                //    Width = 0,
                //    Height = 0
                //};
                //w.Show();

                ////const int DESKTOP_SWITCHDESKTOP = 256;
                ////IntPtr hwnd = OpenInputDesktop(0, false, 0x00020000);
                ////var b = SetThreadDesktop(hwnd);

                //LbmMouse.CursorPos = pOut;

                //w.Close();
            }

            ZoneChanged?.Invoke(this, new ZoneChangeEventArgs(_oldZone, zoneOut));
            e.Handled = true;
        }
 public void ChangeLocation(string newLocationID)
 {
     CurrentLocation = newLocationID;
     ZoneChanged?.Invoke(this, null);
 }
        private void MouseMovestraight(object sender, MouseEventExtArgs e)
        {
            if (e.Clicked)
            {
                return;
            }
            var pIn = new Point(e.X, e.Y);

            if (_oldZone.ContainsPx(pIn))
            {
                _oldPoint = pIn;
                e.Handled = false;
                return;
            }

            //Point oldpInMm = _oldZone.Px2Mm(_oldPoint);
            Point pInMm   = _oldZone.Px2Mm(pIn);
            Zone  zoneOut = null;

            var minDx = 0.0;
            var minDy = 0.0;

            if (pIn.Y > _oldZone.Px.Bottom)
            {
                foreach (var zone in _zones.All /*.Where(z => z.Mm.Top > _oldZone.Mm.Bottom)*/)
                {
                    if (zone.Mm.Left > pInMm.X || zone.Mm.Right < pInMm.X)
                    {
                        continue;
                    }
                    var dy = zone.Mm.Top - _oldZone.Mm.Bottom;

                    if (dy < 0)
                    {
                        continue;
                    }
                    if (dy > minDy && minDy > 0)
                    {
                        continue;
                    }


                    // = pInMm + new Vector(0, dy);
                    minDy   = dy;
                    zoneOut = zone;
                }
            }
            else if (pIn.Y < _oldZone.Px.Top)
            {
                foreach (var zone in _zones.All /*.Where(z => !ReferenceEquals(z, _oldZone))*/)
                {
                    if (zone.Mm.Left > pInMm.X || zone.Mm.Right < pInMm.X)
                    {
                        continue;
                    }
                    var dy = zone.Mm.Bottom - _oldZone.Mm.Top;

                    if (dy > 0)
                    {
                        continue;
                    }
                    if (dy < minDy && minDy < 0)
                    {
                        continue;
                    }

                    minDy   = dy;
                    zoneOut = zone;
                }
            }

            if (pIn.X > _oldZone.Px.Right)
            {
                foreach (var zone in _zones.All)
                {
                    if (zone.Mm.Top > pInMm.Y || zone.Mm.Bottom < pInMm.Y)
                    {
                        continue;
                    }
                    var dx = zone.Mm.Left - _oldZone.Mm.Right;

                    if (dx < 0)
                    {
                        continue;
                    }
                    if (dx > minDx && minDx > 0)
                    {
                        continue;
                    }

                    minDx   = dx;
                    zoneOut = zone;
                }
            }
            else if (pIn.X < _oldZone.Px.Left)
            {
                foreach (var zone in _zones.All)
                {
                    if (zone.Mm.Top > pInMm.Y || zone.Mm.Bottom < pInMm.Y)
                    {
                        continue;
                    }
                    var dx = zone.Mm.Right - _oldZone.Mm.Left;

                    if (dx < minDx && minDx < 0)
                    {
                        continue;
                    }
                    if (dx > 0)
                    {
                        continue;
                    }

                    minDx   = dx;
                    zoneOut = zone;
                }
            }

            if (zoneOut == null)
            {
                LbmMouse.CursorPos = _oldZone.InsidePx(pIn);
                e.Handled          = true;
                return;
            }

            var pOut = zoneOut.Mm2Px(new Point(pInMm.X + minDx, pInMm.Y + minDy));

            pOut               = zoneOut.InsidePx(pOut);
            _oldZone           = zoneOut.Main;
            _oldPoint          = pOut;
            LbmMouse.CursorPos = pOut;
            ZoneChanged?.Invoke(this, new ZoneChangeEventArgs(_oldZone, zoneOut));
            e.Handled = true;
        }