-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuickModConfigPlayer.cs
More file actions
32 lines (25 loc) · 1.06 KB
/
QuickModConfigPlayer.cs
File metadata and controls
32 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace QuickModConfig;
// Navigation state is saved per player
public class QuickModConfigPlayer : ModPlayer
{
private const string ViewKey = "view";
private const string ModNameKey = "modName";
private const string ConfigNameKey = "configName";
public override void SaveData(TagCompound tag)
{
tag[ViewKey] = (int)NavigationState.CurrentView;
if (NavigationState.CurrentModName != null)
tag[ModNameKey] = NavigationState.CurrentModName;
if (NavigationState.CurrentConfigName != null)
tag[ConfigNameKey] = NavigationState.CurrentConfigName;
}
public override void LoadData(TagCompound tag)
{
if (tag.ContainsKey(ViewKey))
NavigationState.CurrentView = (NavigationState.View)tag.GetInt(ViewKey);
NavigationState.CurrentModName = tag.ContainsKey(ModNameKey) ? tag.GetString(ModNameKey) : null;
NavigationState.CurrentConfigName = tag.ContainsKey(ConfigNameKey) ? tag.GetString(ConfigNameKey) : null;
}
}