-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConsoleCmdSetLevel.cs
55 lines (50 loc) · 1.85 KB
/
ConsoleCmdSetLevel.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
using System.Collections.Generic;
namespace _7DTD_Test
{
public class ConsoleCmdSetLevel : ConsoleCmdAbstract
{
public override string[] GetCommands() => new string[1]
{
"setlevel"
};
public override bool IsExecuteOnClient => true;
public override string GetDescription()
{
return "Set your level";
}
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
{
if (GameManager.IsDedicatedServer)
{
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("cannot execute setlevel on dedicated server, please execute as a client");
return;
}
if (_params.Count < 1)
{
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("setlevel requires level as integer");
}
else
{
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
if (int.TryParse(_params[0], out var result))
{
if ( result <= 0)
{
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("level must be 1 or more.");
}
else if (result > Progression.MaxLevel)
{
SingletonMonoBehaviour<SdtdConsole>.Instance.Output(
$"level can not be higher as {Progression.MaxLevel}.");
}
else
{
primaryPlayer.Progression.Level = result;
}
}
else
SingletonMonoBehaviour<SdtdConsole>.Instance.Output("level must be a integer.");
}
}
}
}