-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathServerConfig.cs
65 lines (55 loc) · 1.98 KB
/
ServerConfig.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
using Newtonsoft.Json;
using System.ComponentModel;
using System.Runtime.Serialization;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
namespace SummonersAssociation
{
public class ServerConfig : ModConfig
{
public override ConfigScope Mode => ConfigScope.ServerSide;
public static ServerConfig Instance => ModContent.GetInstance<ServerConfig>();
/// <summary>
/// If true, disables the hooks required for the feature to work, makes the right click a regular "targeting" feature, and if a reticle
/// manages to spawn (cheatsheet), it's automatically despawned
/// </summary>
[ReloadRequired]
[DefaultValue(false)]
public bool DisableAdvancedTargetingFeature;
[DefaultValue(false)]
public bool PersistentReticle;
public const float LoadoutBookSpeed_Min = 1f;
public const float LoadoutBookSpeed_Max = 20f;
[Slider]
[Increment(0.5f)]
[Range(LoadoutBookSpeed_Min, LoadoutBookSpeed_Max)]
[DefaultValue(2.5f)]
public float LoadoutBookSpeed;
[Header("HintToClientConfig")]
[JsonIgnore]
[ShowDespiteJsonIgnore]
public bool Hint => true;
public static bool IsPlayerLocalServerOwner(int whoAmI) {
if (Main.netMode == NetmodeID.MultiplayerClient) {
return Netplay.Connection.Socket.GetRemoteAddress().IsLocalHost();
}
return NetMessage.DoesPlayerSlotCountAsAHost(whoAmI);
}
public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref NetworkText message) {
if (Main.netMode == NetmodeID.SinglePlayer) return true;
else if (!IsPlayerLocalServerOwner(whoAmI)) {
message = NetworkText.FromKey("tModLoader.ModConfigRejectChangesNotHost");
return false;
}
return base.AcceptClientChanges(pendingConfig, whoAmI, ref message);
}
[OnDeserialized]
internal void OnDeserializedMethod(StreamingContext context) {
//Correct invalid values
LoadoutBookSpeed = Utils.Clamp(LoadoutBookSpeed, LoadoutBookSpeed_Min, LoadoutBookSpeed_Max);
}
}
}