routecommand attempt1

This commit is contained in:
Logophilist
2020-09-18 14:54:13 +02:00
parent a5a61a8a83
commit 36a0177270
3 changed files with 59 additions and 6 deletions

View File

@@ -1,8 +1,10 @@
using Newtonsoft.Json; using LibNoise.Primitive;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading;
namespace RH_Engine namespace RH_Engine
{ {
@@ -148,7 +150,57 @@ namespace RH_Engine
public string RouteCommand() public string RouteCommand()
{ {
return ""; ImprovedPerlin improvedPerlin = new ImprovedPerlin(0, LibNoise.NoiseQuality.Best);
dynamic payload = new
{
id = "route/add",
data = new
{
nodes = new dynamic[]
{
new
{
pos = GetPos(0, improvedPerlin),
dir = GetDir()
},
new
{
pos = GetPos(1, improvedPerlin),
dir = GetDir()
},
new
{
pos = GetPos(2, improvedPerlin),
dir = GetDir()
},
new
{
pos = GetPos(3, improvedPerlin),
dir = GetDir()
},
new
{
pos = GetPos(4, improvedPerlin),
dir = GetDir()
}
}
}
};
Console.WriteLine(JsonConvert.SerializeObject(Payload(payload)));
return JsonConvert.SerializeObject(Payload(payload));
}
private int[] GetPos(int n, ImprovedPerlin improvedPerlin)
{
return new int[] { (int)improvedPerlin.GetValue(n) * 50 * n, 0, (int)improvedPerlin.GetValue(n) * 50 };
}
private int[] GetDir()
{
Random rng = new Random();
int[] dir = {rng.Next(5), rng.Next(5), rng.Next(5)};
return dir;
} }
public string FollowRouteCommand() public string FollowRouteCommand()

View File

@@ -13,11 +13,11 @@ namespace RH_Engine
internal class Program internal class Program
{ {
private static PC[] PCs = { private static PC[] PCs = {
//new PC("DESKTOP-TV73FK0", "woute"),
//new PC("DESKTOP-M2CIH87", "Fabian"), //new PC("DESKTOP-M2CIH87", "Fabian"),
new PC("T470S", "Shinichi"), //new PC("T470S", "Shinichi"),
//new PC("DESKTOP-DHS478C", "semme"), new PC("DESKTOP-DHS478C", "semme"),
new PC("NA", "Ralf"), //new PC("DESKTOP-TV73FKO", "Wouter"),
new PC("DESKTOP-SINMKT1", "Ralf"),
new PC("NA", "Bart") }; new PC("NA", "Bart") };
private static void Main(string[] args) private static void Main(string[] args)
{ {

View File

@@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="LibNoise" Version="0.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup> </ItemGroup>