}                                                   // Always save player

        public object GetSaveData()
        {
            if (!playerEnterExit || !StreamingWorld)
            {
                return(null);
            }

            PlayerData_v1 data = new PlayerData_v1();

            // Store player entity data
            PlayerEntity entity = playerEntityBehaviour.Entity as PlayerEntity;

            data.playerEntity                = new PlayerEntityData_v1();
            data.playerEntity.gender         = entity.Gender;
            data.playerEntity.raceTemplate   = entity.RaceTemplate;
            data.playerEntity.faceIndex      = entity.FaceIndex;
            data.playerEntity.reflexes       = entity.Reflexes;
            data.playerEntity.careerTemplate = entity.Career;
            data.playerEntity.name           = entity.Name;
            data.playerEntity.level          = entity.Level;
            data.playerEntity.stats          = entity.Stats;
            data.playerEntity.skills         = entity.Skills;
            data.playerEntity.maxHealth      = entity.MaxHealth;
            data.playerEntity.currentHealth  = entity.CurrentHealth;
            data.playerEntity.currentFatigue = entity.CurrentFatigue;
            data.playerEntity.currentMagicka = entity.CurrentMagicka;
            data.playerEntity.equipTable     = entity.ItemEquipTable.SerializeEquipTable();
            data.playerEntity.items          = entity.Items.SerializeItems();
            data.playerEntity.wagonItems     = entity.WagonItems.SerializeItems();
            data.playerEntity.otherItems     = entity.OtherItems.SerializeItems();
            data.playerEntity.goldPieces     = entity.GoldPieces;

            // Store player position data
            data.playerPosition                       = new PlayerPositionData_v1();
            data.playerPosition.position              = transform.position;
            data.playerPosition.yaw                   = playerMouseLook.Yaw;
            data.playerPosition.pitch                 = playerMouseLook.Pitch;
            data.playerPosition.isCrouching           = playerMotor.IsCrouching;
            data.playerPosition.worldPosX             = StreamingWorld.LocalPlayerGPS.WorldX;
            data.playerPosition.worldPosZ             = StreamingWorld.LocalPlayerGPS.WorldZ;
            data.playerPosition.insideDungeon         = playerEnterExit.IsPlayerInsideDungeon;
            data.playerPosition.insideBuilding        = playerEnterExit.IsPlayerInsideBuilding;
            data.playerPosition.terrainSamplerName    = DaggerfallUnity.Instance.TerrainSampler.ToString();
            data.playerPosition.terrainSamplerVersion = DaggerfallUnity.Instance.TerrainSampler.Version;

            // Store weapon state
            data.weaponDrawn = !weaponManager.Sheathed;

            // Store building exterior door data
            if ((playerEnterExit.IsPlayerInsideBuilding))
            {
                data.playerPosition.exteriorDoors = playerEnterExit.ExteriorDoors;
            }

            return(data);
        }
        public void RestorePlayerData(PlayerData_v1 playerData)
        {
            if (playerData == null)
            {
                return;
            }

            if (serializablePlayer)
            {
                serializablePlayer.RestoreSaveData(playerData);
            }
        }
        public object GetSaveData()
        {
            if (!playerEnterExit || !StreamingWorld)
                return null;

            PlayerData_v1 data = new PlayerData_v1();

            // Store player entity data
            PlayerEntity entity = playerEntityBehaviour.Entity as PlayerEntity;
            data.playerEntity = new PlayerEntityData_v1();
            data.playerEntity.gender = entity.Gender;
            data.playerEntity.raceTemplate = entity.RaceTemplate;
            data.playerEntity.faceIndex = entity.FaceIndex;
            data.playerEntity.reflexes = entity.Reflexes;
            data.playerEntity.careerTemplate = entity.Career;
            data.playerEntity.name = entity.Name;
            data.playerEntity.level = entity.Level;
            data.playerEntity.stats = entity.Stats;
            data.playerEntity.skills = entity.Skills;
            data.playerEntity.maxHealth = entity.MaxHealth;
            data.playerEntity.currentHealth = entity.CurrentHealth;
            data.playerEntity.currentFatigue = entity.CurrentFatigue;
            data.playerEntity.currentMagicka = entity.CurrentMagicka;
            data.playerEntity.equipTable = entity.ItemEquipTable.SerializeEquipTable();
            data.playerEntity.items = entity.Items.SerializeItems();
            data.playerEntity.wagonItems = entity.WagonItems.SerializeItems();
            data.playerEntity.otherItems = entity.OtherItems.SerializeItems();
            data.playerEntity.goldPieces = entity.GoldPieces;

            // Store player position data
            data.playerPosition = new PlayerPositionData_v1();
            data.playerPosition.position = transform.position;
            data.playerPosition.yaw = playerMouseLook.Yaw;
            data.playerPosition.pitch = playerMouseLook.Pitch;
            data.playerPosition.isCrouching = playerMotor.IsCrouching;
            data.playerPosition.worldPosX = StreamingWorld.LocalPlayerGPS.WorldX;
            data.playerPosition.worldPosZ = StreamingWorld.LocalPlayerGPS.WorldZ;
            data.playerPosition.insideDungeon = playerEnterExit.IsPlayerInsideDungeon;
            data.playerPosition.insideBuilding = playerEnterExit.IsPlayerInsideBuilding;
            data.playerPosition.terrainSamplerName = DaggerfallUnity.Instance.TerrainSampler.ToString();
            data.playerPosition.terrainSamplerVersion = DaggerfallUnity.Instance.TerrainSampler.Version;

            // Store weapon state
            data.weaponDrawn = !weaponManager.Sheathed;

            // Store building exterior door data
            if ((playerEnterExit.IsPlayerInsideBuilding))
            {
                data.playerPosition.exteriorDoors = playerEnterExit.ExteriorDoors;
            }

            return data;
        }
        public void RestoreSaveData(object dataIn)
        {
            if (!playerEnterExit || !StreamingWorld || !playerCamera || !playerMouseLook)
            {
                return;
            }

            // Restore player entity data
            PlayerData_v1 data   = (PlayerData_v1)dataIn;
            PlayerEntity  entity = playerEntityBehaviour.Entity as PlayerEntity;

            entity.Gender         = data.playerEntity.gender;
            entity.RaceTemplate   = data.playerEntity.raceTemplate;
            entity.FaceIndex      = data.playerEntity.faceIndex;
            entity.Reflexes       = data.playerEntity.reflexes;
            entity.Career         = data.playerEntity.careerTemplate;
            entity.Name           = data.playerEntity.name;
            entity.Level          = data.playerEntity.level;
            entity.Stats          = data.playerEntity.stats;
            entity.Skills         = data.playerEntity.skills;
            entity.MaxHealth      = data.playerEntity.maxHealth;
            entity.CurrentHealth  = data.playerEntity.currentHealth;
            entity.CurrentFatigue = data.playerEntity.currentFatigue;
            entity.CurrentMagicka = data.playerEntity.currentMagicka;
            entity.SkillUses      = data.playerEntity.skillUses;
            entity.TimeOfLastSkillIncreaseCheck = data.playerEntity.timeOfLastSkillIncreaseCheck;
            entity.StartingLevelUpSkillSum      = data.playerEntity.startingLevelUpSkillSum;
            entity.Items.DeserializeItems(data.playerEntity.items);
            entity.WagonItems.DeserializeItems(data.playerEntity.wagonItems);
            entity.OtherItems.DeserializeItems(data.playerEntity.otherItems);
            entity.ItemEquipTable.DeserializeEquipTable(data.playerEntity.equipTable, entity.Items);
            entity.GoldPieces = data.playerEntity.goldPieces;
            entity.GlobalVars.DeserializeGlobalVars(data.playerEntity.globalVars);
            entity.SetCurrentLevelUpSkillSum();

            // Fill in missing data for saves
            if (entity.StartingLevelUpSkillSum <= 0)
            {
                entity.EstimateStartingLevelUpSkillSum();
            }
            if (entity.SkillUses == null)
            {
                entity.SkillUses = new short[DaggerfallSkills.Count];
            }

            // Initialize body part armor values to 100 (no armor)
            for (int i = 0; i < entity.ArmorValues.Length; i++)
            {
                entity.ArmorValues[i] = 100;
            }

            // Apply armor values from equipped armor
            Items.DaggerfallUnityItem[] equipTable = entity.ItemEquipTable.EquipTable;
            for (int i = 0; i < equipTable.Length; i++)
            {
                if (equipTable[i] != null && (equipTable[i].ItemGroup == Items.ItemGroups.Armor))
                {
                    entity.UpdateEquippedArmorValues(equipTable[i], true);
                }
            }

            // Flag determines if player position is restored
            bool restorePlayerPosition = true;

            // Check exterior doors are included in save, we need these to exit building
            bool hasExteriorDoors;

            if (data.playerPosition.exteriorDoors == null || data.playerPosition.exteriorDoors.Length == 0)
            {
                hasExteriorDoors = false;
            }
            else
            {
                hasExteriorDoors = true;
            }

            // Lower player position flag if player outside and terrain sampler changed
            if (data.playerPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() ||
                data.playerPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version)
            {
                restorePlayerPosition = false;
            }

            // Lower player position flag if inside with no doors
            if (data.playerPosition.insideBuilding && !hasExteriorDoors)
            {
                restorePlayerPosition = false;
            }

            // Restore player position
            if (restorePlayerPosition)
            {
                transform.position      = data.playerPosition.position;
                playerMouseLook.Yaw     = data.playerPosition.yaw;
                playerMouseLook.Pitch   = data.playerPosition.pitch;
                playerMotor.IsCrouching = data.playerPosition.isCrouching;
            }

            // Restore sheath state
            weaponManager.Sheathed = !data.weaponDrawn;
        }
