|
|
|
|
@ -1,9 +1,38 @@ |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
|
|
namespace UltraCombos |
|
|
|
|
{ |
|
|
|
|
public class GroundControl : MonoBehaviour |
|
|
|
|
{ |
|
|
|
|
[System.Serializable] |
|
|
|
|
public class Component |
|
|
|
|
{ |
|
|
|
|
[JsonProperty("key")] public string Key { get; set; } |
|
|
|
|
[JsonProperty("order")] public int Order { get; set; } |
|
|
|
|
[JsonProperty("width")] public float? Width { get; set; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[System.Serializable] |
|
|
|
|
public class Message |
|
|
|
|
{ |
|
|
|
|
[JsonProperty("id")] public string Id { get; set; } |
|
|
|
|
[JsonProperty("step")] public int Step { get; set; } |
|
|
|
|
[JsonProperty("stepName")] public string StepName { get; set; } |
|
|
|
|
[JsonProperty("character")] public string Character { get; set; } |
|
|
|
|
[JsonProperty("components")] public List<Component> Components { get; set; } = new(); |
|
|
|
|
[JsonProperty("title")] public string Title { get; set; } |
|
|
|
|
[JsonProperty("result")] public string Result { get; set; } |
|
|
|
|
[JsonProperty("updatedAt")] public long UpdatedAt { get; set; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Dictionary<string, Message> messages = new(); |
|
|
|
|
public string Station1 => GetSummary(0); |
|
|
|
|
public string Station2 => GetSummary(1); |
|
|
|
|
public string Station3 => GetSummary(2); |
|
|
|
|
|
|
|
|
|
private void Start() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
@ -13,6 +42,30 @@ namespace UltraCombos |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void OnMQTT(string topic, string payload) |
|
|
|
|
{ |
|
|
|
|
var parts = topic.Split("/"); |
|
|
|
|
if (parts.Length != 3) |
|
|
|
|
{ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
var id = parts[1]; |
|
|
|
|
var msg = JsonConvert.DeserializeObject<Message>(payload); |
|
|
|
|
messages[id] = msg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private string GetSummary(int index) |
|
|
|
|
{ |
|
|
|
|
var keys = messages.Keys.ToArray(); |
|
|
|
|
if (keys.Length <= index) |
|
|
|
|
{ |
|
|
|
|
return "No messages"; |
|
|
|
|
} |
|
|
|
|
var id = keys[index]; |
|
|
|
|
var msg = messages[id]; |
|
|
|
|
return $"{id} #{msg.Step} {msg.Character}"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|