Beispiel #1
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm    = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt     = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                                                                                     GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel   = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 177;
            QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228;
            this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            vm.OnChatEvent  += Vm_OnChatEvent;
            vm.OnDialog     += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            EODs   = new UIEODController(this);
        }
Beispiel #2
0
        private bool LastRectCutNotable = false; //set if the last rect cut made a noticable change to the cuts array. If true refresh regardless of new cut effect.

        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm    = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt     = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                                                                                     GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            Touch        = new UILotControlTouchHelper(this);
            Add(Touch);
            SetupQuery();

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp

            vm.OnChatEvent  += Vm_OnChatEvent;
            vm.OnDialog     += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            this.Add(Cheats);
            AvatarDS = new UIAvatarDataServiceUpdater(this);
            EODs     = new UIEODController(this);
        }
 public UIRoofer(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
 {
     vm.SendCommand(new VMNetSetRoofCmd()
     {
         Pitch = vm.Context.Architecture.RoofPitch,
         Style = (uint)parameters[0]
     });
 }
Beispiel #4
0
        public UIGrassPaint(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            this.vm    = vm;
            World      = parent.World;
            Parent     = parent;
            WallCursor = vm.Context.CreateObjectInstance(0x2F39B7A6, LotTilePos.OUT_OF_WORLD, FSO.LotView.Model.Direction.NORTH, true);

            ((ObjectComponent)WallCursor.Objects[0].WorldUI).ForceDynamic = true;
        }
Beispiel #5
0
        public UIFloorPainter(VM vm, LotView.World world, UILotControl parent, List<int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World = parent.World;
            Parent = parent;

            Commands = new List<VMArchitectureCommand>();
        }
Beispiel #6
0
        public UIFloorPainter(VM vm, LotView.World world, UILotControl parent, List <int> parameters)
        {
            Pattern = (ushort)parameters[0];

            this.vm = vm;
            World   = parent.World;
            Parent  = parent;

            Commands = new List <VMArchitectureCommand>();
        }
Beispiel #7
0
        public void InitializeLot()
        {
            CleanupLastWorld();

            /*
             * if (FSOEnvironment.Enable3D)
             * {
             *  var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
             *  rc.SetSurroundingWorld(CityRenderer);
             *  World = rc;
             * }
             * else */
            World = new World(GameFacade.GraphicsDevice);
            World.Surroundings = CityRenderer;

            WorldLoaded   = false;
            World.Opacity = 0;
            GameFacade.Scenes.Add(World);
            Driver = new VMClientDriver(ClientStateChange);
            Driver.OnClientCommand += VMSendCommand;
            Driver.OnShutdown      += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.FSOVDoAsyncLoad = true;
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(1, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        public void CleanupLastWorld()
        {
            if (vm == null)
            {
                return;
            }

            //clear our cache too, if the setting lets us do that
            DiscordRpcEngine.SendFSOPresence(gizmo.CurrentAvatar.Value.Avatar_Name, null, 0, 0, 0, 0, gizmo.CurrentAvatar.Value.Avatar_PrivacyMode > 0);
            TimedReferenceController.Clear();
            TimedReferenceController.Clear();

            if (ZoomLevel < 4)
            {
                ZoomLevel = 5;
            }
            vm.Context.Ambience.Kill();
            foreach (var ent in vm.Entities)   //stop object sounds
            {
                var threads = ent.SoundThreads;
                for (int i = 0; i < threads.Count; i++)
                {
                    threads[i].Sound.RemoveOwner(ent.ObjectID);
                }
                threads.Clear();
            }
            vm.CloseNet(VMCloseNetReason.LeaveLot);
            Driver.OnClientCommand -= VMSendCommand;
            GameFacade.Scenes.Remove(World);
            World.Dispose();
            LotControl.Dispose();
            this.Remove(LotControl);
            ucp.SetPanel(-1);
            ucp.SetInLot(false);
            vm.SuppressBHAVChanges();
            vm         = null;
            World      = null;
            Driver     = null;
            LotControl = null;
            CityRenderer.DisposeOnLot();
        }
Beispiel #11
0
        public void CleanupLastWorld()
        {
            if (vm == null)
            {
                return;
            }

            //clear our cache too, if the setting lets us do that
            TimedReferenceController.Clear();
            TimedReferenceController.Clear();
            VM.ClearAssembled();

            vm.Context.Ambience.Kill();
            foreach (var ent in vm.Entities)
            { //stop object sounds
                var threads = ent.SoundThreads;
                for (int i = 0; i < threads.Count; i++)
                {
                    threads[i].Sound.RemoveOwner(ent.ObjectID);
                }
                threads.Clear();
            }
            vm.CloseNet(VMCloseNetReason.LeaveLot);
            //Driver.OnClientCommand -= VMSendCommand;
            GameFacade.Scenes.Remove(World);
            World.Dispose();
            LotControl.Dispose();
            this.Remove(LotControl);
            ucp.SetPanel(-1);
            ucp.SetInLot(false);
            vm.SuppressBHAVChanges();
            vm         = null;
            World      = null;
            Driver     = null;
            LotControl = null;

            SandServer?.Shutdown();
            SandCli?.Disconnect();
            SandServer = null;
            SandCli    = null;
        }
Beispiel #12
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;
        }
Beispiel #13
0
        public UIWallPlacer(VM vm, LotView.World world, ILotControl 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;
        }
Beispiel #14
0
        public void InitTestLot(string path, bool host)
        {
            if (Connecting) return;

            if (vm != null) CleanupLastWorld();

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            VMNetDriver driver;
            if (host)
            {
                driver = new VMServerDriver(37564);
            }
            else
            {
                Connecting = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }

            vm = new VM(new VMContext(World), driver);
            vm.Init();

            if (host)
            {
                vm.SendCommand(new VMBlueprintRestoreCmd
                {
                    XMLData = File.ReadAllBytes(path)
                });
            }

            uint simID = (uint)(new Random()).Next();

            vm.SendCommand(new VMNetSimJoinCmd
            {
                SimID = simID,
                HeadID = GlobalSettings.Default.DebugHead,
                BodyID = GlobalSettings.Default.DebugBody,
                SkinTone = (byte)GlobalSettings.Default.DebugSkin,
                Gender = !GlobalSettings.Default.DebugGender,
                Name = GlobalSettings.Default.LastUser
            });

            LotController = new UILotControl(vm, World);
            LotController.SelectedSimID = simID;
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 8;
            if (m_ZoomLevel > 3)
            {
                World.Visible = false;
                LotController.Visible = false;
            }

            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            } else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            vm.OnFullRefresh += VMRefreshed;
        }
Beispiel #15
0
        public UIQueryPanel(LotView.World world)
        {
            World   = world;
            Active  = false;
            Opacity = 0;
            Visible = false;

            AdStrings = new string[14];
            for (int i = 0; i < 14; i++)
            {
                string str = GameFacade.Strings.GetString("206", (i + 4).ToString());
                AdStrings[i] = ((i < 7)?str.Substring(0, str.Length - 2) + "{0}":str) + "\r\n";
            }

            var useSmall = (GlobalSettings.Default.GraphicsWidth < 1024) || FSOEnvironment.UIZoomFactor > 1f;
            var script   = this.RenderScript("querypanel" + (useSmall?"":"1024") + ".uis");

            //NOTE: the background and position of this element changes with the context it is used in.
            //other elements that are only used for certain modes will be flagged as such with comments.

            QuerybackPanel   = new UIImage(BackgroundImagePanel);
            QuerybackPanel.Y = 0;
            QuerybackPanel.BlockInput();
            this.AddAt(0, QuerybackPanel);

            QuerybackCatalog          = new UIImage(BackgroundImageCatalog);
            QuerybackCatalog.Position = new Vector2(-22, 0);
            QuerybackCatalog.BlockInput();
            this.AddAt(1, QuerybackCatalog);

            QuerybackTrade   = new UIImage(BackgroundImageTrade);
            QuerybackTrade.Y = 0;
            QuerybackTrade.BlockInput();
            this.AddAt(2, QuerybackTrade);

            //init general tab specific backgrounds

            DescriptionBackgroundImage          = new UIImage(ImageDescriptionBackground);
            DescriptionBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(119, 7);
            this.AddAt(3, DescriptionBackgroundImage);

            MotivesBackgroundImage          = new UIImage(ImageMotivesBackground);
            MotivesBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 395:619, 7);
            this.AddAt(3, MotivesBackgroundImage);

            GeneralTabImage          = new UIImage(ImageGeneralTab);
            GeneralTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0);
            this.AddAt(3, GeneralTabImage);

            SpecificTabImage          = new UIImage(ImageSpecificTab);
            SpecificTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0);
            this.AddAt(3, SpecificTabImage);

            OwnerPriceBack          = new UIImage(GeneralOwnerPriceBack);
            OwnerPriceBack.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 501 : 725, 80);
            this.AddAt(3, OwnerPriceBack);

            Thumbnail          = new UIImage();
            Thumbnail.Position = new Vector2(24, 11);
            Thumbnail.SetSize(90, 90);
            this.Add(Thumbnail);

            DescriptionText.CurrentText = "No Object Selected"; //user should not see this.
            DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1);
            DescriptionText.AttachSlider(DescriptionSlider);

            MotivesText.CurrentText = "";
            MotivesSlider.AttachButtons(MotivesScrollUpButton, MotivesScrollDownButton, 1);
            MotivesText.AttachSlider(MotivesSlider);

            GeneralTabButton.OnButtonClick  += new ButtonClickDelegate(GeneralTabButton_OnButtonClick);
            SpecificTabButton.OnButtonClick += new ButtonClickDelegate(SpecificTabButton_OnButtonClick);
            SellBackButton.OnButtonClick    += new ButtonClickDelegate(SellBackButton_OnButtonClick);

            Mode = 1;
            Tab  = 0;
        }