Esempio n. 5
0
        public void RestoreSaveData(object dataIn)
        {
            if (!playerEnterExit || !StreamingWorld || !playerCamera || !playerMouseLook)
            {
                return;
            }

            // Restore player entity data
            PlayerData_v1 data   = (PlayerData_v1)dataIn;
            PlayerEntity  entity = playerEntityBehaviour.Entity as PlayerEntity;

            entity.Gender         = data.playerEntity.gender;
            entity.RaceTemplate   = data.playerEntity.raceTemplate;
            entity.FaceIndex      = data.playerEntity.faceIndex;
            entity.Reflexes       = data.playerEntity.reflexes;
            entity.Career         = data.playerEntity.careerTemplate;
            entity.Name           = data.playerEntity.name;
            entity.Level          = data.playerEntity.level;
            entity.Stats          = data.playerEntity.stats;
            entity.Skills         = data.playerEntity.skills;
            entity.Resistances    = (data.playerEntity.resistances != null) ? data.playerEntity.resistances : new DaggerfallResistances();
            entity.MaxHealth      = data.playerEntity.maxHealth;
            entity.CurrentHealth  = data.playerEntity.currentHealth;
            entity.CurrentFatigue = data.playerEntity.currentFatigue;
            entity.CurrentMagicka = data.playerEntity.currentMagicka;
            entity.CurrentBreath  = data.playerEntity.currentBreath;
            entity.SkillUses      = data.playerEntity.skillUses;
            entity.TimeOfLastSkillIncreaseCheck = data.playerEntity.timeOfLastSkillIncreaseCheck;
            entity.TimeOfLastSkillTraining      = data.playerEntity.timeOfLastSkillTraining;
            entity.StartingLevelUpSkillSum      = data.playerEntity.startingLevelUpSkillSum;
            entity.Items.DeserializeItems(data.playerEntity.items);
            entity.WagonItems.DeserializeItems(data.playerEntity.wagonItems);
            entity.OtherItems.DeserializeItems(data.playerEntity.otherItems);
            entity.ItemEquipTable.DeserializeEquipTable(data.playerEntity.equipTable, entity.Items);
            entity.GoldPieces = data.playerEntity.goldPieces;
            entity.GlobalVars.DeserializeGlobalVars(data.playerEntity.globalVars);
            entity.MinMetalToHit                      = data.playerEntity.minMetalToHit;
            entity.BiographyResistDiseaseMod          = data.playerEntity.biographyResistDiseaseMod;
            entity.BiographyResistMagicMod            = data.playerEntity.biographyResistMagicMod;
            entity.BiographyAvoidHitMod               = data.playerEntity.biographyAvoidHitMod;
            entity.BiographyResistPoisonMod           = data.playerEntity.biographyResistPoisonMod;
            entity.BiographyFatigueMod                = data.playerEntity.biographyFatigueMod;
            entity.BiographyReactionMod               = data.playerEntity.biographyReactionMod;
            entity.TimeForThievesGuildLetter          = data.playerEntity.timeForThievesGuildLetter;
            entity.TimeForDarkBrotherhoodLetter       = data.playerEntity.timeForDarkBrotherhoodLetter;
            entity.ThievesGuildRequirementTally       = data.playerEntity.thievesGuildRequirementTally;
            entity.DarkBrotherhoodRequirementTally    = data.playerEntity.darkBrotherhoodRequirementTally;
            entity.TimeToBecomeVampireOrWerebeast     = data.playerEntity.timeToBecomeVampireOrWerebeast;
            entity.LastTimePlayerAteOrDrankAtTavern   = data.playerEntity.lastTimePlayerAteOrDrankAtTavern;
            entity.CrimeCommitted                     = data.playerEntity.crimeCommitted;
            entity.HaveShownSurrenderToGuardsDialogue = data.playerEntity.haveShownSurrenderToGuardsDialogue;
            entity.SetCurrentLevelUpSkillSum();

            entity.RentedRooms = (data.playerEntity.rentedRooms != null) ? data.playerEntity.rentedRooms.ToList() : new List <RoomRental_v1>();

            // Set time tracked in player entity
            entity.LastGameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            // Fill in missing data for saves.
            // Older saves may have regionData non-null but Values, Flags and Flags2 are uninitialized.
            // Just checking that any one of these is null is enough. Initialize to 0 (no conditions) for now to avoid null references.
            if (data.playerEntity.regionData != null && data.playerEntity.regionData[0].Values != null)
            {
                entity.RegionData = data.playerEntity.regionData;
            }
            else // If data doesn't exist, initialize it
            {
                entity.InitializeRegionData();
            }

            if (entity.StartingLevelUpSkillSum <= 0)
            {
                entity.EstimateStartingLevelUpSkillSum();
            }
            if (entity.SkillUses == null)
            {
                entity.SkillUses = new short[DaggerfallSkills.Count];
            }

            // Initialize body part armor values to 100 (no armor)
            for (int i = 0; i < entity.ArmorValues.Length; i++)
            {
                entity.ArmorValues[i] = 100;
            }

            // Apply armor values from equipped armor
            Items.DaggerfallUnityItem[] equipTable = entity.ItemEquipTable.EquipTable;
            for (int i = 0; i < equipTable.Length; i++)
            {
                if (equipTable[i] != null && (equipTable[i].ItemGroup == Items.ItemGroups.Armor))
                {
                    entity.UpdateEquippedArmorValues(equipTable[i], true);
                }
            }

            // Flag determines if player position is restored
            bool restorePlayerPosition = true;

            // Check exterior doors are included in save, we need these to exit building
            bool hasExteriorDoors;

            if (data.playerPosition.exteriorDoors == null || data.playerPosition.exteriorDoors.Length == 0)
            {
                hasExteriorDoors = false;
            }
            else
            {
                hasExteriorDoors = true;
            }

            // Lower player position flag if player outside and terrain sampler changed
            if (data.playerPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() ||
                data.playerPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version)
            {
                restorePlayerPosition = false;
            }

            // Restore building summary
            if (data.playerPosition.insideBuilding)
            {
                playerEnterExit.BuildingDiscoveryData  = data.playerPosition.buildingDiscoveryData;
                playerEnterExit.IsPlayerInsideOpenShop = data.playerPosition.insideOpenShop;
            }

            // Lower player position flag if inside with no doors
            if (data.playerPosition.insideBuilding && !hasExteriorDoors)
            {
                restorePlayerPosition = false;
            }

            // Restore player position
            if (restorePlayerPosition)
            {
                RestorePosition(data.playerPosition);
            }

            // Restore sheath state
            weaponManager.Sheathed = !data.weaponDrawn;
            // Restore transport mode
            transportManager.TransportMode = data.transportMode;
            // Restore pre boarding ship position
            transportManager.BoardShipPosition = data.boardShipPosition;

            // Restore guild memberships, also done early in SaveLoadManager for interiors
            GameManager.Instance.GuildManager.RestoreMembershipData(data.guildMemberships);

            entity.DeserializeSpellbook(data.playerEntity.spellbook);

            // Restore instanced effect bundles
            GetComponent <EntityEffectManager>().RestoreInstancedBundleSaveData(data.playerEntity.instancedEffectBundles);
        }
