コード例 #1
0
        public void Run(VRageGameServices services, IntPtr windowHandle, bool customRenderLoop = false, MySandboxGame game = null )
        {
            MyLog.Default = MySandboxGame.Log;

            if (game == null)
            {
                Static = new MySandboxExternal(this, services, null, windowHandle);
            }
            else
            {
                Static = game;
            }

            Initialize(Static);

            

            //Sandbox.Definitions.MyDefinitionManager.Static.LoadData(new List<Sandbox.Common.ObjectBuilders.MyObjectBuilder_Checkpoint.ModItem>());

            //Static.In
            Static.OnGameLoaded += GameLoaded;
            Static.OnGameExit += GameExit;

            //GameLoaded(this, null);

            Static.Run(customRenderLoop);

            //LoadDefinitions();

            if (!customRenderLoop)
            {
                Dispose();
            }
        }
コード例 #2
0
        public SpaceEngineersCore()
        {
            var contentPath = ToolboxUpdater.GetApplicationContentPath();
            string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath;

            MyFileSystem.Reset();
            MyFileSystem.Init(contentPath, userDataPath);

            MyLog.Default = MySandboxGame.Log;
            MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME.
            MySandboxGame.Config.Load();

            MyFileSystem.InitUserSpecific(null);
            SpaceEngineersGame.SetupPerGameSettings();

            VRageRender.MyRenderProxy.Initialize(new MyNullRender());
            // We create a whole instance of MySandboxGame!
            MySandboxGame gameTemp = new MySandboxGame(null, null);

            SpaceEngineersApi.LoadLocalization();
            _stockDefinitions = new SpaceEngineersResources();
            _stockDefinitions.LoadDefinitions();
            _manageDeleteVoxelList = new List<string>();
        }
コード例 #3
0
ファイル: MyProgram.cs プロジェクト: caomw/SpaceEngineers
        static void RunInternal(string[] args)
        {
            using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId))
            {
                IMyRender renderer = null;

                if (MySandboxGame.IsDedicated)
                {
                    renderer = new MyNullRender();
                }
                else if (!MyFakes.ENABLE_DX11_RENDERER)
                {
                    renderer = new MyDX9Render();
                }
                else if (MyFakes.ENABLE_DX11_RENDERER)
                {
                    renderer = new MyDX11Render();
                }

                VRageRender.MyRenderProxy.Initialize(renderer);

                VRageRender.MyRenderProxy.IS_OFFICIAL = MyFinalBuildConstants.IS_OFFICIAL;
                VRageRender.MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
                VRageRender.MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init");
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()");

                if (!MySandboxGame.IsDedicated)
                {
                    if (steamService.IsActive)
                    {
                        steamService.SetNotificationPosition(MySteamService.NotificationPosition.TopLeft);

                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsActive: " + steamService.IsActive);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.IsOnline: " + steamService.IsOnline);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.OwnsGame: " + steamService.OwnsGame);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserId: " + steamService.UserId);
                        MySandboxGame.Log.WriteLineAndConsole("Steam.UserName: "******"[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Steam.Branch: " + steamService.BranchName ?? "[n/a]");
                        MySandboxGame.Log.WriteLineAndConsole("Build date: " + MySandboxGame.BuildDateTime.ToString("yyyy-MM-dd hh:mm", CultureInfo.InvariantCulture));
                        MySandboxGame.Log.WriteLineAndConsole("Build version: " + MySandboxGame.BuildVersion.ToString());
                    }
                    else if (MyFinalBuildConstants.IS_OFFICIAL) //We dont need Steam only in VS 
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            MessageBoxWrapper("Steam is not running!", "Please run this game from Steam." + Environment.NewLine + "(restart Steam if already running)");
                            return;
                        }
                    }
                    else
                    {
                        if (!(steamService.IsActive && steamService.OwnsGame))
                        {
                            MessageBoxWrapper("Steam is not running!", "Game might be unstable when run without Steam!");
                        }
                    }
                }

                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("new MySandboxGame()");

                SpaceEngineersGame.SetupPerGameSettings();

                VRageGameServices services = new VRageGameServices(steamService);

                if (!MySandboxGame.IsDedicated)
                    MyFileSystem.InitUserSpecific(steamService.UserId.ToString());

                using (MySandboxGame game = new MySandboxGame(services, args))
                {
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
                    game.Run(disposeSplashScreen: DisposeSplashScreen);
                }
            }
        }
