This repository was archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInteraction.cs
More file actions
109 lines (98 loc) · 3.23 KB
/
Interaction.cs
File metadata and controls
109 lines (98 loc) · 3.23 KB
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
109
using System.Text;
namespace Rift.RiftEngine.Core
{
public class Interaction
{
public readonly string InteractionName;
public readonly Event trigger;
public readonly string output;
public readonly List<object> parameters = new();
public Interaction(string interactionName, Event trigger, string output)
{
InteractionName = interactionName;
this.trigger = trigger;
this.output = output;
}
public Interaction(string interactionName, Event trigger, FilePath output)
{
InteractionName = interactionName;
this.trigger = trigger;
try
{
this.output = File.ReadAllText(output.ToString());
}
catch (Exception ex)
{
throw new FilePathInvalidException($"The file path \"{output.ToString()}\" was not a valid file.", ex);
}
}
public Interaction(string interactionName, Event trigger, string output, List<object> parameters)
{
InteractionName = interactionName;
this.trigger = trigger;
this.output = output;
foreach (object p in parameters)
{
AddParameter(p);
}
}
public Interaction(string interactionName, Event trigger, FilePath output, List<object> parameters)
{
InteractionName = interactionName;
this.trigger = trigger;
try
{
this.output = File.ReadAllText(output.ToString());
}
catch (Exception ex)
{
throw new FilePathInvalidException($"The file path \"{output.ToString()}\" was not a valid file.", ex);
}
foreach (object p in parameters)
{
AddParameter(p);
}
}
public Interaction(string interactionName, Event trigger, string output, object parameter)
{
InteractionName = interactionName;
this.trigger = trigger;
this.output = output;
AddParameter(parameter);
}
public Interaction(string interactionName, Event trigger, FilePath output, object parameter)
{
InteractionName = interactionName;
this.trigger = trigger;
try
{
this.output = File.ReadAllText(output.ToString());
}
catch (Exception ex)
{
throw new FilePathInvalidException($"The file path \"{output.ToString()}\" was not a valid file.", ex);
}
AddParameter(parameter);
}
public void AddParameter(object parameter)
{
parameters.Add(parameter);
}
public List<object> GetParameters()
{
return parameters;
}
public void RemoveParameter(int index)
{
parameters.RemoveAt(index);
}
public void RemoveParameter(object parameter)
{
parameters.Remove(parameter);
}
public void Trigger()
{
Console.WriteLine(string.Format(output, parameters.ToArray()));
}
}
}