Ejemplo n.º 1
0
        public void Combine(VMMultitileGroup other)
        {
            var bObj = BaseObject;

            int Dir = 0;

            switch (bObj.Direction)
            {
            case Direction.NORTH:
                Dir = 0; break;

            case Direction.EAST:
                Dir = 2; break;

            case Direction.SOUTH:
                Dir = 4; break;

            case Direction.WEST:
                Dir = 6; break;
            }
            Matrix rotMat = Matrix.CreateRotationZ((float)(-Dir * Math.PI / 4.0));

            foreach (var obj in other.Objects)
            {
                var diff = obj.Position - bObj.Position;
                var vec  = new Vector3(diff.x, diff.y, 0);
                Vector3.Transform(vec, rotMat);
                AddDynamicObject(obj, new LotTilePos((short)Math.Round(vec.X), (short)Math.Round(vec.Y), diff.Level));
                obj.MultitileGroup = this;
                obj.Direction      = bObj.Direction;
            }
        }
Ejemplo n.º 2
0
 public void SetGUIDLocal(uint id)
 {
     oldGUID = id;
     GUID = id;
     if (TempVM != null)
     {
         if (TargetOBJ != null) TargetOBJ.Delete(TempVM.Context);
         TargetOBJ = TempVM.Context.CreateObjectInstance(GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
         if (TargetOBJ != null && TargetOBJ.BaseObject is VMGameObject) UpdateThumb();
         else Thumb = null;
     }
 }
Ejemplo n.º 3
0
        public UIWallPainter(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World = parent.World;
            Parent = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
            Commands = new List<VMArchitectureCommand>();

            SetCursorGraphic(2);
        }
Ejemplo n.º 4
0
        public UIWallPlacer(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];
            Style = (ushort)parameters[1];
            if (Style == 1)
            {
                DrawPattern = 255;
                DrawStyle = 255;
            } else
            {
                DrawPattern = Pattern;
                DrawStyle = Style;
            }

            this.vm = vm;
            World = parent.World;
            Parent = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x00000439, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
        }
Ejemplo n.º 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.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;
        }
Ejemplo n.º 6
0
 public VMMultitileGroup(VMMultitileGroup baseGroup)
 {
     InitialPrice = baseGroup.InitialPrice;
     MultiTile    = baseGroup.MultiTile;
 }
Ejemplo n.º 7
0
        public VMMultitileGroup GhostCopyGroup(VMMultitileGroup group)
        {
            var newGroup = CreateObjectInstance(((group.MultiTile) ? group.BaseObject.MasterDefinition.GUID : group.BaseObject.Object.OBJ.GUID), LotTilePos.OUT_OF_WORLD, group.BaseObject.Direction, true);

            return newGroup;
        }
Ejemplo n.º 8
0
        public VMMultitileGroup CreateObjectInstance(UInt32 GUID, LotTilePos pos, Direction direction, short MainStackOBJ, short MainParam, bool ghostImage)
        {
            VMMultitileGroup group = new VMMultitileGroup();
            var objDefinition = FSO.Content.Content.Get().WorldObjects.Get(GUID);
            if (objDefinition == null)
            {
                return null;
            }

            var master = objDefinition.OBJ.MasterID;
            if (master != 0)
            {
                group.MultiTile = true;
                var objd = objDefinition.Resource.List<OBJD>();

                for (int i = 0; i < objd.Count; i++)
                {
                    if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it!
                    {
                        var subObjDefinition = FSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID);
                        if (subObjDefinition != null)
                        {
                            var worldObject = new ObjectComponent(subObjDefinition);
                            var vmObject = new VMGameObject(subObjDefinition, worldObject);
                            vmObject.GhostImage = ghostImage;

                            vmObject.MasterDefinition = objDefinition.OBJ;
                            vmObject.UseTreeTableOf(objDefinition);

                            vmObject.MainParam = MainParam;
                            vmObject.MainStackOBJ = MainStackOBJ;
                            group.Objects.Add(vmObject);

                            vmObject.MultitileGroup = group;
                            if (!ghostImage) VM.AddEntity(vmObject);

                        }
                    }
                }

                group.Init(this);
                VMPlacementError couldPlace = group.ChangePosition(pos, direction, this).Status;
                return group;
            }
            else
            {
                if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person
                {
                    var vmObject = new VMAvatar(objDefinition);
                    vmObject.MultitileGroup = group;
                    group.Objects.Add(vmObject);

                    vmObject.GhostImage = ghostImage;
                    if (!ghostImage) VM.AddEntity(vmObject);

                    if (UseWorld) Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI);

                    vmObject.MainParam = MainParam;
                    vmObject.MainStackOBJ = MainStackOBJ;

                    group.Init(this);
                    vmObject.SetPosition(pos, direction, this);

                    return group;
                }
                else
                {
                    var worldObject = new ObjectComponent(objDefinition);
                    var vmObject = new VMGameObject(objDefinition, worldObject);

                    vmObject.MultitileGroup = group;

                    group.Objects.Add(vmObject);

                    vmObject.GhostImage = ghostImage;
                    if (!ghostImage) VM.AddEntity(vmObject);

                    vmObject.MainParam = MainParam;
                    vmObject.MainStackOBJ = MainStackOBJ;

                    group.Init(this);
                    vmObject.SetPosition(pos, direction, this);

                    return group;
                }
            }
        }
