Browse Source

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
tags/v1.0.0
NorbiPeti 4 years ago
parent
commit
20cd8b7a50
2 changed files with 41 additions and 38 deletions
  1. +41
    -26
      BlockMod/BlockMod.cs
  2. +0
    -12
      BlockMod/BlockMod.csproj

+ 41
- 26
BlockMod/BlockMod.cs View File

@@ -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<float, float, float, Block[], Block> 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()


+ 0
- 12
BlockMod/BlockMod.csproj View File

@@ -57,9 +57,6 @@
<Reference Include="Blocks.HUDFeedbackBlocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll</HintPath>
</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">
<HintPath>..\..\ref\Gamecraft_Data\Managed\ClusterToWireConversion.Mock.dll</HintPath>
</Reference>
@@ -72,9 +69,6 @@
<Reference Include="DDNA, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\DDNA.dll</HintPath>
</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">
<HintPath>..\..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath>
</Reference>
@@ -333,12 +327,6 @@
<Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath>
</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">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll</HintPath>
</Reference>


Loading…
Cancel
Save