Exemple #1
0
        public override void Unload()
        {
            ItemHold.Clear();

            try
            {
                Plugin.OnDisconnected();
            }
            catch
            {
            }

            TargetManager.Reset();

            // special case for wmap. this allow us to save settings
            UIManager.GetGump <WorldMapGump>()
            ?.SaveSettings();

            ProfileManager.Current?.Save
            (
                UIManager.Gumps.OfType <Gump>()
                .Where(s => s.CanBeSaved)
                .Reverse()
                .ToList()
            );

            Macros.Save();
            InfoBars.Save();
            ProfileManager.UnLoadProfile();

            StaticFilters.CleanCaveTextures();
            StaticFilters.CleanTreeTextures();

            NetClient.Socket.Disconnected -= SocketOnDisconnected;
            NetClient.Socket.Disconnect();
            _lightRenderTarget?.Dispose();
            _world_render_target?.Dispose();

            CommandManager.UnRegisterAll();
            Weather.Reset();
            UIManager.Clear();
            World.Clear();
            UOChatManager.Clear();
            DelayedObjectClickManager.Clear();

            _useItemQueue?.Clear();
            _useItemQueue = null;
            Hotkeys       = null;
            Macros        = null;
            MessageManager.MessageReceived -= ChatOnMessageReceived;


            Settings.GlobalSettings.WindowSize        = new Point(Client.Game.Window.ClientBounds.Width, Client.Game.Window.ClientBounds.Height);
            Settings.GlobalSettings.IsWindowMaximized = Client.Game.IsWindowMaximized();
            Client.Game.SetWindowBorderless(false);

            base.Unload();
        }
        private bool PickupItemDirectly(Item item, int x, int y, int amount, Point?offset)
        {
            if (World.Player.IsDead || ItemHold.Enabled || item == null || item.IsDestroyed)
            {
                return(false);
            }

            if (amount <= 0)
            {
                amount = item.Amount;
            }

            ItemHold.Clear();
            ItemHold.Set(item, (ushort)amount);
            NetClient.Socket.Send(new PPickUpRequest(item, (ushort)amount));
            UIManager.GameCursor.SetDraggedItem(offset);

            if (!item.OnGround)
            {
                //Entity entity = World.Get(item.Container);
                //item.Container = Serial.INVALID;
                //entity.Items.Remove(item);

                //if (entity != null && entity.HasEquipment)
                //    entity.FindItemByLayer( item.Layer] = null;

                //entity.Items.ProcessDelta();
            }
            else
            {
                item.RemoveFromTile();
            }
            item.TextContainer?.Clear();

            //item.AllowedToDraw = false;
            //World.Items.Remove(item);
            //World.Items.ProcessDelta();
            //CloseItemGumps(item);

            //World.RemoveItem(item.Serial, true);

            World.ObjectToRemove = item.Serial;

            return(true);
        }
Exemple #3
0
        private bool PickupItemDirectly(Item item, int x, int y, int amount, Point?offset)
        {
            if (World.Player.IsDead || ItemHold.Enabled || item == null || item.IsDestroyed /*|| (!ItemHold.Enabled && ItemHold.Dropped && ItemHold.Serial.IsValid)*/)
            {
                return(false);
            }

            ItemHold.Clear();
            ItemHold.Set(item, amount <= 0 ? item.Amount : (ushort)amount);
            UIManager.GameCursor.SetDraggedItem(offset);

            if (!item.OnGround)
            {
                Entity entity = World.Get(item.Container);
                //item.Container = Serial.INVALID;
                //entity.Items.Remove(item);

                if (entity.HasEquipment)
                {
                    entity.Equipment[(int)item.Layer] = null;
                }

                //entity.Items.ProcessDelta();
            }
            else
            {
                item.RemoveFromTile();
            }
            item.TextContainer?.Clear();

            item.AllowedToDraw = false;
            //World.Items.Remove(item);
            //World.Items.ProcessDelta();
            //CloseItemGumps(item);

            NetClient.Socket.Send(new PPickUpRequest(item, (ushort)amount));

            return(true);
        }
