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