Ejemplo n.º 9
0
        public void SetGUIDLocal(uint id, VM TempVM)
        {
            oldGUID = id;
            GUID = id;
            if (TempVM != null)
            {
                if (TargetOBJ != null) TargetOBJ.Delete(TempVM.Context);
                //create our master, center camera on target object
                var objDefinition = FSO.Content.Content.Get().WorldObjects.Get(GUID);

                if (objDefinition != null)
                {
                    var masterID = id;
                    var notMaster = objDefinition.OBJ.MasterID != 0 && objDefinition.OBJ.SubIndex != -1;
                    if (notMaster)
                    {
                        //find the master
                        var master = objDefinition.Resource.List<OBJD>().FirstOrDefault(x => x.MasterID == objDefinition.OBJ.MasterID && x.SubIndex == -1);
                        if (master != null) masterID = master.GUID;
                    }
                    TargetOBJ = TempVM.Context.CreateObjectInstance(masterID, LotTilePos.OUT_OF_WORLD, Direction.SOUTH, true);
                    TargetOBJ.SetVisualPosition(new Vector3(0.5f, 0.5f, 0f), Direction.SOUTH, TempVM.Context);
                    TempVM.Entities = TargetOBJ.Objects;
                    if (TargetOBJ == null) return;
                    TargetTile = TargetOBJ.Objects.FirstOrDefault(x => x.Object.OBJ.GUID == id);
                    if (TargetTile == null) TargetTile = TargetOBJ.BaseObject;
                    var tile = TargetTile.VisualPosition;
                    TempVM.Context.World.State.CenterTile = new Vector2(tile.X, tile.Y) - new Vector2(2.5f, 2.5f);
                    foreach (var obj in TargetOBJ.Objects)
                    {
                        if (obj is VMGameObject) ((ObjectComponent)obj.WorldUI).renderInfo.Layer = LotView.WorldObjectRenderLayer.DYNAMIC;
                        if (notMaster && obj.Object.OBJ.GUID != id) obj.SetRoom(2);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        void Catalog_OnSelectionChange(int selection)
        {
            var item = CurrentCategory[selection];

            if (LotController.ActiveEntity != null && item.Price > LotController.ActiveEntity.TSOState.Budget.Value)
            {
                HIT.HITVM.Get().PlaySoundEvent(Model.UISounds.Error);
                return;
            }

            if (OldSelection != -1) Catalog.SetActive(OldSelection, false);
            Catalog.SetActive(selection, true);
            BuyItem = vm.Context.CreateObjectInstance(item.GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
            if (BuyItem == null) return; //uh
            QueryPanel.SetInfo(LotController.vm, BuyItem.Objects[0], false);
            QueryPanel.Mode = 1;
            QueryPanel.Tab = 0;
            QueryPanel.Active = true;
            Holder.SetSelected(BuyItem);
            OldSelection = selection;
        }
Ejemplo n.º 11
0
        public VMMultitileGroup GhostCopyGroup(VMMultitileGroup group)
        {
            var newGroup = CreateObjectInstance(((group.MultiTile) ? group.BaseObject.MasterDefinition.GUID : group.BaseObject.Object.OBJ.GUID), LotTilePos.OUT_OF_WORLD, group.BaseObject.Direction, true);

            if (newGroup != null)
            {
                newGroup.Price = group.Price;
                for (int i=0; i < Math.Min(newGroup.Objects.Count, group.Objects.Count); i++) {
                    newGroup.Objects[i].GhostOriginal = group;
                    newGroup.Objects[i].SetValue(VMStackObjectVariable.Graphic, group.Objects[i].GetValue(VMStackObjectVariable.Graphic));
                    newGroup.Objects[i].DynamicSpriteFlags = group.Objects[i].DynamicSpriteFlags;
                    newGroup.Objects[i].DynamicSpriteFlags2 = group.Objects[i].DynamicSpriteFlags2;
                    newGroup.Objects[i].SetDynamicSpriteFlag(0, group.Objects[i].IsDynamicSpriteFlagSet(0));
                    newGroup.Objects[i].PlatformState = group.Objects[i].PlatformState;
                    if (newGroup.Objects[i] is VMGameObject) ((VMGameObject)newGroup.Objects[i]).RefreshGraphic();
                }
            }

            return newGroup;
        }
Ejemplo n.º 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];
         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;
 }
Ejemplo n.º 13
0
        void Catalog_OnSelectionChange(int selection)
        {
            Holder.ClearSelected();
            var item = CurrentCategory[selection];
            if (OldSelection != -1) Catalog.SetActive(OldSelection, false);
            Catalog.SetActive(selection, true);

            if (LotController.CustomControl != null)
            {
                LotController.CustomControl.Release();
                LotController.CustomControl = null;
            }

            if (item.Special != null)
            {
                QueryPanel.Active = false;
                LotController.CustomControl = (UICustomLotControl)Activator.CreateInstance(item.Special.Control, vm, LotController.World, LotController, item.Special.Parameters);
            }
            else
            {
                BuyItem = vm.Context.CreateObjectInstance(item.GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
                QueryPanel.SetInfo(BuyItem.Objects[0], false);
                QueryPanel.Mode = 1;
                QueryPanel.Tab = 0;
                QueryPanel.Active = true;
                Holder.SetSelected(BuyItem);
            }

            OldSelection = selection;
        }
Ejemplo n.º 14
0
        void Catalog_OnSelectionChange(int selection)
        {
            Holder.ClearSelected();
            var item = CurrentCategory[selection];

            if (LotController.ActiveEntity != null && item.Price > LotController.ActiveEntity.TSOState.Budget.Value) {
                HIT.HITVM.Get().PlaySoundEvent(UISounds.Error);
                return;
            }

            if (OldSelection != -1) Catalog.SetActive(OldSelection, false);
            Catalog.SetActive(selection, true);

            if (LotController.CustomControl != null)
            {
                LotController.CustomControl.Release();
                LotController.CustomControl = null;
            }

            if (item.Special != null)
            {
                var res = item.Special.Res;
                var resID = item.Special.ResID;
                QueryPanel.SetInfo(res.GetIcon(resID), res.GetName(resID), res.GetDescription(resID), res.GetPrice(resID));
                QueryPanel.Mode = 1;
                QueryPanel.Tab = 0;
                QueryPanel.Active = true;
                LotController.CustomControl = (UICustomLotControl)Activator.CreateInstance(item.Special.Control, vm, LotController.World, LotController, item.Special.Parameters);
            }
            else
            {
                BuyItem = vm.Context.CreateObjectInstance(item.GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
                QueryPanel.SetInfo(LotController.vm, BuyItem.Objects[0], false);
                QueryPanel.Mode = 1;
                QueryPanel.Tab = 0;
                QueryPanel.Active = true;
                Holder.SetSelected(BuyItem);
            }

            OldSelection = selection;
        }
Ejemplo n.º 15
0
 void Catalog_OnSelectionChange(int selection)
 {
     if (OldSelection != -1) Catalog.SetActive(OldSelection, false);
     Catalog.SetActive(selection, true);
     BuyItem = vm.Context.CreateObjectInstance(CurrentCategory[selection].GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true);
     QueryPanel.SetInfo(BuyItem.Objects[0], false);
     QueryPanel.Mode = 1;
     QueryPanel.Tab = 0;
     QueryPanel.Active = true;
     Holder.SetSelected(BuyItem);
     OldSelection = selection;
 }
Ejemplo n.º 16
0
        public void Combine(VMMultitileGroup other)
        {
            var bObj = BaseObject;

            int Dir = 0;
            switch (bObj.Direction)
            {
                case Direction.NORTH:
                    Dir = 0; break;
                case Direction.EAST:
                    Dir = 2; break;
                case Direction.SOUTH:
                    Dir = 4; break;
                case Direction.WEST:
                    Dir = 6; break;
            }
            Matrix rotMat = Matrix.CreateRotationZ((float)(-Dir * Math.PI / 4.0));
            foreach (var obj in other.Objects)
            {
                var diff = obj.Position - bObj.Position;
                var vec = new Vector3(diff.x, diff.y, 0);
                Vector3.Transform(vec, rotMat);
                AddDynamicObject(obj, new LotTilePos((short)Math.Round(vec.X), (short)Math.Round(vec.Y), diff.Level));
                obj.MultitileGroup = this;
                obj.Direction = bObj.Direction;
            }
        }