FSO.SimAntics.VM.Init C# (CSharp) Method

Init() public method

Initializes this Virtual Machine.
public Init ( ) : void
return void
        public void Init()
        {
            Context.Globals = FSO.Content.Content.Get().WorldObjectGlobals.Get("global");
            PlatformState = new VMTSOLotState();
            GlobalState = new short[33];
            GlobalState[20] = 255; //Game Edition. Basically, what "expansion packs" are running. Let's just say all of them.
            GlobalState[25] = 4; //as seen in EA-Land edith's simulator globals, this needs to be set for people to do their idle interactions.
            GlobalState[17] = 4; //Runtime Code Version, is this in EA-Land.
            if (Driver is VMServerDriver) EODHost = new VMEODHost();
        }

Usage Example

Ejemplo n.º 1
0
        public void ResetVM()
        {
            VMNetDriver driver;
            driver = new VMServerDriver(Port, NetClosed);

            var vm = new VM(new VMContext(null), driver, new VMNullHeadlineProvider());
            state = vm;
            vm.Init();
            vm.OnChatEvent += Vm_OnChatEvent;

            var path = Settings.Default.GamePath + "housedata/blueprints/" + Settings.Default.DebugLot;
            string filename = Path.GetFileName(path);
            try
            {
                //try to load from FSOV first.
                LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov");
            }
            catch (Exception)
            {
                try
                {
                    Console.WriteLine("Failed FSOV load... Trying Backup");
                    LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + "_backup.fsov");
                }
                catch (Exception)
                {
                    Console.WriteLine("CRITICAL::: Failed FSOV load... Trying Blueprint (first run or something went wrong)");
                    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)
                    });

                    vm.Context.Clock.Hours = 10;
                }
            }
            vm.MyUID = uint.MaxValue-1;
            vm.SendCommand(new VMNetSimJoinCmd
            {
                ActorUID = uint.MaxValue - 1,
                Name = "server"
            });
        }
All Usage Examples Of FSO.SimAntics.VM::Init