Esempio n. 6
0
        }                                                   // Always save player

        public object GetSaveData()
        {
            if (!playerEnterExit || !StreamingWorld)
            {
                return(null);
            }

            PlayerData_v1 data = new PlayerData_v1();

            // Store player entity data
            PlayerEntity entity = playerEntityBehaviour.Entity as PlayerEntity;

            data.playerEntity                = new PlayerEntityData_v1();
            data.playerEntity.gender         = entity.Gender;
            data.playerEntity.raceTemplate   = entity.RaceTemplate;
            data.playerEntity.faceIndex      = entity.FaceIndex;
            data.playerEntity.reflexes       = entity.Reflexes;
            data.playerEntity.careerTemplate = entity.Career;
            data.playerEntity.name           = entity.Name;
            data.playerEntity.level          = entity.Level;
            data.playerEntity.stats          = entity.Stats;
            data.playerEntity.skills         = entity.Skills;
            data.playerEntity.resistances    = entity.Resistances;
            data.playerEntity.maxHealth      = entity.MaxHealth;
            data.playerEntity.currentHealth  = entity.CurrentHealth;
            data.playerEntity.currentFatigue = entity.CurrentFatigue;
            data.playerEntity.currentMagicka = entity.CurrentMagicka;
            data.playerEntity.currentBreath  = entity.CurrentBreath;
            data.playerEntity.skillUses      = entity.SkillUses;
            data.playerEntity.timeOfLastSkillIncreaseCheck = entity.TimeOfLastSkillIncreaseCheck;
            data.playerEntity.timeOfLastSkillTraining      = entity.TimeOfLastSkillTraining;
            data.playerEntity.startingLevelUpSkillSum      = entity.StartingLevelUpSkillSum;
            data.playerEntity.equipTable                         = entity.ItemEquipTable.SerializeEquipTable();
            data.playerEntity.items                              = entity.Items.SerializeItems();
            data.playerEntity.wagonItems                         = entity.WagonItems.SerializeItems();
            data.playerEntity.otherItems                         = entity.OtherItems.SerializeItems();
            data.playerEntity.goldPieces                         = entity.GoldPieces;
            data.playerEntity.globalVars                         = entity.GlobalVars.SerializeGlobalVars();
            data.playerEntity.minMetalToHit                      = entity.MinMetalToHit;
            data.playerEntity.biographyResistDiseaseMod          = entity.BiographyResistDiseaseMod;
            data.playerEntity.biographyResistMagicMod            = entity.BiographyResistMagicMod;
            data.playerEntity.biographyAvoidHitMod               = entity.BiographyAvoidHitMod;
            data.playerEntity.biographyResistPoisonMod           = entity.BiographyResistPoisonMod;
            data.playerEntity.biographyFatigueMod                = entity.BiographyFatigueMod;
            data.playerEntity.biographyReactionMod               = entity.BiographyReactionMod;
            data.playerEntity.timeForThievesGuildLetter          = entity.TimeForThievesGuildLetter;
            data.playerEntity.timeForDarkBrotherhoodLetter       = entity.TimeForDarkBrotherhoodLetter;
            data.playerEntity.thievesGuildRequirementTally       = entity.ThievesGuildRequirementTally;
            data.playerEntity.darkBrotherhoodRequirementTally    = entity.DarkBrotherhoodRequirementTally;
            data.playerEntity.timeToBecomeVampireOrWerebeast     = entity.TimeToBecomeVampireOrWerebeast;
            data.playerEntity.lastTimePlayerAteOrDrankAtTavern   = entity.LastTimePlayerAteOrDrankAtTavern;
            data.playerEntity.spellbook                          = entity.SerializeSpellbook();
            data.playerEntity.crimeCommitted                     = entity.CrimeCommitted;
            data.playerEntity.haveShownSurrenderToGuardsDialogue = entity.HaveShownSurrenderToGuardsDialogue;

            data.playerEntity.regionData  = entity.RegionData;
            data.playerEntity.rentedRooms = entity.RentedRooms.ToArray();

            // Store player position data
            data.playerPosition = GetPlayerPositionData();

            // Store weapon state
            data.weaponDrawn = !weaponManager.Sheathed;
            // Store transport mode
            data.transportMode = transportManager.TransportMode;
            // Store pre boarding ship position
            data.boardShipPosition = transportManager.BoardShipPosition;

            // Store building exterior door data
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                data.playerPosition.exteriorDoors         = playerEnterExit.ExteriorDoors;
                data.playerPosition.buildingDiscoveryData = playerEnterExit.BuildingDiscoveryData;
            }
            // Store guild memberships
            data.guildMemberships = GameManager.Instance.GuildManager.GetMembershipData();

            // Store instanced effect bundles
            data.playerEntity.instancedEffectBundles = GetComponent <EntityEffectManager>().GetInstancedBundlesSaveData();

            return(data);
        }
