示例#1
0
    public static void LoadGame(GameSaving.GameSave loadedData)
    {
        GameSaving.ClearScene();
        MySaveLoadedHook mySaveLoadedHook = new MySaveLoadedHook(loadedData);

        mySaveLoadedHook = MyHookSystem.executeHook <MySaveLoadedHook>(mySaveLoadedHook);
        if (mySaveLoadedHook.isCanceled())
        {
            return;
        }

        Ref.planetManager.SwitchLocation(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress), loadedData.vessels[loadedData.mainVesselId].globalPosition, false, true, 0.0);
        Ref.velocityOffset                 = loadedData.velocityOffset;
        Ref.controller.globalTime          = loadedData.globalTime;
        Ref.controller.timewarpPhase       = loadedData.timeWarpPhase;
        Ref.controller.startedTimewarpTime = loadedData.startedTimewapTime;
        Ref.timeWarping = (Ref.controller.timewarpPhase != 0);
        Ref.controller.SetCameraDistance(loadedData.camDistance);
        foreach (GameSaving.VesselSave vesselToLoad in loadedData.vessels)
        {
            GameSaving.LoadVessel(vesselToLoad);
        }
        Ref.planetManager.FullyLoadTerrain(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress));
        Ref.mainVessel = Ref.controller.vessels[loadedData.mainVesselId];
        if (loadedData.selectedVesselId != -1)
        {
            Ref.map.SelectVessel(Ref.controller.vessels[loadedData.selectedVesselId], false);
        }
        Ref.map.UpdateVesselsMapIcons();
        Ref.map.following = new OrbitLines.Target(Ref.GetPlanetByName(loadedData.mapFollowingAdress));
        Ref.map.UpdateMapPosition(loadedData.mapPosition);
        Ref.map.UpdateMapZoom(-loadedData.mapPosition.z);
        Ref.map.ToggleMap();
        if (Ref.mapView != loadedData.mapView)
        {
            Ref.map.ToggleMap();
        }
        Ref.mainVessel.SetThrottle(Ref.mainVessel.throttle);
        Ref.map.DrawOrbitLines();
        Ref.controller.RepositionFuelIcons();
        Ref.controller.warpedTimeCounterUI.text = string.Empty;
        Ref.planetManager.UpdateAtmosphereFade();
        Ref.mainVesselHeight        = loadedData.vessels[loadedData.mainVesselId].globalPosition.magnitude2d - Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).radius;
        Ref.mainVesselAngleToPlanet = (float)Math.Atan2(loadedData.vessels[loadedData.mainVesselId].globalPosition.y, loadedData.vessels[loadedData.mainVesselId].globalPosition.x) * 57.29578f;
        if (Ref.mainVesselHeight < Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).cameraSwitchHeightM)
        {
            Ref.controller.camTargetAngle = Ref.mainVesselAngleToPlanet - 90f;
        }
        else
        {
            Ref.controller.camTargetAngle = 0f;
        }
        Ref.cam.transform.eulerAngles     = new Vector3(0f, 0f, Ref.controller.camTargetAngle);
        Ref.controller.camAngularVelocity = 0f;
    }
