Browse Source

Update to the latest API

tags/v1.2.0
NorbiPeti 3 years ago
parent
commit
a15634f003
5 changed files with 1087 additions and 896 deletions
  1. +2
    -2
      BuildingTools/BlockSelections.cs
  2. +13
    -12
      BuildingTools/BuildingTools.cs
  3. +1066
    -867
      BuildingTools/BuildingTools.csproj
  4. +6
    -6
      BuildingTools/CommandUtils.cs
  5. +0
    -9
      BuildingTools/NoClipCommand.cs

+ 2
- 2
BuildingTools/BlockSelections.cs View File

@@ -21,7 +21,7 @@ namespace BuildingTools
return false;
}

public Block[] SelectBlocks(byte id)
/*public Block[] SelectBlocks(byte id)
{
var blocks = ObjectIdentifier.GetBySimID(id).SelectMany(block => block.GetConnectedCubes()).ToArray();
return blocks;
@@ -32,6 +32,6 @@ namespace BuildingTools
var blocks = ObjectIdentifier.GetByID(id).SelectMany(oid => oid.GetConnectedCubes())
.ToArray();
return blocks;
}
}*/
}
}

+ 13
- 12
BuildingTools/BuildingTools.cs View File

@@ -7,6 +7,7 @@ using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Commands;
using TechbloxModdingAPI.Utility;
using IllusionPlugin;
using TechbloxModdingAPI.App;
using Unity.Mathematics;
using Main = TechbloxModdingAPI.Main;

@@ -26,8 +27,8 @@ namespace BuildingTools
public override void OnApplicationStart()
{
Main.Init();
GameClient.SetDebugInfo("PlayerInfo", GetPlayerInfo);
GameClient.SetDebugInfo("BlockModInfo", GetBlockInfo);
Game.AddPersistentDebugInfo("PlayerInfo", GetPlayerInfo);
Game.AddPersistentDebugInfo("BlockModInfo", GetBlockInfo);
_commandUtils.RegisterBlockCommand("scaleBlocks",
"Scales the selected blocks, relative to current size (current scale * new scale)." +
" The block you're looking at stays where it is, everything else is moved next to it.",
@@ -106,14 +107,14 @@ namespace BuildingTools
var blocks = _blockSelections.blocks;
Logging.CommandLog(blocks.Length + " blocks selected.");
}).Build();
CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.")
/*CommandBuilder.Builder("selectBlocksWithID", "Selects blocks with a specific object ID.")
.Action<char>(id =>
{
_blockSelections.blocks =
(_blockSelections.refBlock = ObjectIdentifier.GetByID(id).FirstOrDefault())
?.GetConnectedCubes() ?? new Block[0];
Logging.CommandLog(_blockSelections.blocks.Length + " blocks selected.");
}).Build();
}).Build();*/
CommandBuilder.Builder("selectSelectedBlocks", "Selects blocks that are box selected by the player.")
.Action(() =>
{
@@ -193,7 +194,7 @@ namespace BuildingTools
uint refID = _blockSelections.refBlock.Id.entityID;
if (group is null)
{
var copy = _blockSelections.refBlock.Copy<Block>();
var copy = _blockSelections.refBlock.Copy();
group = BlockGroup.Create(copy);
_blockSelections.refBlock.Remove();
_blockSelections.refBlock = copy;
@@ -203,7 +204,7 @@ namespace BuildingTools
.Select(block =>
{
if (block.BlockGroup == group) return block;
var copy = block.Copy<Block>();
var copy = block.Copy();
group.Add(copy);
block.Remove();
return copy;
@@ -282,12 +283,12 @@ namespace BuildingTools
{
var player = Player.LocalPlayer;
if (player == null) return "";
TechbloxModdingAPI.FlyCam cam = GameState.IsBuildMode() ? player.BuildCamera : null;
//float3 pos = cam?.Position ?? player.Position;
float3 rot = cam?.Rotation ?? player.Rotation;
float3 vel = cam?.Velocity ?? player.Velocity;
float3 ave = cam?.AngularVelocity ?? player.AngularVelocity;
return $"Player rotation: {rot.x:F}° {rot.y:F}° {rot.z:F}°\n" +
float3 pos = player.Position;
float3 rot = player.Rotation;
float3 vel = player.Velocity;
float3 ave = player.AngularVelocity;
return $"Player position: {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" +
$"- Mass: {player.Mass:F}\n" +


+ 1066
- 867
BuildingTools/BuildingTools.csproj
File diff suppressed because it is too large
View File


+ 6
- 6
BuildingTools/CommandUtils.cs View File

@@ -25,8 +25,8 @@ namespace BuildingTools
ConsoleCommands.RegisterWithChannel<string>(name + "Chan", (a1, ch) =>
{
Console.WriteLine($"Command {name} with args {a1} and channel {ch} executing");
var blks = _blockSelections.SelectBlocks(ch);
action(a1, blks, blks[0]);
/*var blks = _blockSelections.SelectBlocks(ch); - TODO: Re-add support if object IDs exist again
action(a1, blks, blks[0]);*/
}, ChannelType.Object, desc);
}

@@ -56,9 +56,9 @@ namespace BuildingTools
return;
}

var blocks = _blockSelections.SelectBlocks(argsa[3][0]);
/*var blocks = _blockSelections.SelectBlocks(argsa[3][0]);
if (_blockSelections.CheckNoBlocks(blocks)) return;
action(x, y, z, blocks, blocks[0]);
action(x, y, z, blocks, blocks[0]);*/
}
else if (!_blockSelections.CheckNoBlocks(bs))
action(x, y, z, bs, b);
@@ -90,9 +90,9 @@ namespace BuildingTools
return;
}

var blocks = _blockSelections.SelectBlocks(argsa[2][0]);
/*var blocks = _blockSelections.SelectBlocks(argsa[2][0]);
if (_blockSelections.CheckNoBlocks(blocks)) return;
action(argsa[0], darkness, blocks, blocks[0]);
action(argsa[0], darkness, blocks, blocks[0]);*/
}
else if(!_blockSelections.CheckNoBlocks(bs))
action(argsa[0], darkness, bs, b);


+ 0
- 9
BuildingTools/NoClipCommand.cs View File

@@ -1,25 +1,16 @@
using System;
using System.Collections;
using System.Reflection;
using TechbloxModdingAPI;
using TechbloxModdingAPI.Engines;
using TechbloxModdingAPI.Players;
using TechbloxModdingAPI.Utility;
using HarmonyLib;
using RobocraftX.Character;
using RobocraftX.Character.Factories;
using RobocraftX.Character.Movement;
using RobocraftX.Common;
using RobocraftX.Common.Input;
using RobocraftX.Common.UnityECSWrappers;
using RobocraftX.UECS;
using Svelto.ECS;
using Svelto.Tasks.ExtraLean;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using UnityEngine;
using Collider = Unity.Physics.Collider;
using Yield = Svelto.Tasks.Yield;

namespace BuildingTools


Loading…
Cancel
Save