-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundEntry.cs
95 lines (87 loc) · 2.08 KB
/
SoundEntry.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
using System;
using System.Linq;
using System.Runtime.Remoting.Activation;
using System.Xml.Serialization;
namespace BasicTwitchSoundPlayer.SoundStorage
{
[Serializable]
public class SoundEntry
{
[XmlAttribute]
public string RewardName;
[XmlAttribute]
public string RewardID;
[XmlAttribute]
public string Description;
[XmlAttribute]
public float Volume;
[XmlAttribute]
public int AmountOfPoints;
[XmlAttribute]
public int Cooldown;
[XmlArrayItem]
public string[] Files;
[XmlArrayItem]
public string[] Tags;
public SoundEntry()
{
RewardName = "";
Description = "";
Files = new string[0];
Tags = new string[0];
RewardID = "";
Volume = 1f;
AmountOfPoints = 500;
Cooldown = 0;
}
public SoundEntry(string Command, string Description, string RewardID, string[] Files, string[] Tags, float Volume, int AmountOfPoints, int Cooldown)
{
this.RewardName = Command;
this.Description = Description;
this.RewardID = RewardID;
this.Files = Files;
this.Tags = Tags;
this.Description = Description;
this.Volume = Volume;
this.AmountOfPoints = AmountOfPoints;
if (Cooldown < 0)
Cooldown = 0;
this.Cooldown = Cooldown;
}
public string GetFile(Random rng)
{
if (Files.Length > 1)
{
return Files[rng.Next(0, Files.Length)];
}
return Files[0];
}
public void AddFiles(string[] importedFiles)
{
foreach (var importedFile in importedFiles)
{
if (!Files.Any(x => x.ToLower() == importedFile.ToLower()))
{
var tempFile = new string[Files.Length + 1];
for (int i = 0; i < Files.Length; i++)
{
tempFile[i] = Files[i];
}
tempFile[tempFile.Length - 1] = importedFile;
Files = tempFile;
}
}
}
public bool GetIsProperEntry() { return (RewardName != null && RewardName != "") && (Files != null && Files.Length > 0); }
public SoundEntry CreateCopy() => new SoundEntry()
{
RewardID = RewardID,
RewardName = RewardName,
AmountOfPoints = AmountOfPoints,
Cooldown = Cooldown,
Description = Description,
Files = Files,
Volume = Volume,
};
}
}