forked from Hazardu/ChampionsOfForest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModSettings.cs
161 lines (150 loc) · 4.9 KB
/
ModSettings.cs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
using System.Collections.Generic;
using System.IO;
using TheForest.Utils;
namespace ChampionsOfForest
{
public class ModSettings
{
public enum Difficulty
{
Easy, Veteran, Elite, Master, Challenge1, Challenge2, Challenge3, Challenge4, Challenge5, Challenge6, Hell
}
public enum DropsOnDeathMode
{
All, Equipped, Disabled, NonEquipped
}
public enum LootLevelPolicy
{
HighestPlayerLevel, AverageLevel, LowestLevel, ClosestPlayer, HostLevel
}
public static Difficulty difficulty = Difficulty.Easy;
public static DropsOnDeathMode dropsOnDeath = DropsOnDeathMode.Disabled;
public static bool DifficultyChosen = false;
public static bool FriendlyFire = true;
public static bool IsDedicated = false;
public static bool killOnDowned = false;
public static bool AllowRandomCaveSpawn = true;
public static bool AllowCaveRespawn = true;
public static int CaveMaxAdditionalEnemies = 1;
public static float CaveRespawnDelay = 1;
public static string Version;
public const bool RequiresNewFiles = false;
public const bool ALLNewFiles = false;
public const bool RequiresNewSave = true;
public const string RequiresNewSaveVersion = "1.6.0.2";
public static readonly List<int> outdatedFiles = new List<int>();
public static float DropQuantityMultiplier = 1;
public static float DropChanceMultiplier = 1;
public static float ExpMultiplier = 1;
public static int EnemyLevelIncrease = 0;
public static float EnemyDamageMultiplier = 1;
public static float EnemyHealthMultiplier = 1;
public static float EnemyArmorMultiplier = 1;
public static float EnemySpeedMultiplier = 1;
public static bool AllowElites = true;
public static LootLevelPolicy lootLevelPolicy = LootLevelPolicy.HighestPlayerLevel;
public static int LootFilterMinRarity = 0;
public static void Reset()
{
DropQuantityMultiplier = 1;
DropChanceMultiplier = 1;
ExpMultiplier = 1;
EnemyLevelIncrease = 0;
EnemyDamageMultiplier = 1;
EnemyHealthMultiplier = 1;
EnemyArmorMultiplier = 1;
EnemySpeedMultiplier = 1;
AllowElites = true;
lootLevelPolicy = LootLevelPolicy.HighestPlayerLevel;
AllowRandomCaveSpawn = true;
AllowCaveRespawn = true;
CaveMaxAdditionalEnemies = 1;
CaveRespawnDelay = 1;
LootFilterMinRarity = 0;
}
public static void BroadCastSettingsToClients()
{
if (GameSetup.IsMpServer)
{
using (MemoryStream answerStream = new MemoryStream())
{
using (BinaryWriter w = new BinaryWriter(answerStream))
{
w.Write(2);
w.Write((int)ModSettings.difficulty);
w.Write(ModSettings.FriendlyFire);
w.Write((int)ModSettings.dropsOnDeath);
w.Write(ModSettings.killOnDowned);
w.Close();
}
Network.NetworkManager.SendLine(answerStream.ToArray(), Network.NetworkManager.Target.Clients);
answerStream.Close();
}
}
}
const string PATH = "Mods/Champions of the Forest/Settings.save";
public static void SaveSettings()
{
using (MemoryStream stream = new MemoryStream())
{
using (BinaryWriter buf = new BinaryWriter(stream))
{
buf.Write(FriendlyFire);
buf.Write(killOnDowned);
buf.Write(DropQuantityMultiplier);
buf.Write(DropChanceMultiplier);
buf.Write(ExpMultiplier);
buf.Write(EnemyLevelIncrease);
buf.Write(EnemyDamageMultiplier);
buf.Write(EnemyHealthMultiplier);
buf.Write(EnemyArmorMultiplier);
buf.Write(EnemySpeedMultiplier);
buf.Write(AllowElites);
buf.Write((int)dropsOnDeath);
buf.Write((int)lootLevelPolicy);
buf.Write(AllowRandomCaveSpawn);
buf.Write(AllowCaveRespawn);
buf.Write(CaveMaxAdditionalEnemies);
buf.Write(CaveRespawnDelay);
buf.Write(LootFilterMinRarity);
File.WriteAllBytes(PATH, stream.ToArray());
}
}
}
public static void LoadSettings()
{
if (File.Exists(PATH))
try
{
using (FileStream stream = new FileStream(PATH, FileMode.Open))
{
using (BinaryReader buf = new BinaryReader(stream))
{
FriendlyFire = buf.ReadBoolean();
killOnDowned = buf.ReadBoolean();
DropQuantityMultiplier = buf.ReadSingle();
DropChanceMultiplier = buf.ReadSingle();
ExpMultiplier = buf.ReadSingle();
EnemyLevelIncrease = buf.ReadInt32();
EnemyDamageMultiplier = buf.ReadSingle();
EnemyHealthMultiplier = buf.ReadSingle();
EnemyArmorMultiplier = buf.ReadSingle();
EnemySpeedMultiplier = buf.ReadSingle();
AllowElites = buf.ReadBoolean();
dropsOnDeath = (DropsOnDeathMode)buf.ReadInt32();
lootLevelPolicy = (LootLevelPolicy)buf.ReadInt32();
AllowRandomCaveSpawn = buf.ReadBoolean();
AllowCaveRespawn = buf.ReadBoolean();
CaveMaxAdditionalEnemies = buf.ReadInt32();
CaveRespawnDelay = buf.ReadSingle();
LootFilterMinRarity = buf.ReadInt32();
}
}
}
catch (System.Exception)
{
CotfUtils.Log("Failed loading settings");
}
}
}
}