public void SaveData() { foreach (var player in PlayersData) { foreach (var home in player.Homes) { if (home == null || home.InteractableBed == null) { continue; } home.Position = new ConvertablePosition(home.LivePosition); } } PlayersDataStorage.Save(PlayersData); Logger.Log($"{PlayersData.Count} player homes data has been saved!"); }
public void ReloadData() { PlayersData = PlayersDataStorage.Read(); if (PlayersData == null) { PlayersData = new List <PlayerData>(); } var interactableBeds = new List <InteractableBed>(); foreach (var region in BarricadeManager.regions) { foreach (var drop in region.drops) { if (drop.interactable as InteractableBed != null) { interactableBeds.Add(drop.interactable as InteractableBed); } } } foreach (var player in PlayersData) { foreach (var home in player.Homes) { foreach (var interactableBed in interactableBeds) { if (interactableBed.transform.position.x == home.Position.X && interactableBed.transform.position.y == home.Position.Y && interactableBed.transform.position.z == home.Position.Z) { home.InteractableBed = interactableBed; interactableBeds.Remove(interactableBed); break; } } } } }