Esempio n. 7
0
        }                                                   // Always save player

        public object GetSaveData()
        {
            if (!playerEnterExit || !StreamingWorld)
            {
                return(null);
            }

            PlayerData_v1 data = new PlayerData_v1();

            // Store player entity data
            PlayerEntity entity = playerEntityBehaviour.Entity as PlayerEntity;

            data.playerEntity                = new PlayerEntityData_v1();
            data.playerEntity.gender         = entity.Gender;
            data.playerEntity.raceTemplate   = entity.BirthRaceTemplate;
            data.playerEntity.faceIndex      = entity.FaceIndex;
            data.playerEntity.reflexes       = entity.Reflexes;
            data.playerEntity.careerTemplate = entity.Career;
            data.playerEntity.name           = entity.Name;
            data.playerEntity.level          = entity.Level;
            data.playerEntity.stats          = entity.Stats;
            data.playerEntity.skills         = entity.Skills;
            data.playerEntity.resistances    = entity.Resistances;
            data.playerEntity.maxHealth      = entity.RawMaxHealth;
            data.playerEntity.currentHealth  = entity.CurrentHealth;
            data.playerEntity.currentFatigue = entity.CurrentFatigue;
            data.playerEntity.currentMagicka = entity.CurrentMagicka;
            data.playerEntity.currentBreath  = entity.CurrentBreath;
            data.playerEntity.skillUses      = entity.SkillUses;
            data.playerEntity.timeOfLastSkillIncreaseCheck = entity.TimeOfLastSkillIncreaseCheck;
            data.playerEntity.skillsRecentlyRaised         = entity.SkillsRecentlyRaised;
            data.playerEntity.timeOfLastSkillTraining      = entity.TimeOfLastSkillTraining;
            data.playerEntity.startingLevelUpSkillSum      = entity.StartingLevelUpSkillSum;
            data.playerEntity.currentLevelUpSkillSum       = entity.CurrentLevelUpSkillSum;
            data.playerEntity.equipTable                         = entity.ItemEquipTable.SerializeEquipTable();
            data.playerEntity.items                              = entity.Items.SerializeItems();
            data.playerEntity.wagonItems                         = entity.WagonItems.SerializeItems();
            data.playerEntity.otherItems                         = entity.OtherItems.SerializeItems();
            data.playerEntity.goldPieces                         = entity.GoldPieces;
            data.playerEntity.globalVars                         = entity.GlobalVars.SerializeGlobalVars();
            data.playerEntity.minMetalToHit                      = entity.MinMetalToHit;
            data.playerEntity.biographyResistDiseaseMod          = entity.BiographyResistDiseaseMod;
            data.playerEntity.biographyResistMagicMod            = entity.BiographyResistMagicMod;
            data.playerEntity.biographyAvoidHitMod               = entity.BiographyAvoidHitMod;
            data.playerEntity.biographyResistPoisonMod           = entity.BiographyResistPoisonMod;
            data.playerEntity.biographyFatigueMod                = entity.BiographyFatigueMod;
            data.playerEntity.biographyReactionMod               = entity.BiographyReactionMod;
            data.playerEntity.timeForThievesGuildLetter          = entity.TimeForThievesGuildLetter;
            data.playerEntity.timeForDarkBrotherhoodLetter       = entity.TimeForDarkBrotherhoodLetter;
            data.playerEntity.thievesGuildRequirementTally       = entity.ThievesGuildRequirementTally;
            data.playerEntity.darkBrotherhoodRequirementTally    = entity.DarkBrotherhoodRequirementTally;
            data.playerEntity.timeToBecomeVampireOrWerebeast     = entity.TimeToBecomeVampireOrWerebeast;
            data.playerEntity.lastTimePlayerAteOrDrankAtTavern   = entity.LastTimePlayerAteOrDrankAtTavern;
            data.playerEntity.spellbook                          = entity.SerializeSpellbook();
            data.playerEntity.crimeCommitted                     = entity.CrimeCommitted;
            data.playerEntity.haveShownSurrenderToGuardsDialogue = entity.HaveShownSurrenderToGuardsDialogue;
            data.playerEntity.lightSourceUID                     = (entity.LightSource == null) ? 0 : entity.LightSource.UID;
            data.playerEntity.reputationCommoners                = entity.SGroupReputations[(int)FactionFile.SocialGroups.Commoners];
            data.playerEntity.reputationMerchants                = entity.SGroupReputations[(int)FactionFile.SocialGroups.Merchants];
            data.playerEntity.reputationScholars                 = entity.SGroupReputations[(int)FactionFile.SocialGroups.Scholars];
            data.playerEntity.reputationNobility                 = entity.SGroupReputations[(int)FactionFile.SocialGroups.Nobility];
            data.playerEntity.reputationUnderworld               = entity.SGroupReputations[(int)FactionFile.SocialGroups.Underworld];
            data.playerEntity.reputationSGroup5                  = entity.SGroupReputations[(int)FactionFile.SocialGroups.SGroup5];
            data.playerEntity.reputationSupernaturalBeings       = entity.SGroupReputations[(int)FactionFile.SocialGroups.SupernaturalBeings];
            data.playerEntity.reputationGuildMembers             = entity.SGroupReputations[(int)FactionFile.SocialGroups.GuildMembers];
            data.playerEntity.reputationSGroup8                  = entity.SGroupReputations[(int)FactionFile.SocialGroups.SGroup8];
            data.playerEntity.reputationSGroup9                  = entity.SGroupReputations[(int)FactionFile.SocialGroups.SGroup9];
            data.playerEntity.reputationSGroup10                 = entity.SGroupReputations[(int)FactionFile.SocialGroups.SGroup10];
            data.playerEntity.previousVampireClan                = entity.PreviousVampireClan;
            data.playerEntity.daedraSummonDay                    = entity.DaedraSummonDay;
            data.playerEntity.daedraSummonIndex                  = entity.DaedraSummonIndex;

            data.playerEntity.regionData  = entity.RegionData;
            data.playerEntity.rentedRooms = entity.RentedRooms.ToArray();

            // Store player position data
            data.playerPosition = GetPlayerPositionData();

            // Store weapon state
            data.weaponDrawn   = !weaponManager.Sheathed;
            data.usingLeftHand = !weaponManager.UsingRightHand;
            // Store transport mode
            data.transportMode = transportManager.TransportMode;
            // Store pre boarding ship position
            data.boardShipPosition = transportManager.BoardShipPosition;

            // Store building exterior door data
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                data.playerPosition.exteriorDoors         = playerEnterExit.ExteriorDoors;
                data.playerPosition.buildingDiscoveryData = playerEnterExit.BuildingDiscoveryData;
            }
            // Store guild memberships
            data.guildMemberships   = GameManager.Instance.GuildManager.GetMembershipData();
            data.vampireMemberships = GameManager.Instance.GuildManager.GetMembershipData(true);
            // Store one time quest acceptances
            data.oneTimeQuestsAccepted = GameManager.Instance.QuestListsManager.oneTimeQuestsAccepted;

            // Store instanced effect bundles
            data.playerEntity.instancedEffectBundles = GetComponent <EntityEffectManager>().GetInstancedBundlesSaveData();

            return(data);
        }
        public void RestoreSaveData(object dataIn)
        {
            if (!playerEnterExit || !StreamingWorld || !playerCamera || !playerMouseLook)
            {
                return;
            }

            // Restore player entity data
            PlayerData_v1 data   = (PlayerData_v1)dataIn;
            PlayerEntity  entity = playerEntityBehaviour.Entity as PlayerEntity;

            entity.Gender         = data.playerEntity.gender;
            entity.RaceTemplate   = data.playerEntity.raceTemplate;
            entity.FaceIndex      = data.playerEntity.faceIndex;
            entity.Reflexes       = data.playerEntity.reflexes;
            entity.Career         = data.playerEntity.careerTemplate;
            entity.Name           = data.playerEntity.name;
            entity.Level          = data.playerEntity.level;
            entity.Stats          = data.playerEntity.stats;
            entity.Skills         = data.playerEntity.skills;
            entity.MaxHealth      = data.playerEntity.maxHealth;
            entity.CurrentHealth  = data.playerEntity.currentHealth;
            entity.CurrentFatigue = data.playerEntity.currentFatigue;
            entity.CurrentMagicka = data.playerEntity.currentMagicka;
            entity.Items.DeserializeItems(data.playerEntity.items);
            entity.WagonItems.DeserializeItems(data.playerEntity.wagonItems);
            entity.OtherItems.DeserializeItems(data.playerEntity.otherItems);
            entity.ItemEquipTable.DeserializeEquipTable(data.playerEntity.equipTable, entity.Items);
            entity.GoldPieces = data.playerEntity.goldPieces;

            // Flag determines if player position is restored
            bool restorePlayerPosition = true;

            // Check exterior doors are included in save, we need these to exit building
            bool hasExteriorDoors;

            if (data.playerPosition.exteriorDoors == null || data.playerPosition.exteriorDoors.Length == 0)
            {
                hasExteriorDoors = false;
            }
            else
            {
                hasExteriorDoors = true;
            }

            // Lower player position flag if player outside and terrain sampler changed
            if (data.playerPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() ||
                data.playerPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version)
            {
                restorePlayerPosition = false;
            }

            // Lower player position flag if inside with no doors
            if (data.playerPosition.insideBuilding && !hasExteriorDoors)
            {
                restorePlayerPosition = false;
            }

            // Restore player position
            if (restorePlayerPosition)
            {
                transform.position      = data.playerPosition.position;
                playerMouseLook.Yaw     = data.playerPosition.yaw;
                playerMouseLook.Pitch   = data.playerPosition.pitch;
                playerMotor.IsCrouching = data.playerPosition.isCrouching;
            }

            // Restore sheath state
            weaponManager.Sheathed = !data.weaponDrawn;
        }
