-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorldTickManager.cs
63 lines (52 loc) · 1.6 KB
/
WorldTickManager.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
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
using Engine;
namespace UtilityAI
{
public class WorldTickManager
{
private static WorldTickManager _instance;
public static WorldTickManager Instance {
get {
if (_instance == null) {
_instance = new WorldTickManager();
}
return _instance;
}
}
private UpdateManager realtime;
private UpdateManager[] tick;
public void Init(int tickcapacity = 5){
realtime = new UpdateManager();
tick = new UpdateManager[tickcapacity];
for (int i = 0; i < tickcapacity; i++)
{
tick[i] = new UpdateManager();
}
}
public WorldTickManager AddRealtime(string group, Action function){
realtime.Add(group, function);
return this;
}
public WorldTickManager AddTick(int id, string group, Action function){
tick[id].Add(group, function);
return this;
}
public WorldTickManager RemoveRealtime(string group, Action function){
realtime.Remove(group, function);
return this;
}
public WorldTickManager RemoveTick(int id, string group, Action function){
tick[id].Remove(group, function);
return this;
}
public void UpdateRealtime(){
realtime.Update();
}
public void UpdateTick(int id){
tick[id].Update();
}
}
}