/// <summary> /// Warps to warp_target, at ORBIT_DISTANCE in the direction of the sun /// (i.e. warps to the sunny side of the target) /// </summary> /// <param name="warpTarget"></param> public void WarpTo(OrbitingBodyBackgroundGameObject warpTarget) { // shitty lock - DO NOT RELY ON THIS if (warping) { Debug.Log("Already warping! Not warping again"); return; } warping = true; // direction from origin Vector3 current_target_vector = warpTarget .GetCurrentGameSolarSystemCoordinates(); Vector3 normalised_target_vector = current_target_vector.normalized; double orbit_distance_in_solar_system_scale = ORBIT_DISTANCE_IN_METRES / OrbitingBodyMathematics.DISTANCE_SCALE_TO_METRES; // var name is in capitals - Solar system scale DISTANCE float sdistance = System.Convert.ToSingle( current_target_vector.magnitude - orbit_distance_in_solar_system_scale ); Vector3 SolarScaleOrbitCoordinates = normalised_target_vector * sdistance; double orbit_distance_in_nearest_planet_scale = Scale.NearestPlanet .ConvertMeasurementFromMetres(ORBIT_DISTANCE_IN_METRES); // var name is in capitals - Nearest planet scale DISTANCE float ndistance = System.Convert.ToSingle(orbit_distance_in_nearest_planet_scale); // need to go backwards i.e. towards the sun to be on the sunny side Vector3 NearestPlanetScaleOrbitCoordinates = -normalised_target_vector * ndistance; // Solar System Warps CurrentNearestOrbitingBody.ChangeToSolarSystemReferenceFrame(); CameraRegistry[(int)CameraRoles.SolarSystem] .GetComponent <LargeScaleCamera>() .WarpTo(SolarScaleOrbitCoordinates); // Orbital Warps warpTarget.ChangeToOrbitalReferenceFrame(); warpTarget.UpdateSunDirection(nearest_planet_sunlight); CameraRegistry[(int)CameraRoles.NearestPlanet] .GetComponent <LargeScaleCamera>() .WarpTo(NearestPlanetScaleOrbitCoordinates); // Playable Area Warp //transform.position = new Vector3(0, 0, 0); //Debug.Log("TODO: warp player position (maybe?) (CURRENTLY DOES NOTHING)"); CurrentNearestOrbitingBody = warpTarget; warping = false; }