Esempio n. 9
0
        public void RestoreSaveData(object dataIn)
        {
            if (!playerEnterExit || !StreamingWorld || !playerCamera || !playerMouseLook)
            {
                return;
            }

            // Restore player entity data
            PlayerData_v1 data   = (PlayerData_v1)dataIn;
            PlayerEntity  entity = playerEntityBehaviour.Entity as PlayerEntity;

            entity.Gender         = data.playerEntity.gender;
            entity.RaceTemplate   = data.playerEntity.raceTemplate;
            entity.FaceIndex      = data.playerEntity.faceIndex;
            entity.Reflexes       = data.playerEntity.reflexes;
            entity.Career         = data.playerEntity.careerTemplate;
            entity.Name           = data.playerEntity.name;
            entity.Level          = data.playerEntity.level;
            entity.Stats          = data.playerEntity.stats;
            entity.Skills         = data.playerEntity.skills;
            entity.MaxHealth      = data.playerEntity.maxHealth;
            entity.CurrentHealth  = data.playerEntity.currentHealth;
            entity.CurrentFatigue = data.playerEntity.currentFatigue;
            entity.CurrentMagicka = data.playerEntity.currentMagicka;
            entity.SkillUses      = data.playerEntity.skillUses;
            entity.TimeOfLastSkillIncreaseCheck = data.playerEntity.timeOfLastSkillIncreaseCheck;
            entity.TimeOfLastSkillTraining      = data.playerEntity.timeOfLastSkillTraining;
            entity.StartingLevelUpSkillSum      = data.playerEntity.startingLevelUpSkillSum;
            entity.Items.DeserializeItems(data.playerEntity.items);
            entity.WagonItems.DeserializeItems(data.playerEntity.wagonItems);
            entity.OtherItems.DeserializeItems(data.playerEntity.otherItems);
            entity.ItemEquipTable.DeserializeEquipTable(data.playerEntity.equipTable, entity.Items);
            entity.GoldPieces = data.playerEntity.goldPieces;
            entity.GlobalVars.DeserializeGlobalVars(data.playerEntity.globalVars);
            entity.MinMetalToHit                   = data.playerEntity.minMetalToHit;
            entity.BiographyResistDiseaseMod       = data.playerEntity.biographyResistDiseaseMod;
            entity.BiographyResistMagicMod         = data.playerEntity.biographyResistMagicMod;
            entity.BiographyAvoidHitMod            = data.playerEntity.biographyAvoidHitMod;
            entity.BiographyResistPoisonMod        = data.playerEntity.biographyResistPoisonMod;
            entity.BiographyFatigueMod             = data.playerEntity.biographyFatigueMod;
            entity.BiographyReactionMod            = data.playerEntity.biographyReactionMod;
            entity.TimeForThievesGuildLetter       = data.playerEntity.timeForThievesGuildLetter;
            entity.TimeForDarkBrotherhoodLetter    = data.playerEntity.timeForDarkBrotherhoodLetter;
            entity.ThievesGuildRequirementTally    = data.playerEntity.thievesGuildRequirementTally;
            entity.DarkBrotherhoodRequirementTally = data.playerEntity.darkBrotherhoodRequirementTally;
            entity.SetCurrentLevelUpSkillSum();

            if (data.playerEntity.regionData != null)
            {
                entity.RegionData = data.playerEntity.regionData;
            }
            else // If data doesn't exist, initialize to random values
            {
                entity.InitializeRegionPrices();
            }

            // Set time tracked in player entity
            entity.LastGameMinutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();

            // Fill in missing data for saves
            if (entity.StartingLevelUpSkillSum <= 0)
            {
                entity.EstimateStartingLevelUpSkillSum();
            }
            if (entity.SkillUses == null)
            {
                entity.SkillUses = new short[DaggerfallSkills.Count];
            }

            // Initialize body part armor values to 100 (no armor)
            for (int i = 0; i < entity.ArmorValues.Length; i++)
            {
                entity.ArmorValues[i] = 100;
            }

            // Apply armor values from equipped armor
            Items.DaggerfallUnityItem[] equipTable = entity.ItemEquipTable.EquipTable;
            for (int i = 0; i < equipTable.Length; i++)
            {
                if (equipTable[i] != null && (equipTable[i].ItemGroup == Items.ItemGroups.Armor))
                {
                    entity.UpdateEquippedArmorValues(equipTable[i], true);
                }
            }

            // Flag determines if player position is restored
            bool restorePlayerPosition = true;

            // Check exterior doors are included in save, we need these to exit building
            bool hasExteriorDoors;

            if (data.playerPosition.exteriorDoors == null || data.playerPosition.exteriorDoors.Length == 0)
            {
                hasExteriorDoors = false;
            }
            else
            {
                hasExteriorDoors = true;
            }

            // Lower player position flag if player outside and terrain sampler changed
            if (data.playerPosition.terrainSamplerName != DaggerfallUnity.Instance.TerrainSampler.ToString() ||
                data.playerPosition.terrainSamplerVersion != DaggerfallUnity.Instance.TerrainSampler.Version)
            {
                restorePlayerPosition = false;
            }

            // Restore building summary
            if (data.playerPosition.insideBuilding)
            {
                playerEnterExit.BuildingDiscoveryData = data.playerPosition.buildingDiscoveryData;
            }

            // Lower player position flag if inside with no doors
            if (data.playerPosition.insideBuilding && !hasExteriorDoors)
            {
                restorePlayerPosition = false;
            }

            // Restore player position
            if (restorePlayerPosition)
            {
                RestorePosition(data.playerPosition);
            }

            // Restore sheath state
            weaponManager.Sheathed = !data.weaponDrawn;
            // Restore transport mode
            transportManager.TransportMode = data.transportMode;
            // Restore pre boarding ship position
            transportManager.BoardShipPosition = data.boardShipPosition;
        }
Esempio n. 10
0
        }                                                   // Always save player

        public object GetSaveData()
        {
            if (!playerEnterExit || !StreamingWorld)
            {
                return(null);
            }

            PlayerData_v1 data = new PlayerData_v1();

            // Store player entity data
            PlayerEntity entity = playerEntityBehaviour.Entity as PlayerEntity;

            data.playerEntity                = new PlayerEntityData_v1();
            data.playerEntity.gender         = entity.Gender;
            data.playerEntity.raceTemplate   = entity.RaceTemplate;
            data.playerEntity.faceIndex      = entity.FaceIndex;
            data.playerEntity.reflexes       = entity.Reflexes;
            data.playerEntity.careerTemplate = entity.Career;
            data.playerEntity.name           = entity.Name;
            data.playerEntity.level          = entity.Level;
            data.playerEntity.stats          = entity.Stats;
            data.playerEntity.skills         = entity.Skills;
            data.playerEntity.maxHealth      = entity.MaxHealth;
            data.playerEntity.currentHealth  = entity.CurrentHealth;
            data.playerEntity.currentFatigue = entity.CurrentFatigue;
            data.playerEntity.currentMagicka = entity.CurrentMagicka;
            data.playerEntity.skillUses      = entity.SkillUses;
            data.playerEntity.timeOfLastSkillIncreaseCheck = entity.TimeOfLastSkillIncreaseCheck;
            data.playerEntity.timeOfLastSkillTraining      = entity.TimeOfLastSkillTraining;
            data.playerEntity.startingLevelUpSkillSum      = entity.StartingLevelUpSkillSum;
            data.playerEntity.equipTable                      = entity.ItemEquipTable.SerializeEquipTable();
            data.playerEntity.items                           = entity.Items.SerializeItems();
            data.playerEntity.wagonItems                      = entity.WagonItems.SerializeItems();
            data.playerEntity.otherItems                      = entity.OtherItems.SerializeItems();
            data.playerEntity.goldPieces                      = entity.GoldPieces;
            data.playerEntity.globalVars                      = entity.GlobalVars.SerializeGlobalVars();
            data.playerEntity.minMetalToHit                   = entity.MinMetalToHit;
            data.playerEntity.biographyResistDiseaseMod       = entity.BiographyResistDiseaseMod;
            data.playerEntity.biographyResistMagicMod         = entity.BiographyResistMagicMod;
            data.playerEntity.biographyAvoidHitMod            = entity.BiographyAvoidHitMod;
            data.playerEntity.biographyResistPoisonMod        = entity.BiographyResistPoisonMod;
            data.playerEntity.biographyFatigueMod             = entity.BiographyFatigueMod;
            data.playerEntity.biographyReactionMod            = entity.BiographyReactionMod;
            data.playerEntity.timeForThievesGuildLetter       = entity.TimeForThievesGuildLetter;
            data.playerEntity.timeForDarkBrotherhoodLetter    = entity.TimeForDarkBrotherhoodLetter;
            data.playerEntity.thievesGuildRequirementTally    = entity.ThievesGuildRequirementTally;
            data.playerEntity.darkBrotherhoodRequirementTally = entity.DarkBrotherhoodRequirementTally;
            data.playerEntity.regionData                      = entity.RegionData;

            // Store player position data
            data.playerPosition = GetPlayerPositionData();

            // Store weapon state
            data.weaponDrawn = !weaponManager.Sheathed;
            // Store transport mode
            data.transportMode = transportManager.TransportMode;
            // Store pre boarding ship position
            data.boardShipPosition = transportManager.BoardShipPosition;

            // Store building exterior door data
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                data.playerPosition.exteriorDoors         = playerEnterExit.ExteriorDoors;
                data.playerPosition.buildingDiscoveryData = playerEnterExit.BuildingDiscoveryData;
            }

            return(data);
        }
Esempio n. 11
0
        void RestorePlayerData(PlayerData_v1 playerData)
        {
            if (playerData == null)
                return;

            if (serializablePlayer)
                serializablePlayer.RestoreSaveData(playerData);
        }