コード例 #4
0
        public MySandboxGame(VRageGameServices services, string[] commandlineArgs)
        {
            ParseArgs(commandlineArgs);
            ProfilerShort.Begin("MySandboxGame()::constructor");
            MySandboxGame.Log.WriteLine("MySandboxGame.Constructor() - START");
            MySandboxGame.Log.IncreaseIndent();

            Services = services;

            SharpDX.Configuration.EnableObjectTracking = MyCompilationSymbols.EnableSharpDxObjectTracking;

            UpdateThread = Thread.CurrentThread;

            // we want check objectbuilders, prefab's configurations, gameplay constants and building specifications
            ProfilerShort.Begin("Checks");

            MySandboxGame.Log.WriteLine("Game dir: " + MyFileSystem.ExePath);
            MySandboxGame.Log.WriteLine("Content dir: " + MyFileSystem.ContentPath);

            ProfilerShort.BeginNextBlock("MyCustomGraphicsDeviceManagerDX");

            Static = this;

            Console.CancelKeyPress += Console_CancelKeyPress;

            ProfilerShort.BeginNextBlock("InitNumberOfCores");
            InitNumberOfCores();

            ProfilerShort.BeginNextBlock("MyTexts.Init()");
            MyLanguage.Init();

            MySession.OnReady += delegate
            {
                if (OnSessionReady != null)
                    OnSessionReady();
            };

            ProfilerShort.BeginNextBlock("MyDefinitionManager.LoadScenarios");
            MyDefinitionManager.Static.LoadScenarios();

            ProfilerShort.BeginNextBlock("Preallocate");
            Preallocate();

            if (!IsDedicated)
            {
                ProfilerShort.BeginNextBlock("new MyGameRenderComponent");
                GameRenderComponent = new MyGameRenderComponent();
            }
            else
            {
                ProfilerShort.BeginNextBlock("Dedicated server setup");
                MySandboxGame.ConfigDedicated.Load();
                //ignum
                //+connect 62.109.134.123:27025

                IPAddress address = MyDedicatedServerOverrides.IpAddress ?? IPAddressExtensions.ParseOrAny(MySandboxGame.ConfigDedicated.IP);
                ushort port = (ushort)(MyDedicatedServerOverrides.Port ?? MySandboxGame.ConfigDedicated.ServerPort);

                IPEndPoint ep = new IPEndPoint(address, port);

                MyLog.Default.WriteLineAndConsole("Bind IP : " + ep.ToString());

                MyDedicatedServer dedicatedServer = new MyDedicatedServer(ep);
                MyMultiplayer.Static = dedicatedServer;

                FatalErrorDuringInit = !dedicatedServer.ServerStarted;

                if (FatalErrorDuringInit && !Environment.UserInteractive)
                {
                    var e = new Exception("Fatal error during dedicated server init: " + dedicatedServer.ServerInitError);
                    e.Data["Silent"] = true;
                    throw e;
                }
            }

            // Game tags contain game data hash, so they need to be sent after preallocation
            if (IsDedicated && !FatalErrorDuringInit)
            {
                (MyMultiplayer.Static as MyDedicatedServer).SendGameTagsToSteam();
            }

            ProfilerShort.BeginNextBlock("InitMultithreading");

            InitMultithreading();

            ProfilerShort.End();

            if (!IsDedicated && SteamSDK.SteamAPI.Instance != null)
            {
                SteamSDK.SteamAPI.Instance.OnPingServerResponded += ServerResponded;
                SteamSDK.SteamAPI.Instance.OnPingServerFailedToRespond += ServerFailedToRespond;
                SteamSDK.Peer2Peer.ConnectionFailed += Peer2Peer_ConnectionFailed;
            }

            MyMessageLoop.AddMessageHandler(MyWMCodes.GAME_IS_RUNNING_REQUEST, OnToolIsGameRunningMessage);

            MySandboxGame.Log.DecreaseIndent();
            MySandboxGame.Log.WriteLine("MySandboxGame.Constructor() - END");
            ProfilerShort.End();
        }
コード例 #5
0
 public void Dispose()
 {
     Static.Dispose();
     Static = null;
 }