Update to the latest API

This commit is contained in:
Norbi Peti 2021-06-08 01:12:33 +02:00
parent c4f0198965
commit a15634f003
5 changed files with 1087 additions and 896 deletions

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

@ -25,8 +25,8 @@ namespace BuildingTools
ConsoleCommands.RegisterWithChannel<string>(name + "Chan", (a1, ch) => ConsoleCommands.RegisterWithChannel<string>(name + "Chan", (a1, ch) =>
{ {
Console.WriteLine($"Command {name} with args {a1} and channel {ch} executing"); Console.WriteLine($"Command {name} with args {a1} and channel {ch} executing");
var blks = _blockSelections.SelectBlocks(ch); /*var blks = _blockSelections.SelectBlocks(ch); - TODO: Re-add support if object IDs exist again
action(a1, blks, blks[0]); action(a1, blks, blks[0]);*/
}, ChannelType.Object, desc); }, ChannelType.Object, desc);
} }
@ -56,9 +56,9 @@ namespace BuildingTools
return; return;
} }
var blocks = _blockSelections.SelectBlocks(argsa[3][0]); /*var blocks = _blockSelections.SelectBlocks(argsa[3][0]);
if (_blockSelections.CheckNoBlocks(blocks)) return; if (_blockSelections.CheckNoBlocks(blocks)) return;
action(x, y, z, blocks, blocks[0]); action(x, y, z, blocks, blocks[0]);*/
} }
else if (!_blockSelections.CheckNoBlocks(bs)) else if (!_blockSelections.CheckNoBlocks(bs))
action(x, y, z, bs, b); action(x, y, z, bs, b);
@ -90,9 +90,9 @@ namespace BuildingTools
return; return;
} }
var blocks = _blockSelections.SelectBlocks(argsa[2][0]); /*var blocks = _blockSelections.SelectBlocks(argsa[2][0]);
if (_blockSelections.CheckNoBlocks(blocks)) return; if (_blockSelections.CheckNoBlocks(blocks)) return;
action(argsa[0], darkness, blocks, blocks[0]); action(argsa[0], darkness, blocks, blocks[0]);*/
} }
else if(!_blockSelections.CheckNoBlocks(bs)) else if(!_blockSelections.CheckNoBlocks(bs))
action(argsa[0], darkness, bs, b); action(argsa[0], darkness, bs, b);

View file

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