Add wire info
This commit is contained in:
parent
3e309a4e4c
commit
72a447cc0e
2 changed files with 25 additions and 12 deletions
|
@ -262,7 +262,7 @@ namespace BuildingTools
|
|||
private static string GetBlockInfoInBuildMode()
|
||||
{
|
||||
var block = Player.LocalPlayer.GetBlockLookedAt();
|
||||
if (block == null) return "";
|
||||
if (block == null) return GetWireInfoInBuildMode();
|
||||
float3 pos = block.Position;
|
||||
float3 rot = block.Rotation;
|
||||
float3 scale = block.Scale;
|
||||
|
@ -275,6 +275,24 @@ namespace BuildingTools
|
|||
$"- Group: {block.BlockGroup.Id}";
|
||||
}
|
||||
|
||||
private static string GetWireInfoInBuildMode()
|
||||
{
|
||||
var wire = Player.LocalPlayer.GetWireLookedAt();
|
||||
if (wire == null) return "";
|
||||
var startPos = wire.Start.Position;
|
||||
var endPos = wire.End.Position;
|
||||
Console.WriteLine("Start port: " + wire.StartPort + " End port: " + wire.EndPort);
|
||||
Console.WriteLine("Start block: " + wire.Start);
|
||||
Console.WriteLine("End block: " + wire.End);
|
||||
string startName = wire.StartPort != byte.MaxValue ? wire.Start.OutputPortName(wire.StartPort) : "no port";
|
||||
string endName = wire.EndPort != byte.MaxValue ? wire.End.InputPortName(wire.EndPort) : "no port";
|
||||
return $"Wire with {wire.Id}\n" +
|
||||
$"- From block {wire.Start.Type} at {startPos.x:F} {startPos.y:F} {startPos.z:F}\n" +
|
||||
$"- at port {startName}\n" +
|
||||
$"- To block {wire.End.Type} at {endPos.x:F} {endPos.y:F} {endPos.z:F}\n" +
|
||||
$"- at port {endName}";
|
||||
}
|
||||
|
||||
private static string GetBodyInfoInSimMode()
|
||||
{
|
||||
var body = Player.LocalPlayer.GetSimBodyLookedAt();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using TechbloxModdingAPI.Utility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BuildingTools
|
||||
|
@ -11,10 +12,11 @@ namespace BuildingTools
|
|||
|
||||
public void Toggle()
|
||||
{
|
||||
Console.WriteLine("Toggling no garage");
|
||||
Logging.CommandLog("Toggling no garage");
|
||||
// ReSharper disable once AssignmentInConditionalExpression
|
||||
if(_enabled = !_enabled)
|
||||
Enable();
|
||||
Console.WriteLine($"{(_enabled ? "Enabled" : "Disabled")} no garage");
|
||||
Logging.CommandLog($"{(_enabled ? "Enabled" : "Disabled")} no garage");
|
||||
}
|
||||
|
||||
private void Enable()
|
||||
|
@ -23,13 +25,7 @@ namespace BuildingTools
|
|||
var simObj = (GameObject)AccessTools.Field(type,
|
||||
"THIS_IS_TEMPORARY_CODE_IT_IS_GOING_TO_BE_DELETED_ONCE_WE_HAVE_THE_FINAL_WORLD_SWITCHING_sim_go")
|
||||
.GetValue(null);
|
||||
/*var buildObjField = AccessTools.Field(type,
|
||||
"THIS_IS_TEMPORARY_CODE_IT_IS_GOING_TO_BE_DELETED_ONCE_WE_HAVE_THE_FINAL_WORLD_SWITCHING_build_go");
|
||||
var buildObj = (GameObject) buildObjField.GetValue(null);
|
||||
Console.WriteLine($"obj: {simObj}");*/
|
||||
var componentType = AccessTools.TypeByName("Techblox.Garage.GarageMachineBoundaryImplementor");
|
||||
//var component = buildObj.GetComponent(componentType);
|
||||
//var newBuildObj = Object.Instantiate(simObj);
|
||||
simObj.AddComponent(componentType);
|
||||
var component = simObj.GetComponent(componentType);
|
||||
AccessTools.Field(componentType, "_bounds")
|
||||
|
@ -38,7 +34,6 @@ namespace BuildingTools
|
|||
.SetValue(component, 1f);
|
||||
AccessTools.Field(componentType, "_cameraLookPointDistance")
|
||||
.SetValue(component, 1f);
|
||||
//buildObjField.SetValue(null, newBuildObj);
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
|
@ -47,10 +42,10 @@ namespace BuildingTools
|
|||
public static bool Prefix(object __instance)
|
||||
{
|
||||
if (!_enabled) return true;
|
||||
Console.WriteLine("Got a time stopped init event");
|
||||
Logging.MetaDebugLog("Got a time stopped init event");
|
||||
AccessTools.Method("Techblox.Environment.Temporary.EnvironmentSwitchEngine:OnTimeRunningInitializationComplete")
|
||||
.Invoke(__instance, Array.Empty<object>());
|
||||
Console.WriteLine("Successfully called time running init event");
|
||||
Logging.MetaDebugLog("Successfully called time running init event");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue