Example #1
0
 private void HolderPickup(UIObjectSelection holding, UpdateState state)
 {
     QueryPanel.Mode   = 0;
     QueryPanel.Active = true;
     QueryPanel.SetInfo(LotController.vm, holding.RealEnt ?? holding.Group.BaseObject, holding.IsBought);
     QueryPanel.Tab = 1;
 }
Example #2
0
 public void SetSelected(VMMultitileGroup Group)
 {
     if (Holding != null)
     {
         ClearSelected();
     }
     Holding              = new UIObjectSelection();
     Holding.Group        = Group;
     Holding.PreviousTile = Holding.Group.BaseObject.Position;
     Holding.Dir          = Group.Objects[0].Direction;
     VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count];
     for (int i = 0; i < Group.Objects.Count; i++)
     {
         var target = Group.Objects[i];
         target.SetRoom(65534);
         if (target is VMGameObject)
         {
             ((ObjectComponent)target.WorldUI).ForceDynamic = true;
         }
         CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).Objects[0];
         CursorTiles[i].SetPosition(new LotTilePos(0, 0, 1), Direction.NORTH, vm.Context);
         ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true;
     }
     Holding.TilePosOffset = new Vector2(0, 0);
     Holding.CursorTiles   = CursorTiles;
 }
Example #3
0
 private void HolderDelete(UIObjectSelection holding, UpdateState state)
 {
     if (OldSelection != -1)
     {
         Catalog.SetActive(OldSelection, false);
         OldSelection = -1;
     }
     QueryPanel.Active = false;
 }
 private void HolderBeforeRelease(UIObjectSelection holding, UpdateState state)
 {
     // remember the upgrade level between entering the catalog
     if (!holding.IsBought)
     {
         var guid    = holding.Group.GUID;
         var baseObj = holding.Group.BaseObject;
         var level   = (baseObj.PlatformState as VMTSOObjectState)?.UpgradeLevel ?? 0;
         UpgradeLevelMemory[guid] = level;
     }
 }
Example #5
0
        public void SetSelected(VMMultitileGroup Group)
        {
            if (Holding != null)
            {
                ClearSelected();
            }
            Holding              = new UIObjectSelection();
            Holding.Group        = Group;
            Holding.PreviousTile = Holding.Group.BaseObject.Position;
            Holding.Dir          = Group.Objects[0].Direction;
            VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count];
            for (int i = 0; i < Group.Objects.Count; i++)
            {
                var target = Group.Objects[i];
                target.ExecuteEntryPoint(10, vm.Context, true, target);
                target.SetRoom(65534);
                if (target is VMGameObject)
                {
                    ((ObjectComponent)target.WorldUI).ForceDynamic = true;
                }
                CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).Objects[0];
                CursorTiles[i].SetPosition(new LotTilePos(0, 0, 1), Direction.NORTH, vm.Context);
                CursorTiles[i].SetRoom(65535);
                ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true;
            }
            Holding.TilePosOffset = new Vector2(0, 0);
            Holding.CursorTiles   = CursorTiles;

            uint guid;
            var  bobj = Group.BaseObject;

            guid = bobj.Object.OBJ.GUID;
            if (bobj.MasterDefinition != null)
            {
                guid = bobj.MasterDefinition.GUID;
            }
            var catalogItem = Content.Content.Get().WorldCatalog.GetItemByGUID(guid);

            if (catalogItem != null)
            {
                var price      = Group.InitialPrice; //(int)catalogItem.Value.Price;
                var dcPercent  = VMBuildableAreaInfo.GetDiscountFor(catalogItem.Value, vm);
                var finalPrice = (price * (100 - dcPercent)) / 100;
                if (DonateMode)
                {
                    finalPrice -= (finalPrice * 2) / 3;
                }
                Holding.Price       = finalPrice;
                Group.InitialPrice  = finalPrice;
                Group.BeforeDCPrice = price;
            }
        }
