-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConfig.cs
More file actions
63 lines (53 loc) · 2.25 KB
/
Copy pathConfig.cs
File metadata and controls
63 lines (53 loc) · 2.25 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using BepInEx.Configuration;
using NebulaAPI;
using System.IO;
namespace SmartEjectors
{
public static class Config
{
private static ConfigFile configFile;
public static MultiplayerConfigEntry<bool> enableLockEjector;
public static MultiplayerConfigEntry<bool> enableDefaultOrbit;
public static MultiplayerConfigEntry<int> nodeToSailRatio;
public static void Init(string path)
{
configFile = new ConfigFile(path, true);
enableLockEjector = new MultiplayerConfigEntry<bool>(configFile.Bind("General", "enableLockEjector", true, "When set to true, EM Rail Ejectors automatically stop firing when the local Dyson Sphere has no available cell points."));
enableDefaultOrbit = new MultiplayerConfigEntry<bool>(configFile.Bind("General", "enableDefaultOrbit", true, "When set to true, EM Rail Ejectors will be set to target Orbit 1 when placed."));
nodeToSailRatio = new MultiplayerConfigEntry<int>(configFile.Bind("General", "nodeToSailRatio", 125, new ConfigDescription(
"Amount of sails to allow in orbit per avaliable node. Set to 0 to disable limit.",
new AcceptableValueRange<int>(0, 10000)
)));
}
public static void Export(BinaryWriter w)
{
w.Write(enableLockEjector.local);
w.Write(enableDefaultOrbit.local);
w.Write(nodeToSailRatio.local);
}
public static void Import(BinaryReader r)
{
enableLockEjector.remote = r.ReadBoolean();
enableDefaultOrbit.remote = r.ReadBoolean();
nodeToSailRatio.remote = r.ReadInt32();
}
}
public class MultiplayerConfigEntry<T>
{
public T local;
public T remote;
public MultiplayerConfigEntry(ConfigEntry<T> entry)
{
local = entry.Value;
remote = entry.Value;
}
public T ActiveValue()
{
if (!NebulaModAPI.IsMultiplayerActive) return local;
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost) return local;
if (NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient) return remote;
// Unreachable
return default(T);
}
}
}