| | 1 | | using UnityEngine; |
| | 2 | | using System; |
| | 3 | | using Variables.RealmsInfo; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Linq; |
| | 6 | |
|
| | 7 | | namespace DCL |
| | 8 | | { |
| | 9 | | public class RealmsInfoHandler |
| | 10 | | { |
| 0 | 11 | | private RealmsInfoModel model = new RealmsInfoModel(); |
| | 12 | |
|
| 1 | 13 | | public CurrentRealmVariable playerRealm => DataStore.i.realm.playerRealm; |
| 1 | 14 | | public BaseCollection<RealmModel> realmsInfo => DataStore.i.realm.realmsInfo; |
| | 15 | |
|
| | 16 | | public void Set(string json) |
| | 17 | | { |
| 2 | 18 | | JsonUtility.FromJsonOverwrite(json, model); |
| 2 | 19 | | Set(model); |
| 2 | 20 | | } |
| | 21 | |
|
| | 22 | | public void Set(RealmsInfoModel newModel) |
| | 23 | | { |
| 5 | 24 | | model = newModel; |
| 5 | 25 | | DataStore.i.realm.playerRealm.Set(model.current?.Clone()); |
| 5 | 26 | | DataStore.i.realm.realmsInfo.Set(newModel.realms != null ? newModel.realms.ToList() : new List<RealmModel>() |
| 5 | 27 | | } |
| | 28 | | } |
| | 29 | |
|
| | 30 | | [Serializable] |
| | 31 | | public class RealmsInfoModel |
| | 32 | | { |
| | 33 | | public CurrentRealmModel current; |
| | 34 | | public RealmModel[] realms; |
| | 35 | | } |
| | 36 | | } |