Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
49 lines (43 loc) · 1.41 KB
/
Copy pathProgram.cs
File metadata and controls
49 lines (43 loc) · 1.41 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
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using PaintScript_Engine.Versions;
namespace PaintScript_Engine
{
public class Program
{
public static async Task Main(string[] args)
{
// Load the JSON IR (replace with your actual file path or JSON string)
string json = File.ReadAllText("program.json");
// Deserialize into PSProgram
var program = JsonSerializer.Deserialize<PaintScriptEngine_Alpha_0_1_0.PSProgram>(
json,
new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
}
);
if (program == null)
{
Console.WriteLine("Failed to load PaintScript program.");
return;
}
// Create the engine
var engine = new PaintScriptEngine_Alpha_0_1_0.PaintScriptEngine(program);
// Start @start event on all targets
foreach (var target in program.Targets)
{
engine.StartEvent(target, "Start");
}
// Tick loop
Console.WriteLine("Running PaintScript program...");
while (true)
{
await engine.TickAsync();
await Task.Delay(10); // small delay to avoid CPU burn
}
}
}
}