30 lines
684 B
C#
30 lines
684 B
C#
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace BITFactory;
|
|
public partial class PathRenderer : EntityBehaviour
|
|
{
|
|
[Export] private DeviceValueComponent valueComponent;
|
|
[Export] private Node3D root;
|
|
[Export] private Path3D path3D;
|
|
|
|
public override void OnAwake()
|
|
{
|
|
base.OnAwake();
|
|
valueComponent.OnValueChanged += OnValueChanged;
|
|
}
|
|
private void OnValueChanged(string arg1, DateTime arg2)
|
|
{
|
|
path3D.Curve.ClearPoints();
|
|
foreach (var pair in JArray.Parse(arg1))
|
|
{
|
|
var x = pair["X"]!.ToObject<float>()!;
|
|
var y = pair["Y"]!.ToObject<float>()!;
|
|
path3D.Curve.AddPoint(new Vector3(x,0,y));
|
|
}
|
|
}
|
|
}
|