Exemple #4
0
        public override void Load()
        {
            base.Load();

            ItemHold.Clear();
            Hotkeys = new HotkeysManager();
            Macros  = new MacroManager();

            // #########################################################
            // [FILE_FIX]
            // TODO: this code is a workaround to port old macros to the new xml system.
            if (ProfileManager.CurrentProfile.Macros != null)
            {
                for (int i = 0; i < ProfileManager.CurrentProfile.Macros.Length; i++)
                {
                    Macros.PushToBack(ProfileManager.CurrentProfile.Macros[i]);
                }

                Macros.Save();

                ProfileManager.CurrentProfile.Macros = null;
            }
            // #########################################################

            Macros.Load();

            InfoBars = new InfoBarManager();
            InfoBars.Load();
            _healthLinesManager = new HealthLinesManager();
            Weather             = new Weather();

            WorldViewportGump viewport = new WorldViewportGump(this);

            UIManager.Add(viewport, false);

            if (!ProfileManager.CurrentProfile.TopbarGumpIsDisabled)
            {
                TopBarGump.Create();
            }


            CommandManager.Initialize();
            NetClient.Socket.Disconnected += SocketOnDisconnected;

            MessageManager.MessageReceived += ChatOnMessageReceived;

            UIManager.ContainerScale = ProfileManager.CurrentProfile.ContainersScale / 100f;

            SDL.SDL_SetWindowMinimumSize(Client.Game.Window.Handle, 640, 480);

            if (ProfileManager.CurrentProfile.WindowBorderless)
            {
                Client.Game.SetWindowBorderless(true);
            }
            else if (Settings.GlobalSettings.IsWindowMaximized)
            {
                Client.Game.MaximizeWindow();
            }
            else if (Settings.GlobalSettings.WindowSize.HasValue)
            {
                int w = Settings.GlobalSettings.WindowSize.Value.X;
                int h = Settings.GlobalSettings.WindowSize.Value.Y;

                w = Math.Max(640, w);
                h = Math.Max(480, h);

                Client.Game.SetWindowSize(w, h);
            }


            CircleOfTransparency.Create(ProfileManager.CurrentProfile.CircleOfTransparencyRadius);
            Plugin.OnConnected();


            Camera.SetZoomValues
            (
                new[]
            {
                .5f, .6f, .7f, .8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f,
                2.3f, 2.4f, 2.5f
            }
            );

            Camera.Zoom = ProfileManager.CurrentProfile.DefaultScale;
        }
Exemple #5
0
        public static void EquipCustom()
        {
            GameScene gs11         = Client.Game.GetScene <GameScene>();
            var       _backpack    = World.Player.FindItemByLayer(Layer.Backpack);
            Item      customweapon = World.Items.Get(ProfileManager.CurrentProfile.CustomSerial);

            if (World.Player != null && !World.Player.IsDead)
            {
                if (ItemHold.Enabled)
                {
                    return;
                }
                if (_backpack == null)
                {
                    return;
                }
                if (customweapon == null)
                {
                    return;
                }

                if (customweapon.Serial == 0 || ProfileManager.CurrentProfile.CustomSerial == 0)
                {
                    if (World.Player.FindItemByLayer(Layer.OneHanded) != null)
                    {
                        customweapon.Serial = World.Player.FindItemByLayer(Layer.OneHanded).Serial;
                        GameActions.Print("Custom Item not defined, Setting current equipped Item", 33, MessageType.System);
                    }
                    else if (World.Player.FindItemByLayer(Layer.OneHanded) != null)
                    {
                        customweapon.Serial = World.Player.FindItemByLayer(Layer.TwoHanded).Serial;
                        GameActions.Print("Custom Item not defined, Setting current equipped Item", 33, MessageType.System);
                    }
                    else
                    {
                        TargetManager.SetTargeting(CursorTarget.SetCustomSerial, 0, TargetType.Neutral);
                        GameActions.Print("Custom Item not defined, Using SetCustomSerial Hotkey.", 33, MessageType.System);
                    }
                }

                if (EM_FindCustomWeapon() != null)
                {
                    EM_UnEquip();
                    TimeSpan.FromMilliseconds(50);
                }
                else if (customweapon != null && customweapon.Serial != 0)
                {
                    customweapon.Serial = ProfileManager.CurrentProfile.CustomSerial;
                    GameActions.PickUp(customweapon.Serial, 0, 0, 1);
                    TimeSpan.FromMilliseconds(50);

                    if (ItemHold.Enabled && !ItemHold.Dropped)
                    {
                        GameActions.Equip();
                    }
                    else
                    {
                        return;
                    }

                    if (ItemHold.Dropped)
                    {
                        ItemHold.Clear();
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }