public void SavePlayerData(bool isInStation) { CurrentSave.PlayerLoadouts = new List <LoadoutSaveData>(); if (!isInStation) { SyncLoadoutWithShip(GameManager.Inst.PlayerProgress.ActiveLoadout, GameManager.Inst.PlayerControl.PlayerShip); } Debug.Log(GameManager.Inst.PlayerProgress.ActiveLoadout.CurrentPowerMgmtButton); LoadoutSaveData loadout = CreateLoadoutSaveData(GameManager.Inst.PlayerProgress.ActiveLoadout); CurrentSave.PlayerLoadouts.Add(loadout); CurrentSave.PlayerActiveLoadoutID = loadout.LoadoutID; CurrentSave.ProfileName = GameManager.Inst.PlayerProgress.ProfileName; CurrentSave.PlayerCredits = GameManager.Inst.PlayerProgress.Credits; }
private LoadoutSaveData CreateLoadoutSaveData(Loadout loadout) { if (loadout == null) { return(null); } LoadoutSaveData loadoutData = new LoadoutSaveData(); loadoutData.LoadoutID = loadout.LoadoutID; loadoutData.ShipID = loadout.ShipID; loadoutData.ShipType = loadout.ShipType; loadoutData.WeaponJointNames = new List <string>(); loadoutData.Weapons = new List <InvItemData>(); foreach (KeyValuePair <string, InvItemData> joint in loadout.WeaponJoints) { loadoutData.WeaponJointNames.Add(joint.Key); loadoutData.Weapons.Add(joint.Value); } loadoutData.CurrentPowerMgmtButton = new SerVector3(loadout.CurrentPowerMgmtButton); loadoutData.HullAmount = loadout.HullAmount; loadoutData.FuelAmount = loadout.FuelAmount; loadoutData.LifeSupportAmount = loadout.LifeSupportAmount; loadoutData.Defensives = loadout.Defensives; loadoutData.AmmoBayItems = loadout.AmmoBayItems; loadoutData.CargoBayItems = loadout.CargoBayItems; loadoutData.Shield = loadout.Shield; loadoutData.WeaponCapacitor = loadout.WeaponCapacitor; loadoutData.Thruster = loadout.Thruster; loadoutData.Scanner = loadout.Scanner; loadoutData.Teleporter = loadout.Teleporter; loadoutData.ShipMods = loadout.ShipMods; return(loadoutData); }
private Loadout LoadLoadoutFromSave(LoadoutSaveData data) { Loadout loadout = new Loadout(data.ShipID, data.ShipType); for (int i = 0; i < data.WeaponJointNames.Count; i++) { loadout.WeaponJoints.Add(data.WeaponJointNames[i], data.Weapons[i]); } loadout.LoadoutID = data.LoadoutID; loadout.CurrentPowerMgmtButton = data.CurrentPowerMgmtButton.ConvertToVector3(); loadout.HullAmount = data.HullAmount; loadout.FuelAmount = data.FuelAmount; loadout.LifeSupportAmount = data.LifeSupportAmount; loadout.Defensives = data.Defensives; loadout.AmmoBayItems = data.AmmoBayItems; foreach (InvItemData itemData in loadout.AmmoBayItems) { if (itemData != null) { itemData.Item.PostLoad(); } } loadout.CargoBayItems = data.CargoBayItems; foreach (InvItemData itemData in loadout.CargoBayItems) { if (itemData != null) { itemData.Item.PostLoad(); } } Debug.Log("Cargo bay items count " + loadout.CargoBayItems.Count); loadout.Shield = data.Shield; if (loadout.Shield != null) { loadout.Shield.Item.PostLoad(); } loadout.WeaponCapacitor = data.WeaponCapacitor; if (loadout.WeaponCapacitor != null) { loadout.WeaponCapacitor.Item.PostLoad(); } loadout.Thruster = data.Thruster; if (loadout.Thruster != null) { loadout.Thruster.Item.PostLoad(); } loadout.Scanner = data.Scanner; if (loadout.Scanner != null) { loadout.Scanner.Item.PostLoad(); } loadout.Teleporter = data.Teleporter; if (loadout.Teleporter != null) { loadout.Teleporter.Item.PostLoad(); } loadout.ShipMods = data.ShipMods; foreach (InvItemData itemData in loadout.ShipMods) { if (itemData != null) { itemData.Item.PostLoad(); } } return(loadout); }
public void SaveWorldData() { //save npc manager CurrentSave.LastUsedPartyNumber = GameManager.Inst.NPCManager.LastUsedPartyNumber; //save all macroAI parties CurrentSave.AllNonPlayerParties = new List <MacroAIPartySaveData>(); foreach (MacroAIParty party in GameManager.Inst.NPCManager.AllParties) { if (party.PartyNumber == 0) { continue; } MacroAIPartySaveData partyData = new MacroAIPartySaveData(); partyData.Destination = new SerVector3(party.Destination); partyData.PartyNumber = party.PartyNumber; partyData.FactionID = party.FactionID; partyData.Location = new SerVector3(party.Location.Disposition); partyData.DockedStationID = party.DockedStationID; partyData.CurrentSystemID = party.CurrentSystemID; partyData.MoveSpeed = party.MoveSpeed; partyData.IsPlayerParty = party.IsPlayerParty; partyData.IsInTradelane = party.IsInTradelane; partyData.NextTwoNodesIDs = new List <string>(); foreach (NavNode node in party.NextTwoNodes) { partyData.NextTwoNodesIDs.Add(node.ID); } partyData.PrevNodeID = (party.PrevNode == null)? "" : party.PrevNode.ID; partyData.DestNodeID = (party.DestNode == null)? "" : party.DestNode.ID; partyData.HasReachedDestNode = party.HasReachedDestNode; partyData.WaitTimer = party.WaitTimer; if (party.CurrentTask != null) { partyData.CurrentTask = new MacroAITaskSaveData(); partyData.CurrentTask.TaskType = party.CurrentTask.TaskType; partyData.CurrentTask.StayDuration = party.CurrentTask.StayDuration; if (party.CurrentTask.TravelDestCoord != null) { partyData.CurrentTask.TravelDestCoord = new SerVector3(party.CurrentTask.TravelDestCoord.Disposition); } partyData.CurrentTask.TravelDestSystemID = party.CurrentTask.TravelDestSystemID; partyData.CurrentTask.TravelDestNodeID = party.CurrentTask.TravelDestNodeID; partyData.CurrentTask.IsDestAStation = party.CurrentTask.IsDestAStation; } partyData.LastUpdateTime = party.LastUpdateTime; partyData.ShouldEnableAI = party.ShouldEnableAI; partyData.FollowerLoadouts = new List <LoadoutSaveData>(); foreach (Loadout loadout in party.FollowerLoadouts) { LoadoutSaveData loadoutData = CreateLoadoutSaveData(loadout); partyData.FollowerLoadouts.Add(loadoutData); } partyData.LeaderLoadout = CreateLoadoutSaveData(party.LeaderLoadout); partyData.TreeSetNames = new List <string>(); foreach (KeyValuePair <string, BehaviorTree> tree in party.TreeSet) { partyData.TreeSetNames.Add(tree.Key); } CurrentSave.AllNonPlayerParties.Add(partyData); } //save station data CurrentSave.DockableStationDatas = new List <DockableStationSaveData>(); foreach (KeyValuePair <string, DockableStationData> stationData in GameManager.Inst.WorldManager.DockableStationDatas) { DockableStationSaveData stationSaveData = new DockableStationSaveData(); stationSaveData.StationID = stationData.Value.StationID; stationSaveData.FactionID = stationData.Value.FactionID; stationSaveData.DemandResources = stationData.Value.DemandResources; stationSaveData.DockedPartiesNumbers = new List <int>(); foreach (MacroAIParty party in stationData.Value.DockedParties) { stationSaveData.DockedPartiesNumbers.Add(party.PartyNumber); } stationSaveData.FuelPrice = stationData.Value.FuelPrice; stationSaveData.LifeSupportPrice = stationData.Value.LifeSupportPrice; stationSaveData.ShipsForSale = stationData.Value.ShipsForSale; stationSaveData.TraderSaleItems = stationData.Value.TraderSaleItems; stationSaveData.UndesiredItemPriceMultiplier = stationData.Value.UndesiredItemPriceMultiplier; stationSaveData.DemandNormalizeSpeed = stationData.Value.DemandNormalizeSpeed; if (stationData.Value.HomeStationData != null) { stationSaveData.HomeStationSaveData = new HomeStationSaveData(); stationSaveData.HomeStationSaveData.ItemsInVault = stationData.Value.HomeStationData.ItemsInVault; stationSaveData.HomeStationSaveData.ShipsInHangar = new List <LoadoutSaveData>(); foreach (Loadout loadout in stationData.Value.HomeStationData.ShipsInHangar) { stationSaveData.HomeStationSaveData.ShipsInHangar.Add(CreateLoadoutSaveData(loadout)); } stationSaveData.HomeStationSaveData.HangarSize = stationData.Value.HomeStationData.HangarSize; stationSaveData.HomeStationSaveData.VaultSize = stationData.Value.HomeStationData.VaultSize; } CurrentSave.DockableStationDatas.Add(stationSaveData); } //time CurrentSave.CurrentTime = GameManager.Inst.WorldManager.CurrentTime; }