-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoundEndAdvertise.cs
77 lines (65 loc) · 2.45 KB
/
RoundEndAdvertise.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
using BattleBitAPI.Common;
using BBRAPIModules;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
namespace BBRModules
{
[Module("Advertise your discord, patreon, etc at the end of a round.", "1.0.0")]
public class RoundEndAdvertise : BattleBitModule
{
public REAConfig Configuration { get; set; } = null!;
private int index = 0;
public override async Task OnGameStateChanged(GameState oldState, GameState newState)
{
if (newState != GameState.EndingGame)
return;
string message = GetNextMessage();
switch (Configuration.MessageType)
{
case "AnnounceLong":
Server.AnnounceLong(message);
break;
case "AnnounceShort":
Server.AnnounceShort(message);
break;
case "Chat":
Server.SayToAllChat(message);
break;
case "Timed":
int index = 0;
List<RunnerPlayer> players = new(Server.AllPlayers);
do
{
RunnerPlayer player = players.ElementAt(index);
player.Message(message, Configuration.TimedMessageDuration);
index++;
} while (index < players.Count());
break;
}
}
private string GetNextMessage()
{
if (!Configuration.UseDifferentMessages)
return Configuration.Message;
int oldIndex = index;
index++;
if (Configuration.Messages.Count == index)
index = 0;
return Configuration.Messages[oldIndex];
}
}
public class REAConfig : ModuleConfiguration
{
public string MessageType { get; set; } = "AnnounceLong";
public string Message { get; set; } = "Join our discord at discord.gg/vanguardbb!";
public bool UseDifferentMessages { get; set; } = false;
public float TimedMessageDuration { get; set; } = 5.0f;
public List<string> Messages { get; set; } = new()
{
"Join our discord at discord.gg/vanguardbb",
"Community server hosted by Vanguard @ discord.gg/vanguardbb",
"For info about current giveaways and events join discord.gg/vanguardbb"
};
}
}