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
This commit is contained in:
Norbi Peti 2020-06-12 17:30:21 +02:00
parent 47d1f43495
commit 20cd8b7a50
2 changed files with 41 additions and 38 deletions

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Gamecraft.Wires;
using Gamecraft.Wires.ChannelsCommon; using Gamecraft.Wires.ChannelsCommon;
using GamecraftModdingAPI; using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Blocks;
@ -90,6 +91,12 @@ namespace BlockMod
refBlock = blocks.Length > 0 ? blocks[0] : null; refBlock = blocks.Length > 0 ? blocks[0] : null;
}).Build(); }).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.", RegisterBlockCommand("pushBlocks", "Adds velocity to the selected blocks. Only works in simulation.",
(x, y, z, blocks, refBlock) => (x, y, z, blocks, refBlock) =>
{ {
@ -118,35 +125,43 @@ namespace BlockMod
private string GetBlockInfo() private string GetBlockInfo()
{ {
if (GameState.IsBuildMode()) if (GameState.IsBuildMode())
{ return GetBlockInfoInBuildMode();
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}";
}
if (GameState.IsSimulationMode()) if (GameState.IsSimulationMode())
{ return GetBodyInfoInSimMode();
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 "Switching modes..."; 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) private bool CheckNoBlocks(Block[] blocks)
{ {
if (blocks.Length == 0) if (blocks.Length == 0)
@ -179,7 +194,7 @@ namespace BlockMod
var blks = SelectBlocks(ch); var blks = SelectBlocks(ch);
if (CheckNoBlocks(blks)) return; if (CheckNoBlocks(blks)) return;
action(a1, a2, blks, blks[0]); action(a1, a2, blks, blks[0]);
}, BinaryChannelUtilities.ChannelType.Object, desc); }, ChannelType.Object, desc);
} }
private void RegisterBlockCommand(string name, string desc, Action<float, float, float, Block[], Block> action) private void RegisterBlockCommand(string name, string desc, Action<float, float, float, Block[], Block> action)
@ -195,7 +210,7 @@ namespace BlockMod
var blks = SelectBlocks(ch); var blks = SelectBlocks(ch);
if (CheckNoBlocks(blks)) return; if (CheckNoBlocks(blks)) return;
action(x, y, z, blks, blks[0]); action(x, y, z, blks, blks[0]);
}, BinaryChannelUtilities.ChannelType.Object, desc); }, ChannelType.Object, desc);
} }
public void OnApplicationQuit() public void OnApplicationQuit()

View file

@ -57,9 +57,6 @@
<Reference Include="Blocks.HUDFeedbackBlocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Blocks.HUDFeedbackBlocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
</Reference> </Reference>
<Reference Include="ChannelsCommon, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\ChannelsCommon.dll</HintPath>
</Reference>
<Reference Include="ClusterToWireConversion.Mock, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="ClusterToWireConversion.Mock, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
</Reference> </Reference>
@ -72,9 +69,6 @@
<Reference Include="DDNA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="DDNA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\DDNA.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\DDNA.dll</HintPath>
</Reference> </Reference>
<Reference Include="Facepunch.Steamworks.Win64, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
</Reference>
<Reference Include="FMOD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="FMOD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath>
</Reference> </Reference>
@ -333,12 +327,6 @@
<Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath>
</Reference> </Reference>
<Reference Include="Svelto.ECS.Debugger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.dll</HintPath>
</Reference>
<Reference Include="Svelto.ECS.Debugger.Internal, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.Debugger.Internal.dll</HintPath>
</Reference>
<Reference Include="Svelto.Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Svelto.Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll</HintPath> <HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll</HintPath>
</Reference> </Reference>