Beispiel #1
0
        internal static void LoadMultiplayer(MyObjectBuilder_World world, MyMultiplayerBase multiplayerSession)
        {
            //MyAudio.Static.Mute = true;
            Static = new MySession(multiplayerSession.SyncLayer);
            Static.Mods = world.Checkpoint.Mods;
            Static.Settings = world.Checkpoint.Settings;
            Static.CurrentPath = MyLocalCache.GetSessionSavesPath(MyUtils.StripInvalidChars(world.Checkpoint.SessionName), false, false);
            if (!MyDefinitionManager.Static.TryGetDefinition<MyScenarioDefinition>(world.Checkpoint.Scenario, out Static.Scenario))
                Static.Scenario = MyDefinitionManager.Static.GetScenarioDefinitions().FirstOrDefault();
            FixIncorrectSettings(Static.Settings);

            Static.InGameTime = MyObjectBuilder_Checkpoint.DEFAULT_DATE;

            Static.LoadMembersFromWorld(world, multiplayerSession);

            MySandboxGame.Static.SessionCompatHelper.FixSessionComponentObjectBuilders(world.Checkpoint, world.Sector);

            Static.PrepareBaseSession(world.Checkpoint, world.Sector);

            // No controlled object
            long hostObj = world.Checkpoint.ControlledObject;
            world.Checkpoint.ControlledObject = -1;

            if (multiplayerSession != null)
            {
                MyHud.Chat.RegisterChat(multiplayerSession);
                Static.Gpss.RegisterChat(multiplayerSession);
            }

            Static.CameraController = MySpectatorCameraController.Static;

            Static.LoadWorld(world.Checkpoint, world.Sector);

            if (Sync.IsServer)
            {
                Static.InitializeFactions();
            }

            Static.Settings.AutoSaveInMinutes = 0;

            Static.IsCameraAwaitingEntity = true;

            multiplayerSession.StartProcessingClientMessages();

            MyLocalCache.ClearLastSessionInfo();

            MyNetworkStats.Static.ClearStats();
            Sync.Layer.TransportLayer.ClearStats();

            Static.BeforeStartComponents();
        }