-
Notifications
You must be signed in to change notification settings - Fork 1
/
AttendanceManager.cs
108 lines (91 loc) · 3.36 KB
/
AttendanceManager.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
using System.Collections.Generic;
using VRage.Game.ModAPI;
using Sandbox.ModAPI;
namespace SETextToSpeechMod
{
public class AttendanceManager
{
private List <IMyPlayer> playersField = new List <IMyPlayer>();
public IList <IMyPlayer> Players
{
get
{
return playersField.AsReadOnly();
}
}
/// <summary>
/// CAN BE NULL
/// </summary>
public IMyPlayer LocalPlayer { get; private set; }
private Dictionary <string, bool> muteStatusesField = new Dictionary <string, bool>();
public IReadOnlyDictionary <string, bool> PlayersMuteStatuses
{
get
{
return (IReadOnlyDictionary<string, bool>)muteStatusesField;
}
}
private static AttendanceManager instance = new AttendanceManager();
private AttendanceManager()
{
}
public static AttendanceManager GetSingleton()
{
return instance;
}
/// <summary>
/// Mutes or unmutes the requests player based on your bool input.
/// </summary>
/// <param name="player"></param>
/// <param name="mutePlayer"></param>
/// <returns></returns>
public void ChangeMuteStatusOfPlayer (string player, bool newMuteStatus)
{
UpdatePlayers();
for (int i = 0; i < playersField.Count; i++)
{
if (playersField[i].DisplayName == player)
{
if (muteStatusesField.ContainsKey (player))
{
muteStatusesField[player] = newMuteStatus;
}
else
{
muteStatusesField.Add (player, newMuteStatus);
}
switch (newMuteStatus)
{
case true:
MyAPIGateway.Utilities.ShowMessage ("", "Muted '" + player + "', Ya cunt...");
break;
case false:
MyAPIGateway.Utilities.ShowMessage ("", "Unmuted '" + player + "'.");
break;
}
return;
}
}
MyAPIGateway.Utilities.ShowMessage ("", "Player: '" + player + "' could not be found.");
}
public static void UpdatePlayers()
{
playersField.Clear(); //GetPlayers() just adds without overwriting so list must be cleared every time.
if (OutputManager.IsDebugging == false)
{
MyAPIGateway.Multiplayer.Players.GetPlayers (playersField);
for (int i = 0; i < playersField.Count; i++)
{
if (muteStatusesField.ContainsKey (playersField[i].DisplayName) == false)
{
muteStatusesField.Add (playersField[i].DisplayName, new bool());
}
if (playersField[i].SteamUserId == MyAPIGateway.Multiplayer.MyId)
{
LocalPlayer = playersField[i];
}
}
}
}
}
}