Beispiel #16
0
        public UIQueryPanel(LotView.World world)
        {
            World   = world;
            Active  = false;
            Opacity = 0;
            Visible = false;

            AdStrings = new string[14];
            for (int i = 0; i < 14; i++)
            {
                string str = GameFacade.Strings.GetString("206", (i + 4).ToString());
                AdStrings[i] = ((i < 7)?str.Substring(0, str.Length - 2) + "{0}":str) + "\r\n";
            }

            var useSmall = (GlobalSettings.Default.GraphicsWidth < 1024) || FSOEnvironment.UIZoomFactor > 1f;
            var script   = this.RenderScript("querypanel" + (useSmall?"":"1024") + ".uis");

            //NOTE: the background and position of this element changes with the context it is used in.
            //other elements that are only used for certain modes will be flagged as such with comments.

            QuerybackPanel   = new UIImage(BackgroundImagePanel);
            QuerybackPanel.Y = 0;
            this.AddAt(0, QuerybackPanel);

            ListenForMouse(new Rectangle(0, 0, QuerybackPanel.Texture.Width, QuerybackPanel.Texture.Height), (t, s) => { });

            Size       = QuerybackPanel.Size.ToVector2() + new Vector2(22, 42);
            BackOffset = new Point(40, 0);

            QuerybackCatalog          = new UIImage(BackgroundImageCatalog);
            QuerybackCatalog.Position = new Vector2(-22, 0);
            this.AddAt(1, QuerybackCatalog);

            QuerybackTrade   = new UIImage(BackgroundImageTrade);
            QuerybackTrade.X = -40;
            QuerybackTrade.Y = 0;
            this.AddAt(2, QuerybackTrade);

            //init general tab specific backgrounds

            DescriptionBackgroundImage          = new UIImage(ImageDescriptionBackground);
            DescriptionBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(119, 7);
            this.AddAt(3, DescriptionBackgroundImage);

            MotivesBackgroundImage          = new UIImage(ImageMotivesBackground);
            MotivesBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 395:619, 7);
            this.AddAt(3, MotivesBackgroundImage);

            GeneralTabImage          = new UIImage(ImageGeneralTab);
            GeneralTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0);
            this.AddAt(3, GeneralTabImage);

            SpecificTabImage          = new UIImage(ImageSpecificTab);
            SpecificTabImage.Position = new Microsoft.Xna.Framework.Vector2(useSmall ? 563 : 787, 0);
            this.AddAt(3, SpecificTabImage);

            OwnerPriceBack = script.Create <UIImage>("OwnerPriceBack");
            this.AddAt(3, OwnerPriceBack);

            BuyerPriceBack = script.Create <UIImage>("BuyerPriceBack");
            this.AddAt(3, BuyerPriceBack);

            OwnerPriceBack.X = ForSalePrice.X;
            BuyerPriceBack.X = ForSalePrice.X;
            ForSalePrice.Y  += 2;
            ForSalePrice.SetSize(OwnerPriceBack.Width, ForSalePrice.Height);

            Thumbnail          = new UIImage();
            Thumbnail.Position = new Vector2(24, 11);
            Thumbnail.SetSize(90, 90);
            this.Add(Thumbnail);

            DescriptionText.CurrentText = "No Object Selected"; //user should not see this.
            DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1);
            DescriptionText.AttachSlider(DescriptionSlider);

            MotivesText.CurrentText = "";
            MotivesSlider.AttachButtons(MotivesScrollUpButton, MotivesScrollDownButton, 1);
            MotivesText.AttachSlider(MotivesSlider);

            GeneralTabButton.OnButtonClick  += new ButtonClickDelegate(GeneralTabButton_OnButtonClick);
            SpecificTabButton.OnButtonClick += new ButtonClickDelegate(SpecificTabButton_OnButtonClick);
            SellBackButton.OnButtonClick    += new ButtonClickDelegate(SellBackButton_OnButtonClick);

            AsyncBuyButton.OnButtonClick        += (btn) => { OnAsyncBuyClicked?.Invoke(btn); };
            AsyncSaleButton.OnButtonClick       += (btn) => { OnAsyncSaleClicked?.Invoke(btn); };
            AsyncEditPriceButton.OnButtonClick  += (btn) => { OnAsyncPriceClicked?.Invoke(btn); };
            AsyncCancelSaleButton.OnButtonClick += (btn) => { OnAsyncSaleCancelClicked?.Invoke(btn); };

            InventoryButton.OnButtonClick += InventoryButton_OnButtonClick;

            WearProgressBar.CaptionStyle        = TextStyle.DefaultLabel.Clone();
            WearProgressBar.CaptionStyle.Shadow = true;

            var btnBg = GetTexture(0x8A700000001); //buybuild_query_generalbuy_sellasyncback = 0x8A700000001

            SpecificBtnBGs = new List <UIImage>();
            SpecificBtnBGs.Add(AddButtonBackground(SellBackButton, btnBg));
            SpecificBtnBGs.Add(AddButtonBackground(InventoryButton, btnBg));
            SpecificBtnBGs.Add(AddButtonBackground(AsyncSaleButton, btnBg));
            AsyncCancelSaleButtonBG = AddButtonBackground(AsyncCancelSaleButton, btnBg);

            var progressBG = new UIImage(ImageWearBack);

            progressBG.Position = WearProgressBar.Position - new Vector2(3, 2);
            AddAt(3, progressBG);
            SpecificBtnBGs.Add(progressBG);

            Mode = 1;
            Tab  = 0;
        }