Example #6
0
        public void ClearSelected()
        {
            if (Holding != null) BeforeRelease?.Invoke(Holding, LastState);
            if (Holding != null)
            {
                RecursiveDelete(vm.Context, Holding.Group.BaseObject);

                for (int i = 0; i < Holding.CursorTiles.Length; i++) {
                    Holding.CursorTiles[i].Delete(true, vm.Context);
                    ((ObjectComponent)Holding.CursorTiles[i].WorldUI).ForceDynamic = false;
                }
            }
            Holding = null;
        }
Example #7
0
        public void ClearSelected()
        {
            //TODO: selected items are only spooky ghosts of the items themselves.
            //      ...so that they dont cause serverside desyncs
            //      and so that clearing selections doesnt delete already placed objects.
            if (Holding != null)
            {
                Holding.Group.Delete(vm.Context);

                for (int i = 0; i < Holding.CursorTiles.Length; i++)
                {
                    Holding.CursorTiles[i].Delete(true, vm.Context);
                    ((ObjectComponent)Holding.CursorTiles[i].WorldUI).ForceDynamic = false;
                }
            }
            Holding = null;
        }
Example #8
0
 private void HolderPutDown(UIObjectSelection holding, UpdateState state)
 {
     if (OldSelection != -1)
     {
         if (!holding.IsBought && (state.KeyboardState.IsKeyDown(Keys.LeftShift) || state.KeyboardState.IsKeyDown(Keys.RightShift)))
         {
             //place another
             var prevDir = holding.Dir;
             Catalog_OnSelectionChange(OldSelection);
             Holder.Holding.Dir = prevDir;
         }
         else
         {
             Catalog.SetActive(OldSelection, false);
             OldSelection = -1;
         }
     }
     QueryPanel.Active = false;
 }
Example #9
0
 void HolderPutDown(UIObjectSelection holding, UpdateState state)
 {
     if (OldSelection != -1)
     {
         if (!holding.IsBought && state.ShiftDown)
         {
             //place another
             var prevDir = holding.Dir;
             Catalog_OnSelectionChange(OldSelection);
             Holder.Holding.Dir = prevDir;
         }
         else
         {
             Catalog.SetActive(OldSelection, false);
             OldSelection = -1;
         }
     }
     QueryPanel.Active = false;
 }
Example #10
0
        public void SetSelected(VMMultitileGroup Group)
        {
            if (Holding != null)
            {
                ClearSelected();
            }
            Holding              = new UIObjectSelection();
            Holding.Group        = Group;
            Holding.PreviousTile = Holding.Group.BaseObject.Position;
            Holding.Dir          = Group.Objects[0].Direction;
            VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count];
            for (int i = 0; i < Group.Objects.Count; i++)
            {
                var target = Group.Objects[i];
                target.SetRoom(65534);
                if (target is VMGameObject)
                {
                    ((ObjectComponent)target.WorldUI).ForceDynamic = true;
                }
                CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).Objects[0];
                CursorTiles[i].SetPosition(new LotTilePos(0, 0, 1), Direction.NORTH, vm.Context);
                ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true;
            }
            Holding.TilePosOffset = new Vector2(0, 0);
            Holding.CursorTiles   = CursorTiles;

            uint guid;
            var  bobj = Group.BaseObject;

            guid = bobj.Object.OBJ.GUID;
            if (bobj.MasterDefinition != null)
            {
                guid = bobj.MasterDefinition.GUID;
            }
            var catalogItem = Content.Content.Get().WorldCatalog.GetItemByGUID(guid);

            if (catalogItem != null)
            {
                Holding.Price = (int)catalogItem.Price;
            }
        }
Example #11
0
        public void ClearSelected()
        {
            //TODO: selected items are only spooky ghosts of the items themselves.
            //      ...so that they dont cause serverside desyncs
            //      and so that clearing selections doesnt delete already placed objects.
            if (Holding != null)
            {
                Holding.Group.Delete(vm.Context);

                for (int i = 0; i < Holding.CursorTiles.Length; i++) {
                    Holding.CursorTiles[i].Delete(true, vm.Context);
                    ((ObjectComponent)Holding.CursorTiles[i].WorldUI).ForceDynamic = false;
                }
            }
            Holding = null;
        }
