From 20cd8b7a50ebf1dd5eb34e7f7c7c63184b1b3c0d Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 12 Jun 2020 17:30:21 +0200 Subject: [PATCH] Update to Gamecraft 2020.06.11.18.50 Apparently the pilot seat is recognised as a block even in sim mode when looking at it --- BlockMod/BlockMod.cs | 67 ++++++++++++++++++++++++---------------- BlockMod/BlockMod.csproj | 12 ------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/BlockMod/BlockMod.cs b/BlockMod/BlockMod.cs index cf15d49..4dd3323 100644 --- a/BlockMod/BlockMod.cs +++ b/BlockMod/BlockMod.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Gamecraft.Wires; using Gamecraft.Wires.ChannelsCommon; using GamecraftModdingAPI; using GamecraftModdingAPI.Blocks; @@ -90,6 +91,12 @@ namespace BlockMod refBlock = blocks.Length > 0 ? blocks[0] : null; }).Build(); + ConsoleCommands.RegisterWithChannel("selectSendSignal", ch => + { + + }, ChannelType.Object, + "Sends a signal for selecting a given object ID for a command block."); + RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in simulation.", (x, y, z, blocks, refBlock) => { @@ -118,35 +125,43 @@ namespace BlockMod private string GetBlockInfo() { if (GameState.IsBuildMode()) - { - var block = new Player(PlayerType.Local).GetBlockLookedAt(); - float3 pos = block.Position; - float3 rot = block.Rotation; - float3 scale = block.Scale; - 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" + - $"- Scale: {scale.x:F} {scale.y:F} {scale.z:F}\n" + - $"- Label: {block.Label}"; - } + return GetBlockInfoInBuildMode(); if (GameState.IsSimulationMode()) - { - var body = new Player(PlayerType.Local).GetSimBodyLookedAt(); - float3 pos = body.Position; - float3 rot = body.Rotation; - float3 vel = body.Velocity; - float3 ave = body.AngularVelocity; - float3 com = body.CenterOfMass; - return $"Body at {pos.x:F} {pos.y:F} {pos.z:F}\n" + - $"- Rotation: {rot.x:F}° {rot.y:F}° {rot.z:F}°\n" + - $"- Velocity: {vel.x:F} {vel.y:F} {vel.z:F}\n" + - $"- Angular velocity: {ave.x:F} {ave.y:F} {ave.z:F}\n" + - $"- {(body.Static ? "Static body" : $"Mass: {body.Mass:F} center: {com.x:F} {com.y:F} {com.z:F}")}"; - } + return GetBodyInfoInSimMode(); return "Switching modes..."; } + private static string GetBlockInfoInBuildMode() + { + var block = new Player(PlayerType.Local).GetBlockLookedAt(); + if (block == null) return ""; + float3 pos = block.Position; + float3 rot = block.Rotation; + float3 scale = block.Scale; + 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" + + $"- Scale: {scale.x:F} {scale.y:F} {scale.z:F}\n" + + $"- Label: {block.Label}"; + } + + private static string GetBodyInfoInSimMode() + { + var body = new Player(PlayerType.Local).GetSimBodyLookedAt(); + if (body == null) return GetBlockInfoInBuildMode(); + float3 pos = body.Position; + float3 rot = body.Rotation; + float3 vel = body.Velocity; + float3 ave = body.AngularVelocity; + float3 com = body.CenterOfMass; + return $"Body at {pos.x:F} {pos.y:F} {pos.z:F}\n" + + $"- Rotation: {rot.x:F}° {rot.y:F}° {rot.z:F}°\n" + + $"- Velocity: {vel.x:F} {vel.y:F} {vel.z:F}\n" + + $"- Angular velocity: {ave.x:F} {ave.y:F} {ave.z:F}\n" + + $"- {(body.Static ? "Static body" : $"Mass: {body.Mass:F} center: {com.x:F} {com.y:F} {com.z:F}")}"; + } + private bool CheckNoBlocks(Block[] blocks) { if (blocks.Length == 0) @@ -179,7 +194,7 @@ namespace BlockMod var blks = SelectBlocks(ch); if (CheckNoBlocks(blks)) return; action(a1, a2, blks, blks[0]); - }, BinaryChannelUtilities.ChannelType.Object, desc); + }, ChannelType.Object, desc); } private void RegisterBlockCommand(string name, string desc, Action action) @@ -195,7 +210,7 @@ namespace BlockMod var blks = SelectBlocks(ch); if (CheckNoBlocks(blks)) return; action(x, y, z, blks, blks[0]); - }, BinaryChannelUtilities.ChannelType.Object, desc); + }, ChannelType.Object, desc); } public void OnApplicationQuit() diff --git a/BlockMod/BlockMod.csproj b/BlockMod/BlockMod.csproj index ae7d000..e78a966 100644 --- a/BlockMod/BlockMod.csproj +++ b/BlockMod/BlockMod.csproj @@ -57,9 +57,6 @@ ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll - - ..\..\ref\Gamecraft_Data\Managed\ChannelsCommon.dll - ..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll @@ -72,9 +69,6 @@ ..\..\ref\Gamecraft_Data\Managed\DDNA.dll - - ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\..\ref\Gamecraft_Data\Managed\FMOD.dll @@ -333,12 +327,6 @@ ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - - ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.dll - - - ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.Internal.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll