using System;
using Unity.Multiplayer.Center.Common;
using UnityEditor;
using UnityEngine;
namespace Unity.Multiplayer.Center.Questionnaire
{
///
/// The unity object that contains the current choices of the user.
///
[FilePath("Assets/UserChoices.choices", FilePathAttribute.Location.ProjectFolder)]
internal class UserChoicesObject : ScriptableSingleton
{
///
/// The version of the questionnaire the answers correspond to.
///
public string QuestionnaireVersion;
///
/// The answers of the user in the Game specs questionnaire.
///
public AnswerData UserAnswers = new();
///
/// Current preset selected by the user.
///
public Preset Preset;
///
/// The main selections made by the user in the recommendation tab.
///
public SelectedSolutionsData SelectedSolutions;
///
/// Raised when the SelectedSolutions changes
///
public event Action OnSolutionSelectionChanged;
///
/// Set the user selection and calls OnSelectionChanged if needed
///
/// The selected hosting model
/// The selected netcode solution
internal void SetUserSelection(SelectedSolutionsData.HostingModel hostingModel, SelectedSolutionsData.NetcodeSolution netcodeSolution)
{
SelectedSolutions.SelectedHostingModel = hostingModel;
SelectedSolutions.SelectedNetcodeSolution = netcodeSolution;
OnSolutionSelectionChanged?.Invoke();
}
///
/// Save to disk (see filepath)
///
internal void Save()
{
QuestionnaireVersion = QuestionnaireObject.instance.Questionnaire.Version;
this.Save(true);
}
internal string FilePath => GetFilePath();
}
}