-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
55 lines (46 loc) · 1.24 KB
/
Program.cs
File metadata and controls
55 lines (46 loc) · 1.24 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
using Entitas;
using Entitas.Generic;
namespace Sample
{
[Game]
public class Player : IComponent
{
public int Id;
public string Name;
}
public class SayHelloSystem : IExecuteSystem
{
public void Execute()
{
var group = GameCtx.Inst.GetGroup(GameMatchers.Get<Player>());
foreach (var item in group.GetEntities())
{
Console.WriteLine($"Hello {item.Get<Player>().Name}");
}
}
}
public class Program
{
private static Systems m_Systems;
public static void Main(string[] args)
{
GameLoop().GetAwaiter().GetResult();
}
private async static Task GameLoop()
{
Contexts.Inst.Init<Game, InputScope>();
var jack = GameCtx.Inst.CreateEntity();
var player = jack.Add<Player>();
player.Id = 1;
player.Name = "Jack";
m_Systems = new Feature().Add(new SayHelloSystem());
m_Systems.Initialize();
while (true)
{
m_Systems.Execute();
m_Systems.Cleanup();
await Task.Delay(500);
}
}
}
}