From 94e8a0dc5ae9e0a31f76db3d2fafb17066e38976 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 19 Feb 2022 03:03:15 +0100 Subject: [PATCH] Added some more info and a speedometer --- BuildingTools/BuildingTools.cs | 9 ++++++--- BuildingTools/UI.cs | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 BuildingTools/UI.cs diff --git a/BuildingTools/BuildingTools.cs b/BuildingTools/BuildingTools.cs index 506fd00..bcd3d8a 100644 --- a/BuildingTools/BuildingTools.cs +++ b/BuildingTools/BuildingTools.cs @@ -9,7 +9,6 @@ using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Commands; using TechbloxModdingAPI.Utility; using IllusionPlugin; -using Techblox.Services.GameDetails; using TechbloxModdingAPI.App; using Unity.Mathematics; using Main = TechbloxModdingAPI.Main; @@ -234,6 +233,7 @@ namespace BuildingTools }).Build(); _mirrorModeEngine.Init(); + UI.Init(); new Harmony("BuildTools").PatchAll(Assembly.GetExecutingAssembly()); } @@ -258,10 +258,12 @@ namespace BuildingTools return $"Block: {block.Type} at {pos.x:F} {pos.y:F} {pos.z:F}\n" + $"- Rotation: {rot.x:F}° {rot.y:F}° {rot.z:F}°\n" + $"- Color: {block.Color.Color} darkness: {block.Color.Darkness}\n" + + $"- Material: {block.Material}\n" + $"- Scale: {scale.x:F} {scale.y:F} {scale.z:F}\n" + $"- Label: {block.Label}\n" + $"- ID: {block.Id}\n" + - $"- Group: {block.BlockGroup.Id}"; + (block.BlockGroup != null ? $"- Group: {block.BlockGroup.Id}\n" : "") + + $"- Mass: {block.Mass}"; } private static string GetWireInfoInBuildMode() @@ -296,7 +298,8 @@ namespace BuildingTools $"- Chunk health: {body.CurrentHealth:F} / {body.InitialHealth:F} - Multiplier: {body.HealthMultiplier:F}\n" + (cluster == null ? "" - : $"- Cluster health: {cluster.CurrentHealth:F} / {cluster.InitialHealth:F} - Multiplier: {cluster.HealthMultiplier:F}" + : $"- Cluster health: {cluster.CurrentHealth:F} / {cluster.InitialHealth:F} - Multiplier: {cluster.HealthMultiplier:F}\n" + + $"- Cluster mass: {cluster.Mass}" ); } diff --git a/BuildingTools/UI.cs b/BuildingTools/UI.cs new file mode 100644 index 0000000..560993d --- /dev/null +++ b/BuildingTools/UI.cs @@ -0,0 +1,28 @@ +using TechbloxModdingAPI; +using TechbloxModdingAPI.App; +using TechbloxModdingAPI.Interface.IMGUI; +using TechbloxModdingAPI.Tasks; +using Unity.Mathematics; +using UnityEngine; + +namespace BuildingTools +{ + public class UI + { + private static Label _speedLabel; + + public static void Init() + { + Game.Simulate += (sender, args) => + { + _speedLabel = new Label(new Rect(Screen.width - 200, 0, 200, 20), "Speed: ", "SpeedLabel"); + Scheduler.Schedule(new Repeatable( + () => _speedLabel.Text = $"Speed: {math.length(Player.LocalPlayer?.Velocity ?? 0) * 3.6:F} km/h", + () => _speedLabel != null)); + }; + Game.Edit += (sender, args) => _speedLabel = null; + Game.Exit += (sender, args) => _speedLabel = null; + + } + } +} \ No newline at end of file