Exemple #1
0
 public void RestorePosition(PlayerPositionData_v1 positionData)
 {
     transform.position      = positionData.position;
     playerMouseLook.Yaw     = positionData.yaw;
     playerMouseLook.Pitch   = positionData.pitch;
     playerMotor.IsCrouching = positionData.isCrouching;
 }
Exemple #2
0
        public PlayerPositionData_v1 GetPlayerPositionData()
        {
            PlayerPositionData_v1 playerPosition = new PlayerPositionData_v1();

            //PlayerHeightChanger heightChanger = GetComponent<PlayerHeightChanger>();
            playerPosition.position              = transform.position;
            playerPosition.worldCompensation     = GameManager.Instance.StreamingWorld.WorldCompensation;
            playerPosition.worldContext          = playerEnterExit.WorldContext;
            playerPosition.floatingOriginVersion = FloatingOrigin.floatingOriginVersion;
            playerPosition.yaw                   = playerMouseLook.Yaw;
            playerPosition.pitch                 = playerMouseLook.Pitch;
            playerPosition.isCrouching           = playerMotor.IsCrouching;
            playerPosition.worldPosX             = StreamingWorld.LocalPlayerGPS.WorldX;
            playerPosition.worldPosZ             = StreamingWorld.LocalPlayerGPS.WorldZ;
            playerPosition.insideDungeon         = playerEnterExit.IsPlayerInsideDungeon;
            playerPosition.insideBuilding        = playerEnterExit.IsPlayerInsideBuilding;
            playerPosition.insideOpenShop        = playerEnterExit.IsPlayerInsideOpenShop;
            playerPosition.insideTavern          = playerEnterExit.IsPlayerInsideTavern;
            playerPosition.insideResidence       = playerEnterExit.IsPlayerInsideResidence;
            playerPosition.terrainSamplerName    = DaggerfallUnity.Instance.TerrainSampler.ToString();
            playerPosition.terrainSamplerVersion = DaggerfallUnity.Instance.TerrainSampler.Version;
            playerPosition.smallerDungeonsState  = (DaggerfallUnity.Settings.SmallerDungeons) ? QuestSmallerDungeonsState.Enabled : QuestSmallerDungeonsState.Disabled;
            playerPosition.weather               = GameManager.Instance.WeatherManager.PlayerWeather.WeatherType;
            return(playerPosition);
        }
Exemple #3
0
        public void RestorePosition(PlayerPositionData_v1 positionData)
        {
            // Floating origin v2 saves are only missing world context
            WorldContext playerContext = playerEnterExit.WorldContext;

            if (positionData.floatingOriginVersion == 2)
            {
                positionData.worldContext = playerContext;
            }

            // Restore position
            if (playerContext == WorldContext.Exterior)
            {
                RestoreExteriorPositionHandler(gameObject, positionData, playerContext);
            }
            else
            {
                transform.position = positionData.position;
            }

            // Restore orientation and crouch state
            playerMouseLook.Yaw     = positionData.yaw;
            playerMouseLook.Pitch   = positionData.pitch;
            playerMotor.IsCrouching = positionData.isCrouching;
        }
Exemple #4
0
        void RestoreExteriorPositionHandler(GameObject player, PlayerPositionData_v1 data, WorldContext playerContext)
        {
            // If player context matches serialized world context then player was saved after floating y change
            // Need to get relative difference between current and serialized world compensation to get actual y position
            if (playerContext == data.worldContext)
            {
                float diffY = GameManager.Instance.StreamingWorld.WorldCompensation.y - data.worldCompensation.y;
                player.transform.position = data.position + new Vector3(0, diffY, 0);
                return;
            }

            // Otherwise we migrate a legacy exterior position by adjusting for world compensation
            player.transform.position = data.position + GameManager.Instance.StreamingWorld.WorldCompensation;
        }
Exemple #5
0
        public PlayerPositionData_v1 GetPlayerPositionData()
        {
            PlayerPositionData_v1 playerPosition = new PlayerPositionData_v1();

            playerPosition.position              = transform.position;
            playerPosition.yaw                   = playerMouseLook.Yaw;
            playerPosition.pitch                 = playerMouseLook.Pitch;
            playerPosition.isCrouching           = playerMotor.IsCrouching;
            playerPosition.worldPosX             = StreamingWorld.LocalPlayerGPS.WorldX;
            playerPosition.worldPosZ             = StreamingWorld.LocalPlayerGPS.WorldZ;
            playerPosition.insideDungeon         = playerEnterExit.IsPlayerInsideDungeon;
            playerPosition.insideBuilding        = playerEnterExit.IsPlayerInsideBuilding;
            playerPosition.terrainSamplerName    = DaggerfallUnity.Instance.TerrainSampler.ToString();
            playerPosition.terrainSamplerVersion = DaggerfallUnity.Instance.TerrainSampler.Version;
            playerPosition.weather               = GameManager.Instance.WeatherManager.PlayerWeather.WeatherType;
            return(playerPosition);
        }