-
Notifications
You must be signed in to change notification settings - Fork 0
/
VModSystem.cs
50 lines (38 loc) · 1.08 KB
/
VModSystem.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
using ValksStructures.Content.Items;
namespace ValksStructures;
public class VModSystem : ModSystem
{
public static event Action Update;
public static int BuildTickRate { get; set; } = 1;
static readonly List<Action> actions = new();
int count;
public override void PreUpdateEntities()
{
count++;
if (count >= BuildTickRate)
{
count = 0;
Update?.Invoke();
}
}
public static void AddAction(Action action) => actions.Add(action);
public static void StartActions() => Update += ExecuteAction;
public static void ExecuteAllActions()
{
foreach (Action action in actions)
action();
actions.Clear();
ModContent.GetInstance<ValksStructures>().IsCurrentlyBuilding = false;
}
static void ExecuteAction()
{
if (actions.Count == 0)
{
Update -= ExecuteAction;
ModContent.GetInstance<ValksStructures>().IsCurrentlyBuilding = false;
return;
}
actions[0]();
actions.RemoveAt(0);
}
}