Example #12
0
        public void SetSelected(VMMultitileGroup Group)
        {
            if (Holding != null) ClearSelected();
            Holding = new UIObjectSelection();
            Holding.Group = Group;
            Holding.PreviousTile = Holding.Group.BaseObject.Position;
            Holding.Dir = Group.Objects[0].Direction;
            VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count];
            for (int i = 0; i < Group.Objects.Count; i++)
            {
                var target = Group.Objects[i];
                target.SetRoom(65534);
                if (target is VMGameObject) ((ObjectComponent)target.WorldUI).ForceDynamic = true;
                CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).Objects[0];
                CursorTiles[i].SetPosition(new LotTilePos(0,0,1), Direction.NORTH, vm.Context);
                ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true;
            }
            Holding.TilePosOffset = new Vector2(0, 0);
            Holding.CursorTiles = CursorTiles;

            uint guid;
            var bobj = Group.BaseObject;
            guid = bobj.Object.OBJ.GUID;
            if (bobj.MasterDefinition != null) guid = bobj.MasterDefinition.GUID;
            var catalogItem = Content.Content.Get().WorldCatalog.GetItemByGUID(guid);
            if (catalogItem != null) Holding.Price = (int)catalogItem.Price;
        }
Example #13
0
 private void HolderPutDown(UIObjectSelection holding, UpdateState state)
 {
     if (OldSelection != -1)
     {
         if (!holding.IsBought && (state.KeyboardState.IsKeyDown(Keys.LeftShift) || state.KeyboardState.IsKeyDown(Keys.RightShift))) {
             //place another
             var prevDir = holding.Dir;
             Catalog_OnSelectionChange(OldSelection);
             if (Holder.Holding != null) Holder.Holding.Dir = prevDir;
         } else {
             Catalog.SetActive(OldSelection, false);
             OldSelection = -1;
         }
     }
     QueryPanel.Active = false;
 }
Example #14
0
 private void HolderPickup(UIObjectSelection holding, UpdateState state)
 {
     QueryPanel.Mode = 0;
     QueryPanel.Active = true;
     QueryPanel.Tab = 1;
     QueryPanel.SetInfo(LotController.vm, holding.Group.BaseObject, holding.IsBought);
 }
Example #15
0
 private void HolderDelete(UIObjectSelection holding, UpdateState state)
 {
     if (OldSelection != -1)
     {
         Catalog.SetActive(OldSelection, false);
         OldSelection = -1;
     }
     QueryPanel.Active = false;
 }
Example #16
0
 public void SetSelected(VMMultitileGroup Group)
 {
     if (Holding != null) ClearSelected();
     Holding = new UIObjectSelection();
     Holding.Group = Group;
     Holding.PreviousTile = Holding.Group.BaseObject.Position;
     Holding.Dir = Group.Objects[0].Direction;
     VMEntity[] CursorTiles = new VMEntity[Group.Objects.Count];
     for (int i = 0; i < Group.Objects.Count; i++)
     {
         var target = Group.Objects[i];
         if (target is VMGameObject) ((ObjectComponent)target.WorldUI).ForceDynamic = true;
         CursorTiles[i] = vm.Context.CreateObjectInstance(0x00000437, new LotTilePos(target.Position), FSO.LotView.Model.Direction.NORTH, true).Objects[0];
         CursorTiles[i].SetPosition(new LotTilePos(0,0,1), Direction.NORTH, vm.Context);
         ((ObjectComponent)CursorTiles[i].WorldUI).ForceDynamic = true;
     }
     Holding.TilePosOffset = new Vector2(0, 0);
     Holding.CursorTiles = CursorTiles;
 }