GetObjectIDAtScreenPos() public method

Gets the ID of the object at a given position.
public GetObjectIDAtScreenPos ( int x, int y, GraphicsDevice gd ) : short
x int X position of object.
y int Y position of object.
gd GraphicsDevice GraphicsDevice instance.
return short
Ejemplo n.º 1
0
        public void ShowPieMenu(Point pt, UpdateState state)
        {
            if (!LiveMode)
            {
                //if (CustomControl != null) CustomControl.MouseDown(state);
                //else ObjectHolder.MouseDown(state);
                return;
            }
            if (PieMenu == null && ActiveEntity != null)
            {
                VMEntity obj;
                //get new pie menu, make new pie menu panel for it
                var tilePos = World.EstTileAtPosWithScroll(new Vector2(pt.X, pt.Y) / FSOEnvironment.DPIScaleFactor);

                LotTilePos targetPos = LotTilePos.FromBigTile((short)tilePos.X, (short)tilePos.Y, World.State.Level);
                if (vm.Context.SolidToAvatars(targetPos).Solid)
                {
                    targetPos = LotTilePos.OUT_OF_WORLD;
                }

                GotoObject.SetPosition(targetPos, Direction.NORTH, vm.Context);

                var newHover = World.GetObjectIDAtScreenPos(pt.X,
                                                            pt.Y,
                                                            GameFacade.GraphicsDevice);

                ObjectHover = newHover;

                bool objSelected = ObjectHover > 0;
                if (objSelected || (GotoObject.Position != LotTilePos.OUT_OF_WORLD && ObjectHover <= 0))
                {
                    if (objSelected)
                    {
                        obj = vm.GetObjectById(ObjectHover);
                    }
                    else
                    {
                        obj = GotoObject;
                    }
                    if (obj != null)
                    {
                        obj = obj.MultitileGroup.GetInteractionGroupLeader(obj);
                        if (obj is VMGameObject && ((VMGameObject)obj).Disabled > 0)
                        {
                            var flags = ((VMGameObject)obj).Disabled;

                            if ((flags & VMGameObjectDisableFlags.ForSale) > 0)
                            {
                                //for sale
                                var retailPrice = obj.MultitileGroup.Price; //wrong... should get this from catalog
                                var salePrice   = obj.MultitileGroup.SalePrice;
                                ShowErrorTooltip(state, 22, true, "$" + retailPrice.ToString("##,#0"), "$" + salePrice.ToString("##,#0"));
                            }
                            else if ((flags & VMGameObjectDisableFlags.LotCategoryWrong) > 0)
                            {
                                ShowErrorTooltip(state, 21, true); //category wrong
                            }
                            else if ((flags & VMGameObjectDisableFlags.TransactionIncomplete) > 0)
                            {
                                ShowErrorTooltip(state, 27, true); //transaction not yet complete
                            }
                            else if ((flags & VMGameObjectDisableFlags.ObjectLimitExceeded) > 0)
                            {
                                ShowErrorTooltip(state, 24, true); //object is temporarily disabled... todo: something more helpful
                            }
                            else if ((flags & VMGameObjectDisableFlags.PendingRoommateDeletion) > 0)
                            {
                                ShowErrorTooltip(state, 16, true); //pending roommate deletion
                            }
                        }
                        else
                        {
                            var menu = obj.GetPieMenu(vm, ActiveEntity, false, true);
                            if (menu.Count != 0)
                            {
                                HITVM.Get().PlaySoundEvent(UISounds.PieMenuAppear);
                                PieMenu = new UIPieMenu(menu, obj, ActiveEntity, this);
                                this.Add(PieMenu);
                                PieMenu.X = state.MouseState.X / FSOEnvironment.DPIScaleFactor;
                                PieMenu.Y = state.MouseState.Y / FSOEnvironment.DPIScaleFactor;
                                PieMenu.UpdateHeadPosition(state.MouseState.X, state.MouseState.Y);
                            }
                        }
                    }
                }
                else
                {
                    ShowErrorTooltip(state, 0, true);
                }
            }
            else
            {
                if (PieMenu != null)
                {
                    PieMenu.RemoveSimScene();
                }
                this.Remove(PieMenu);
                PieMenu = null;
            }
        }