Beispiel #17
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);
            testimg = new UIImage();
            testimg.X = 20;
            testimg.Y = 20;
            this.Add(testimg);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 177;
            QueryPanel.Y = GlobalSettings.Default.GraphicsHeight - 228;
            this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            vm.OnDialog += vm_OnDialog;
        }
Beispiel #18
0
 public VMTS1Activator(VM vm, LotView.World world, short hn)
 {
     this.VM     = vm;
     this.World  = world;
     HouseNumber = hn;
 }
Beispiel #19
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            var recording = lotName.ToLowerInvariant().EndsWith(".fsor");

            CleanupLastWorld();

            Content.Content.Get().Upgrades.LoadJSONTuning();

            if (FSOEnvironment.Enable3D)
            {
                var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
                World = rc;
            }
            else
            {
                World = new World(GameFacade.GraphicsDevice);
            }
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var settings = GlobalSettings.Default;
            var myState  = new VMNetAvatarPersistState()
            {
                Name         = settings.LastUser,
                DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                BodyOutfit   = settings.DebugBody,
                HeadOutfit   = settings.DebugHead,
                PersistID    = (uint)(new Random()).Next(),
                SkinTone     = (byte)settings.DebugSkin,
                Gender       = (short)(settings.DebugGender ? 0 : 1),
                Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                //CustomGUID = 0x396CD3D1,
                Budget = 1000000,
            };

            if (recording)
            {
                var stream = new FileStream(lotName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var rd     = new VMFSORDriver(stream);
                Driver = rd;
            }
            else if (external)
            {
                var cd = new VMClientDriver(ClientStateChange);
                SandCli             = new FSOSandboxClient();
                cd.OnClientCommand += (msg) => { SandCli.Write(new VMNetMessage(VMNetMessageType.Command, msg)); };
                cd.OnShutdown      += (reason) => SandCli.Disconnect();
                SandCli.OnMessage  += cd.ServerMessage;
                SandCli.Connect(lotName);
                Driver = cd;

                var dat = new MemoryStream();
                var str = new BinaryWriter(dat);
                myState.SerializeInto(str);
                var ava = new VMNetMessage(VMNetMessageType.AvatarData, dat.ToArray());
                dat.Close();
                SandCli.OnConnectComplete += () =>
                {
                    SandCli.Write(ava);
                };
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                globalLink.Database = new SimAntics.Engine.TSOGlobalLink.VMTSOStandaloneDatabase();
                var sd = new VMServerDriver(globalLink);
                SandServer = new FSOSandboxServer();

                Driver                   = sd;
                sd.OnDropClient         += SandServer.ForceDisconnect;
                sd.OnTickBroadcast      += SandServer.Broadcast;
                sd.OnDirectMessage      += SandServer.SendMessage;
                SandServer.OnConnect    += sd.ConnectClient;
                SandServer.OnDisconnect += sd.DisconnectClient;
                SandServer.OnMessage    += sd.HandleMessage;

                SandServer.Start((ushort)37564);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external && !recording)
            {
                if (!Downtown && ActiveFamily != null)
                {
                    ActiveFamily.SelectWholeFamily();
                    vm.TS1State.ActivateFamily(vm, ActiveFamily);
                }
                BlueprintReset(lotName);

                var experimentalTuning = new Common.Model.DynamicTuning(new List <Common.Model.DynTuningEntry> {
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 15, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 5, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 6, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 7, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 8, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "overfill", tuning_table = 255, tuning_index = 9, value = 200
                    },
                    new Common.Model.DynTuningEntry()
                    {
                        tuning_type = "feature", tuning_table = 0, tuning_index = 0, value = 1
                    },                                                                                                            //ts1/tso engine animation timings (1.2x faster)
                });
                vm.ForwardCommand(new VMNetTuningCmd {
                    Tuning = experimentalTuning
                });

                vm.TSOState.PropertyCategory = 255; //11 is community
                vm.TSOState.ActivateValidator(vm);
                vm.Context.Clock.Hours = 0;
                vm.TSOState.Size      &= unchecked ((int)0xFFFF0000);
                vm.TSOState.Size      |= (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();

                if (vm.GetGlobalValue(11) > -1)
                {
                    for (int y = 0; y < 3; y++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            vm.TSOState.Terrain.Roads[x, y] = 0xF; //crossroads everywhere
                        }
                    }
                    VMLotTerrainRestoreTools.RestoreTerrain(vm);
                }

                var myClient = new VMNetClient
                {
                    PersistID   = myState.PersistID,
                    RemoteIP    = "local",
                    AvatarState = myState
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
            vm.MyUID  = myState.PersistID;
            ZoomLevel = 1;
        }
Beispiel #20
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            var recording = lotName.ToLowerInvariant().EndsWith(".fsor");

            CleanupLastWorld();

            if (FSOEnvironment.Enable3D)
            {
                var rc = new LotView.RC.WorldRC(GameFacade.GraphicsDevice);
                World = rc;
            }
            else
            {
                World = new World(GameFacade.GraphicsDevice);
            }
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            var settings = GlobalSettings.Default;
            var myState  = new VMNetAvatarPersistState()
            {
                Name         = settings.LastUser,
                DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                BodyOutfit   = settings.DebugBody,
                HeadOutfit   = settings.DebugHead,
                PersistID    = (uint)(new Random()).Next(),
                SkinTone     = (byte)settings.DebugSkin,
                Gender       = (short)(settings.DebugGender ? 0 : 1),
                Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                Budget       = 1000000,
            };

            if (recording)
            {
                var stream = new FileStream(lotName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                var rd     = new VMFSORDriver(stream);
                Driver = rd;
            }
            else if (external)
            {
                var cd = new VMClientDriver(ClientStateChange);
                SandCli             = new FSOSandboxClient();
                cd.OnClientCommand += (msg) => { SandCli.Write(new VMNetMessage(VMNetMessageType.Command, msg)); };
                cd.OnShutdown      += (reason) => SandCli.Disconnect();
                SandCli.OnMessage  += cd.ServerMessage;
                SandCli.Connect(lotName);
                Driver = cd;

                var dat = new MemoryStream();
                var str = new BinaryWriter(dat);
                myState.SerializeInto(str);
                var ava = new VMNetMessage(VMNetMessageType.AvatarData, dat.ToArray());
                dat.Close();
                SandCli.OnConnectComplete += () =>
                {
                    SandCli.Write(ava);
                };
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                var sd         = new VMServerDriver(globalLink);
                SandServer = new FSOSandboxServer();

                Driver                   = sd;
                sd.OnDropClient         += SandServer.ForceDisconnect;
                sd.OnTickBroadcast      += SandServer.Broadcast;
                sd.OnDirectMessage      += SandServer.SendMessage;
                SandServer.OnConnect    += sd.ConnectClient;
                SandServer.OnDisconnect += sd.DisconnectClient;
                SandServer.OnMessage    += sd.HandleMessage;

                SandServer.Start((ushort)37564);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external && !recording)
            {
                if (!Downtown && ActiveFamily != null)
                {
                    ActiveFamily.SelectWholeFamily();
                    vm.ActivateFamily(ActiveFamily);
                }
                BlueprintReset(lotName);

                vm.TSOState.PropertyCategory = 255;
                vm.Context.Clock.Hours       = 0;
                vm.TSOState.Size             = (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();
                var myClient = new VMNetClient
                {
                    PersistID   = myState.PersistID,
                    RemoteIP    = "local",
                    AvatarState = myState
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
            vm.MyUID  = myState.PersistID;
            ZoomLevel = 1;
        }
Beispiel #21
0
        /// <summary>
        /// Creates a new UILotControl instance.
        /// </summary>
        /// <param name="vm">A SimAntics VM instance.</param>
        /// <param name="World">A World instance.</param>
        public UILotControl(FSO.SimAntics.VM vm, LotView.World World)
        {
            this.vm = vm;
            this.World = World;

            ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar);
            MouseEvt = this.ListenForMouse(new Microsoft.Xna.Framework.Rectangle(0, 0,
                GlobalSettings.Default.GraphicsWidth, GlobalSettings.Default.GraphicsHeight), OnMouse);

            Queue = new UIInteractionQueue(ActiveEntity, vm);
            this.Add(Queue);

            ObjectHolder = new UIObjectHolder(vm, World, this);
            QueryPanel = new UIQueryPanel(World);
            QueryPanel.OnSellBackClicked += ObjectHolder.SellBack;
            QueryPanel.X = 0;
            QueryPanel.Y = -114;
            //this.Add(QueryPanel);

            ChatPanel = new UIChatPanel(vm, this);
            this.Add(ChatPanel);

            RMBCursor = GetTexture(0x24B00000001); //exploreanchor.bmp

            vm.OnChatEvent += Vm_OnChatEvent;
            vm.OnDialog += vm_OnDialog;
            vm.OnBreakpoint += Vm_OnBreakpoint;

            Cheats = new UICheatHandler(this);
            EODs = new UIEODController(this);
        }
Beispiel #22
0
 public VMWorldActivator(VM vm, LotView.World world)
 {
     this.VM = vm;
     this.World = world;
 }
Beispiel #23
0
        public void InitializeLot(string lotName, bool external)
        {
            if (lotName == "")
            {
                return;
            }
            CleanupLastWorld();

            World         = new LotView.World(GameFacade.GraphicsDevice);
            World.Opacity = 1;
            GameFacade.Scenes.Add(World);

            if (external)
            {
                //external not yet implemented
                Driver = new VMClientDriver(ClientStateChange);
            }
            else
            {
                var globalLink = new VMTSOGlobalLinkStub();
                Driver = new VMServerDriver(globalLink);
            }

            //Driver.OnClientCommand += VMSendCommand;
            //Driver.OnShutdown += VMShutdown;

            vm = new VM(new VMContext(World), Driver, new UIHeadlineRendererProvider());
            vm.ListenBHAVChanges();
            vm.Init();

            LotControl = new UILotControl(vm, World);
            this.AddAt(0, LotControl);

            var time    = DateTime.UtcNow;
            var tsoTime = TSOTime.FromUTC(time);

            vm.Context.Clock.Hours   = tsoTime.Item1;
            vm.Context.Clock.Minutes = tsoTime.Item2;
            if (m_ZoomLevel > 3)
            {
                World.Visible      = false;
                LotControl.Visible = false;
            }

            ZoomLevel = Math.Max(ZoomLevel, 4);

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh      += VMRefreshed;
            vm.OnChatEvent        += Vm_OnChatEvent;
            vm.OnEODMessage       += LotControl.EODs.OnEODMessage;
            vm.OnRequestLotSwitch += VMLotSwitch;
            vm.OnGenericVMEvent   += Vm_OnGenericVMEvent;

            if (!external)
            {
                vm.ActivateFamily(ActiveFamily);
                BlueprintReset(lotName);

                vm.Context.Clock.Hours = 0;
                vm.TSOState.Size       = (10) | (3 << 8);
                vm.Context.UpdateTSOBuildableArea();
                vm.MyUID = 1;
                var settings = GlobalSettings.Default;
                var myClient = new VMNetClient
                {
                    PersistID   = 1,
                    RemoteIP    = "local",
                    AvatarState = new VMNetAvatarPersistState()
                    {
                        Name         = settings.LastUser,
                        DefaultSuits = new VMAvatarDefaultSuits(settings.DebugGender),
                        BodyOutfit   = settings.DebugBody,
                        HeadOutfit   = settings.DebugHead,
                        PersistID    = 1,
                        SkinTone     = (byte)settings.DebugSkin,
                        Gender       = (short)(settings.DebugGender ? 1 : 0),
                        Permissions  = SimAntics.Model.TSOPlatform.VMTSOAvatarPermissions.Admin,
                        Budget       = 100000
                    }
                };

                var server = (VMServerDriver)Driver;
                server.ConnectClient(myClient);

                GameFacade.Cursor.SetCursor(CursorType.Normal);
                ZoomLevel = 1;
            }
        }
Beispiel #24
0
        public void InitTestLot(string path, bool host)
        {
            if (Connecting) return;

            if (vm != null) CleanupLastWorld();

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            VMNetDriver driver;
            if (host)
            {
                driver = new VMServerDriver(37564, null);
            }
            else
            {
                Connecting = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }

            vm = new VM(new VMContext(World), driver, new UIHeadlineRendererProvider());
            vm.Init();
            vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are

            if (host)
            {
                //check: do we have an fsov to try loading from?

                string filename = Path.GetFileName(path);
                try
                {
                    using (var file = new BinaryReader(File.OpenRead(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/")+filename.Substring(0, filename.Length-4)+".fsov")))
                    {
                        var marshal = new SimAntics.Marshals.VMMarshal();
                        marshal.Deserialize(file);
                        vm.Load(marshal);
                        vm.Reset();
                    }
                }
                catch (Exception) {
                    short jobLevel = -1;

                    //quick hack to find the job level from the chosen blueprint
                    //the final server will know this from the fact that it wants to create a job lot in the first place...

                    try
                    {
                        if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
                            jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
                    }
                    catch (Exception) { }

                    vm.SendCommand(new VMBlueprintRestoreCmd
                    {
                        JobLevel = jobLevel,
                        XMLData = File.ReadAllBytes(path)
                    });
                }
            }

            uint simID = (uint)(new Random()).Next();
            vm.MyUID = simID;

            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID = simID,
                HeadID = GlobalSettings.Default.DebugHead,
                BodyID = GlobalSettings.Default.DebugBody,
                SkinTone = (byte)GlobalSettings.Default.DebugSkin,
                Gender = !GlobalSettings.Default.DebugGender,
                Name = GlobalSettings.Default.LastUser
            });

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 10;
            if (m_ZoomLevel > 3)
            {
                World.Visible = false;
                LotController.Visible = false;
            }

            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            } else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            if (IDEHook.IDE != null) IDEHook.IDE.StartIDE(vm);

            vm.OnFullRefresh += VMRefreshed;
            vm.OnChatEvent += Vm_OnChatEvent;
            vm.OnEODMessage += LotController.EODs.OnEODMessage;
        }
Beispiel #25
0
 public VMContext(LotView.World world) : this(world, null)
 {
 }
Beispiel #26
0
        public void InitTestLot(string path, bool host)
        {
            if (Connecting)
            {
                return;
            }

            if (vm != null)
            {
                CleanupLastWorld();
            }

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);

            VMNetDriver driver;

            if (host)
            {
                driver = new VMServerDriver(37564, null);
            }
            else
            {
                Connecting       = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption         = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }

            vm = new VM(new VMContext(World), driver, new UIHeadlineRendererProvider());
            vm.Init();
            vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are

            if (host)
            {
                //check: do we have an fsov to try loading from?

                string filename = Path.GetFileName(path);
                try
                {
                    using (var file = new BinaryReader(File.OpenRead("Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov")))
                    {
                        var marshal = new SimAntics.Marshals.VMMarshal();
                        marshal.Deserialize(file);
                        vm.Load(marshal);
                        vm.Reset();
                    }
                }
                catch (Exception) {
                    short jobLevel = -1;

                    //quick hack to find the job level from the chosen blueprint
                    //the final server will know this from the fact that it wants to create a job lot in the first place...

                    try
                    {
                        if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
                        {
                            jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
                        }
                    }
                    catch (Exception) { }

                    vm.SendCommand(new VMBlueprintRestoreCmd
                    {
                        JobLevel = jobLevel,
                        XMLData  = File.ReadAllBytes(path)
                    });
                }
            }

            uint simID = (uint)(new Random()).Next();

            vm.MyUID = simID;

            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID = simID,
                HeadID   = GlobalSettings.Default.DebugHead,
                BodyID   = GlobalSettings.Default.DebugBody,
                SkinTone = (byte)GlobalSettings.Default.DebugSkin,
                Gender   = !GlobalSettings.Default.DebugGender,
                Name     = GlobalSettings.Default.LastUser
            });

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 10;
            if (m_ZoomLevel > 3)
            {
                World.Visible         = false;
                LotController.Visible = false;
            }

            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            }
            else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            if (IDEHook.IDE != null)
            {
                IDEHook.IDE.StartIDE(vm);
            }

            vm.OnFullRefresh += VMRefreshed;
            vm.OnChatEvent   += Vm_OnChatEvent;
            vm.OnEODMessage  += LotController.EODs.OnEODMessage;
        }