示例#2
0
 public static void LoadForLaunch(GameSaving.GameSave loadedData, Double3 launchPadPosition)
 {
     for (int i = 0; i < loadedData.vessels.Count; i++)
     {
         if (loadedData.vessels[i].adress == Ref.controller.startAdress && Math.Abs(loadedData.vessels[i].globalPosition.x - launchPadPosition.x) < 10.0 && Math.Abs(loadedData.vessels[i].globalPosition.y - launchPadPosition.y) < 40.0)
         {
             loadedData.vessels.RemoveAt(i);
             i--;
         }
         else
         {
             Vessel.State state = loadedData.vessels[i].state;
             if (state != Vessel.State.RealTime)
             {
                 if (state != Vessel.State.OnRails)
                 {
                     if (state == Vessel.State.Stationary)
                     {
                         loadedData.vessels[i].state = Vessel.State.StationaryUnloaded;
                     }
                 }
                 else
                 {
                     loadedData.vessels[i].state = Vessel.State.OnRailsUnloaded;
                 }
             }
             else if ((loadedData.vessels[i].globalPosition - launchPadPosition).magnitude2d > 1000.0 || loadedData.vessels[i].adress != Ref.controller.startAdress)
             {
                 loadedData.vessels[i].state = ((Math.Abs(loadedData.vessels[i].globalVelocity.x) <= 1.0 && Math.Abs(loadedData.vessels[i].globalVelocity.y) <= 1.0) ? Vessel.State.StationaryUnloaded : Vessel.State.OnRailsUnloaded);
             }
         }
     }
     Ref.planetManager.SwitchLocation(Ref.GetPlanetByName(Ref.controller.startAdress), launchPadPosition, false, true, 0.0);
     Ref.planetManager.UpdatePositionOffset(new Double3(0.0, 315000.0));
     Ref.velocityOffset           = Double3.zero;
     Ref.controller.globalTime    = loadedData.globalTime;
     Ref.controller.timewarpPhase = 0;
     Ref.timeWarping = false;
     foreach (GameSaving.VesselSave vesselToLoad in loadedData.vessels)
     {
         GameSaving.LoadVessel(vesselToLoad);
     }
     Ref.map.following = new OrbitLines.Target(Ref.GetPlanetByName(Ref.controller.startAdress));
     Ref.map.UpdateMapPosition(new Double3(0.0, launchPadPosition.y / 10000.0));
     Ref.map.UpdateMapZoom(launchPadPosition.y / 10000.0 / 20.0);
     Ref.planetManager.UpdateAtmosphereFade();
     Ref.controller.warpedTimeCounterUI.text = string.Empty;
 }
示例#3
0
 public static void LoadGame(GameSaving.GameSave loadedData)
 {
     GameSaving.ClearScene();
     Ref.planetManager.SwitchLocation(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress), loadedData.vessels[loadedData.mainVesselId].globalPosition, false, true);
     Ref.velocityOffset                 = loadedData.velocityOffset;
     Ref.controller.globalTime          = loadedData.globalTime;
     Ref.controller.timewarpPhase       = loadedData.timeWarpPhase;
     Ref.controller.startedTimewarpTime = loadedData.startedTimewapTime;
     Ref.timeWarping = (Ref.controller.timewarpPhase != 0);
     Ref.controller.SetCameraDistance(loadedData.camDistance);
     foreach (GameSaving.VesselSave current in loadedData.vessels)
     {
         GameSaving.LoadVessel(current);
     }
     Ref.planetManager.FullyLoadTerrain(Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress));
     Ref.mainVessel     = Ref.controller.vessels[loadedData.mainVesselId];
     Ref.selectedVessel = ((loadedData.selectedVesselId == -1) ? null : Ref.controller.vessels[loadedData.selectedVesselId]);
     Ref.map.UpdateVesselsMapIcons();
     Ref.map.following = Ref.GetPlanetByName(loadedData.mapFollowingAdress);
     Ref.map.UpdateMapPosition(loadedData.mapPosition);
     Ref.map.UpdateMapZoom(-loadedData.mapPosition.z);
     Ref.map.ToggleMap();
     if (Ref.mapView != loadedData.mapView)
     {
         Ref.map.ToggleMap();
     }
     Ref.mainVessel.SetThrottle(Ref.mainVessel.throttle);
     Ref.map.UpdateVesselOrbitLines(new List <Orbit>(), true);
     Ref.controller.RepositionFuelIcons();
     Ref.controller.warpedTimeCounterUI.text = string.Empty;
     if (Ref.map.transferWindow.target != null)
     {
         Ref.map.SelectCelestilaBodyTarget(Ref.map.transferWindow.target);
     }
     Ref.planetManager.UpdateAtmosphereFade();
     Ref.mainVesselHeight        = loadedData.vessels[loadedData.mainVesselId].globalPosition.magnitude2d - Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).radius;
     Ref.mainVesselAngleToPlanet = (float)Math.Atan2(loadedData.vessels[loadedData.mainVesselId].globalPosition.y, loadedData.vessels[loadedData.mainVesselId].globalPosition.x) * 57.29578f;
     if (Ref.mainVesselHeight < Ref.GetPlanetByName(loadedData.vessels[loadedData.mainVesselId].adress).cameraSwitchHeightM)
     {
         Ref.controller.camTargetAngle = Ref.mainVesselAngleToPlanet - 90f;
     }
     else
     {
         Ref.controller.camTargetAngle = 0f;
     }
     Ref.cam.transform.eulerAngles     = new Vector3(0f, 0f, Ref.controller.camTargetAngle);
     Ref.controller.camAngularVelocity = 0f;
 }