Added some more info and a speedometer

This commit is contained in:
Norbi Peti 2022-02-19 03:03:15 +01:00
parent 343867e67c
commit 94e8a0dc5a
2 changed files with 34 additions and 3 deletions

View file

@ -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}"
);
}

28
BuildingTools/UI.cs Normal file
View file

@ -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;
}
}
}