Beispiel #27
0
        public VMContext(LotView.World world, VMContext oldContext)
        {
            //oldContext is passed in case we need to inherit certain things, like the ambient sound player
            this.World          = world;
            this.Clock          = new VMClock();
            this.SetToNextCache = new VMSetToNextCache(this);

            if (oldContext == null)
            {
                this.Ambience = new VMAmbientSound();
            }
            else
            {
                this.Ambience = oldContext.Ambience;
            }

            RandomSeed           = (ulong)((new Random()).NextDouble() * UInt64.MaxValue); //when resuming state, this should be set.
            Clock.TicksPerMinute = 30;                                                     //1 minute per irl second

            AddPrimitive(new VMPrimitiveRegistration(new VMSleep())
            {
                Opcode       = 0,
                Name         = "sleep",
                OperandModel = typeof(VMSleepOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMGenericTSOCall())
            {
                Opcode       = 1,
                Name         = "generic_sims_online_call",
                OperandModel = typeof(VMGenericTSOCallOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMExpression())
            {
                Opcode       = 2,
                Name         = "expression",
                OperandModel = typeof(VMExpressionOperand)
            });

            //TODO: Report Metric

            AddPrimitive(new VMPrimitiveRegistration(new VMGrab())
            {
                Opcode       = 4,
                Name         = "grab",
                OperandModel = typeof(VMGrabOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMDrop())
            {
                Opcode       = 5,
                Name         = "drop",
                OperandModel = typeof(VMDropOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMChangeSuitOrAccessory())
            {
                Opcode       = 6,
                Name         = "change_suit_or_accessory",
                OperandModel = typeof(VMChangeSuitOrAccessoryOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRefresh())
            {
                Opcode       = 7,
                Name         = "refresh",
                OperandModel = typeof(VMRefreshOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRandomNumber())
            {
                Opcode       = 8,
                Name         = "random_number",
                OperandModel = typeof(VMRandomNumberOperand)
            });

            //TODO: burn

            //Sims 1.0 tutorial

            AddPrimitive(new VMPrimitiveRegistration(new VMGetDistanceTo())
            {
                Opcode       = 11,
                Name         = "get_distance_to",
                OperandModel = typeof(VMGetDistanceToOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMGetDirectionTo())
            {
                Opcode       = 12,
                Name         = "get_direction_to",
                OperandModel = typeof(VMGetDirectionToOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMPushInteraction())
            {
                Opcode       = 13,
                Name         = "push_interaction",
                OperandModel = typeof(VMPushInteractionOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMFindBestObjectForFunction())
            {
                Opcode       = 14,
                Name         = "find_best_object_for_function",
                OperandModel = typeof(VMFindBestObjectForFunctionOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMBreakPoint())
            {
                Opcode       = 15,
                Name         = "breakpoint",
                OperandModel = typeof(VMBreakPointOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMFindLocationFor())
            {
                Opcode       = 16,
                Name         = "find_location_for",
                OperandModel = typeof(VMFindLocationForOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMIdleForInput())
            {
                Opcode       = 17,
                Name         = "idle_for_input",
                OperandModel = typeof(VMIdleForInputOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRemoveObjectInstance())
            {
                Opcode       = 18,
                Name         = "remove_object_instance",
                OperandModel = typeof(VMRemoveObjectInstanceOperand)
            });

            //Make new character

            AddPrimitive(new VMPrimitiveRegistration(new VMRunFunctionalTree())
            {
                Opcode       = 20,
                Name         = "run_functional_tree",
                OperandModel = typeof(VMRunFunctionalTreeOperand)
            });

            //Show string: may be used but no functional result.

            AddPrimitive(new VMPrimitiveRegistration(new VMLookTowards())
            {
                Opcode       = 22,
                Name         = "look_towards",
                OperandModel = typeof(VMLookTowardsOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMPlaySound())
            {
                Opcode       = 23,
                Name         = "play_sound",
                OperandModel = typeof(VMPlaySoundOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRelationship())
            {
                Opcode       = 24,
                Name         = "old_relationship",
                OperandModel = typeof(VMOldRelationshipOperand) //same primitive, different operand
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMTransferFunds())
            {
                Opcode       = 25,
                Name         = "transfer_funds",
                OperandModel = typeof(VMTransferFundsOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRelationship())
            {
                Opcode       = 26,
                Name         = "relationship",
                OperandModel = typeof(VMRelationshipOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMGotoRelativePosition())
            {
                Opcode       = 27,
                Name         = "goto_relative",
                OperandModel = typeof(VMGotoRelativePositionOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMRunTreeByName())
            {
                Opcode       = 28,
                Name         = "run_tree_by_name",
                OperandModel = typeof(VMRunTreeByNameOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMSetMotiveChange())
            {
                Opcode       = 29,
                Name         = "set_motive_deltas",
                OperandModel = typeof(VMSetMotiveChangeOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMSysLog())
            {
                Opcode       = 30,
                Name         = "syslog",
                OperandModel = typeof(VMSysLogOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMSetToNext())
            {
                Opcode       = 31,
                Name         = "set_to_next",
                OperandModel = typeof(VMSetToNextOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMTestObjectType())
            {
                Opcode       = 32,
                Name         = "test_object_type",
                OperandModel = typeof(VMTestObjectTypeOperand)
            });

            //TODO: find 5 worst motives

            //TODO: ui effect (used?)

            AddPrimitive(new VMPrimitiveRegistration(new VMSpecialEffect())
            {
                Opcode       = 35,
                Name         = "special_effect",
                OperandModel = typeof(VMSpecialEffectOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMDialogPrivateStrings())
            {
                Opcode       = 36,
                Name         = "dialog_private",
                OperandModel = typeof(VMDialogOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMTestSimInteractingWith())
            {
                Opcode       = 37,
                Name         = "test_sim_interacting_with",
                OperandModel = typeof(VMTestSimInteractingWithOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMDialogGlobalStrings())
            {
                Opcode       = 38,
                Name         = "dialog_global",
                OperandModel = typeof(VMDialogOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMDialogSemiGlobalStrings())
            {
                Opcode       = 39,
                Name         = "dialog_semiglobal",
                OperandModel = typeof(VMDialogOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMOnlineJobsCall())
            {
                Opcode       = 40,
                Name         = "online_jobs_call",
                OperandModel = typeof(VMOnlineJobsCallOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMSetBalloonHeadline())
            {
                Opcode       = 41,
                Name         = "set_balloon_headline",
                OperandModel = typeof(VMSetBalloonHeadlineOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMCreateObjectInstance())
            {
                Opcode       = 42,
                Name         = "create_object_instance",
                OperandModel = typeof(VMCreateObjectInstanceOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMDropOnto())
            {
                Opcode       = 43,
                Name         = "drop_onto",
                OperandModel = typeof(VMDropOntoOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMAnimateSim())
            {
                Opcode       = 44,
                Name         = "animate",
                OperandModel = typeof(VMAnimateSimOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMGotoRoutingSlot())
            {
                Opcode       = 45,
                Name         = "goto_routing_slot",
                OperandModel = typeof(VMGotoRoutingSlotOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMSnap()) //not functional right now
            {
                Opcode       = 46,
                Name         = "snap",
                OperandModel = typeof(VMSnapOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMReach())
            {
                Opcode       = 47,
                Name         = "reach",
                OperandModel = typeof(VMReachOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMStopAllSounds())
            {
                Opcode       = 48,
                Name         = "stop_all_sounds",
                OperandModel = typeof(VMStopAllSoundsOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMNotifyOutOfIdle())
            {
                Opcode       = 49,
                Name         = "stackobj_notify_out_of_idle",
                OperandModel = typeof(VMAnimateSimOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMChangeActionString())
            {
                Opcode       = 50,
                Name         = "change_action_string",
                OperandModel = typeof(VMChangeActionStringOperand)
            });

            //lots of unused primitives. see http://simantics.wikidot.com/wiki:primitives

            //TODO: Send Maxis Letter

            AddPrimitive(new VMPrimitiveRegistration(new VMInvokePlugin())
            {
                Opcode       = 62,
                Name         = "invoke_plugin",
                OperandModel = typeof(VMInvokePluginOperand)
            });

            AddPrimitive(new VMPrimitiveRegistration(new VMGetTerrainInfo())
            {
                Opcode       = 63,
                Name         = "get_terrain_info",
                OperandModel = typeof(VMGetTerrainInfoOperand)
            });

            //UNUSED: Leave Lot and Goto

            AddPrimitive(new VMPrimitiveRegistration(new VMFindBestAction())
            {
                Opcode       = 65,
                Name         = "find_best_action",
                OperandModel = typeof(VMFindBestActionOperand)
            });

            //TODO: Set Dynamic Object Name

            //TODO: Inventory Operations
        }
Beispiel #28
0
        public UIQueryPanel(LotView.World world)
        {
            World = world;
            Active = false;
            Opacity = 0;
            Visible = false;

            AdStrings = new string[14];
            for (int i = 0; i < 14; i++)
            {
                string str = GameFacade.Strings.GetString("206", (i + 4).ToString());
                AdStrings[i] = ((i<7)?str.Substring(0,str.Length-2)+"{0}":str) + "\r\n";
            }

            var script = this.RenderScript("querypanel"+((GlobalSettings.Default.GraphicsWidth < 1024)?"":"1024")+".uis");

            //NOTE: the background and position of this element changes with the context it is used in.
            //other elements that are only used for certain modes will be flagged as such with comments.

            QuerybackPanel = new UIImage(BackgroundImagePanel);
            QuerybackPanel.Y = 0;
            QuerybackPanel.BlockInput();
            this.AddAt(0, QuerybackPanel);

            QuerybackCatalog = new UIImage(BackgroundImageCatalog);
            QuerybackCatalog.Position = new Vector2(-22, 0);
            QuerybackCatalog.BlockInput();
            this.AddAt(1, QuerybackCatalog);

            QuerybackTrade = new UIImage(BackgroundImageTrade);
            QuerybackTrade.Y = 0;
            QuerybackTrade.BlockInput();
            this.AddAt(2, QuerybackTrade);

            //init general tab specific backgrounds

            DescriptionBackgroundImage = new UIImage(ImageDescriptionBackground);
            DescriptionBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2(119, 7);
            this.AddAt(3, DescriptionBackgroundImage);

            MotivesBackgroundImage = new UIImage(ImageMotivesBackground);
            MotivesBackgroundImage.Position = new Microsoft.Xna.Framework.Vector2((GlobalSettings.Default.GraphicsWidth < 1024)?395:619, 7);
            this.AddAt(3, MotivesBackgroundImage);

            GeneralTabImage = new UIImage(ImageGeneralTab);
            GeneralTabImage.Position = new Microsoft.Xna.Framework.Vector2((GlobalSettings.Default.GraphicsWidth < 1024) ? 563 : 787, 0);
            this.AddAt(3, GeneralTabImage);

            SpecificTabImage = new UIImage(ImageSpecificTab);
            SpecificTabImage.Position = new Microsoft.Xna.Framework.Vector2((GlobalSettings.Default.GraphicsWidth < 1024) ? 563 : 787, 0);
            this.AddAt(3, SpecificTabImage);

            OwnerPriceBack = new UIImage(GeneralOwnerPriceBack);
            OwnerPriceBack.Position = new Microsoft.Xna.Framework.Vector2((GlobalSettings.Default.GraphicsWidth < 1024) ? 501 : 725, 80);
            this.AddAt(3, OwnerPriceBack);

            Thumbnail = new UIImage();
            Thumbnail.Position = new Vector2(24, 11);
            Thumbnail.SetSize(90, 90);
            this.Add(Thumbnail);

            DescriptionText.CurrentText = "No Object Selected"; //user should not see this.
            DescriptionSlider.AttachButtons(DescriptionScrollUpButton, DescriptionScrollDownButton, 1);
            DescriptionText.AttachSlider(DescriptionSlider);

            MotivesText.CurrentText = "";
            MotivesSlider.AttachButtons(MotivesScrollUpButton, MotivesScrollDownButton, 1);
            MotivesText.AttachSlider(MotivesSlider);

            GeneralTabButton.OnButtonClick += new ButtonClickDelegate(GeneralTabButton_OnButtonClick);
            SpecificTabButton.OnButtonClick += new ButtonClickDelegate(SpecificTabButton_OnButtonClick);
            SellBackButton.OnButtonClick += new ButtonClickDelegate(SellBackButton_OnButtonClick);

            Mode = 1;
            Tab = 0;
        }
 public UIObjectHolder(VM vm, LotView.World World, UILotControl parent)
 {
     this.vm = vm;
     this.World = World;
     ParentControl = parent;
 }
Beispiel #30
0
 public VMWorldActivator(VM vm, LotView.World world)
 {
     this.VM    = vm;
     this.World = world;
 }
Beispiel #31
0
 public UIObjectHolder(VM vm, LotView.World World, UILotControl parent)
 {
     this.vm = vm;
     this.World = World;
     ParentControl = parent;
 }
        public void InitTestLot(string path, bool host)
        {
            if (Connecting)
            {
                return;
            }

            lotName = path;



            Characters = new List <XmlCharacter>();

            SaveHouseButton.Visible = true;
            CreateChar.Visible      = false;

            if (vm != null)
            {
                CleanupLastWorld();
            }

            World = new LotView.World(GameFacade.Game.GraphicsDevice);
            GameFacade.Scenes.Add(World);



            vm = new VM(new VMContext(World), new UIHeadlineRendererProvider());
            vm.Init();
            vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are


            var DirectoryInfo = new DirectoryInfo(Path.Combine(FSOEnvironment.UserDir, "Characters/"));

            for (int i = 0; i <= DirectoryInfo.GetFiles().Count() - 1; i++)
            {
                var file = DirectoryInfo.GetFiles()[i];
                CharacterInfos[i] = Path.GetFileNameWithoutExtension(file.FullName);

                if (CharacterInfos[i] != null && CharacterInfos[i] != gizmo.SelectedCharInfo.Name)
                {
                    Characters.Add(XmlCharacter.Parse(file.FullName));
                }
            }


            VMNetDriver driver;

            if (host)
            {
                driver = new VMServerDriver(37564, null);
            }
            else
            {
                Connecting       = true;
                ConnectingDialog = new UILoginProgress();

                ConnectingDialog.Caption         = GameFacade.Strings.GetString("211", "1");
                ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24");
                //this.Add(ConnectingDialog);

                UIScreen.ShowDialog(ConnectingDialog, true);

                driver = new VMClientDriver(path, 37564, ClientStateChange);
            }


            vm.VM_SetDriver(driver);



            if (host)
            {
                //check: do we have an fsov to try loading from?

                string filename = Path.GetFileName(path);
                try
                {
                    using (var file = new BinaryReader(File.OpenRead(Path.Combine(FSOEnvironment.UserDir, "Houses/") + filename.Substring(0, filename.Length - 4) + ".fsov")))
                    {
                        var marshal = new SimAntics.Marshals.VMMarshal();
                        marshal.Deserialize(file);
                        vm.Load(marshal);
                        vm.Reset();
                    }
                }
                catch (Exception)
                {
                    short jobLevel = -1;

                    //quick hack to find the job level from the chosen blueprint
                    //the final server will know this from the fact that it wants to create a job lot in the first place...

                    try
                    {
                        if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory"))
                        {
                            jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2));
                        }
                    }
                    catch (Exception) { }

                    vm.SendCommand(new VMBlueprintRestoreCmd
                    {
                        JobLevel   = jobLevel,
                        XMLData    = File.ReadAllBytes(path),
                        Characters = Characters
                    });
                }
            }

            //Check the clients loaded;
            List <VMAvatar> Clients = new List <VMAvatar>();

            foreach (VMEntity entity in vm.Entities)
            {
                if (entity is VMAvatar && entity.PersistID > 0)
                {
                    Clients.Add((VMAvatar)entity);
                }
            }


            if (Clients.Count == 0)
            {
                Permissions = true;
            }

            uint simID = (uint)(new Random()).Next();

            vm.MyUID = simID;


            var headPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(gizmo.SelectedCharInfo.Head, 16));
            var bodyPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(gizmo.SelectedCharInfo.Body, 16));
            var HeadID          = headPurchasable != null ? headPurchasable.OutfitID :
                                  Convert.ToUInt64(gizmo.SelectedCharInfo.Head, 16);
            var BodyID = bodyPurchasable != null ? bodyPurchasable.OutfitID :
                         Convert.ToUInt64(gizmo.SelectedCharInfo.Body, 16);

            AppearanceType type;

            Enum.TryParse(gizmo.SelectedCharInfo.Appearance, out type);
            bool Male = (gizmo.SelectedCharInfo.Gender == "male") ? true:false;

            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID    = simID,
                HeadID      = HeadID,
                BodyID      = BodyID,
                SkinTone    = (byte)type,
                Gender      = Male,
                Name        = gizmo.SelectedCharInfo.Name,
                Permissions = (Permissions == true) ?
                              VMTSOAvatarPermissions.Owner : VMTSOAvatarPermissions.Visitor
            });

            VMWorldActivator activator = new VMWorldActivator(vm, World);

            if (host)
            {
            }
            else
            {
                foreach (XmlCharacter Char in Characters)
                {
                    uint vsimID = (uint)(new Random()).Next();
                    Enum.TryParse(Char.Appearance, out type);

                    var vheadPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Head, 16));
                    var vbodyPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Body, 16));
                    var vHeadID          = vheadPurchasable != null ? vheadPurchasable.OutfitID :
                                           Convert.ToUInt64(Char.Head, 16);
                    var vBodyID = vbodyPurchasable != null ? vbodyPurchasable.OutfitID :
                                  Convert.ToUInt64(Char.Body, 16);

                    VMEntity vEntity = vm.Entities.FirstOrDefault(x => (x.Object.OBJ.GUID == 0x7FD96B54 && x.Name == Char.Name));

                    if (vEntity != null)
                    {
                        ((VMAvatar)vEntity).SetAvatarData(Char);
                    }
                }
            }

            LotController = new UILotControl(vm, World);
            this.AddAt(0, LotController);

            vm.Context.Clock.Hours = 10;

            if (m_ZoomLevel > 3)
            {
                World.Visible         = false;
                LotController.Visible = false;
            }


            if (host)
            {
                ZoomLevel = 1;
                ucp.SetInLot(true);
            }
            else
            {
                ZoomLevel = Math.Max(ZoomLevel, 4);
            }

            vm.OnFullRefresh += VMRefreshed;
            vm.OnChatEvent   += Vm_OnChatEvent;
            vm.OnEODMessage  += LotController.EODs.OnEODMessage;
        }