Attempt to bring console back and update block ID list

This commit is contained in:
Norbi Peti 2021-04-13 02:05:16 +02:00
parent 98e00de642
commit 124ef410c7
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
6 changed files with 176 additions and 374 deletions

View file

@ -9,362 +9,145 @@ namespace GamecraftModdingAPI.Blocks
/// Called "nothing" in Gamecraft. (DBID.NOTHING) /// Called "nothing" in Gamecraft. (DBID.NOTHING)
/// </summary> /// </summary>
Invalid = ushort.MaxValue, Invalid = ushort.MaxValue,
AluminiumCube = 0, Cube = 0,
AxleS, Wedge,
HingeS = 3, QuarterPyramid,
MotorS, Tetrahedron,
HingeM, RoundedWedge,
MotorM, RoundedQuarterPyramid,
TyreM, RoundedTetrahedron,
AxleM, NegativeQuarterPyramid,
IronCube, NegativeTetrahedron,
RubberCube, RoundedNegativeQuarterPyramid,
OiledCube, RoundedNegativeTetrahedron, //10
AluminiumConeSegment, //12 PlateCube,
AluminiumCorner, PlateWedge,
AluminiumRoundedCorner, PlateQuarterPyramid,
AluminiumSlicedCube, PlateTetrahedron,
AluminiumRoundedSlicedCube, Sphere,
AluminiumCylinder, Frame,
AluminiumPyramidSegment, FrameS1,
AluminiumSlope, FrameS2,
AluminiumRoundedSlope, FrameS3,
AluminiumSphere, FrameS4, //20
RubberConeSegment, //22 FrameS5,
RubberCorner, FrameWedge,
RubberRoundedCorner, FrameWedgeS1,
RubberSlicedCube, FrameWedgeS2,
RubberRoundedSlicedCube, FrameWedgeS3,
RubberCylinder, FrameWedgeS4,
RubberPyramidSegment, SideS0S1,
RubberSlope, SideS0S2,
RubberRoundedSlope, SideS0S3,
RubberSphere, SideS0S4, //30
OiledConeSegment, //32 SideS0S5,
OiledCorner, SideS1S1,
OiledRoundedCorner, SideS1S2,
OiledSlicedCube, SideS1S3,
OiledRoundedSlicedCube, SideS1S4,
OiledCylinder, SideS1S5,
OiledPyramidSegment, SideS2S1,
OiledSlope, SideS2S2,
OiledRoundedSlope, SideS2S3,
OiledSphere, SideS2S4,
IronConeSegment, //42 SideS2S5,
IronCorner, WindscreenS1, //42
IronRoundedCorner, WindscreenS2,
IronSlicedCube, WindscreenS3,
IronRoundedSlicedCube, WindscreenS4,
IronCylinder, WindscreenS5,
IronPyramidSegment, CarWheelArch,
IronSlope, CarArchSmallFlare,
IronRoundedSlope, CarArchFlare,
IronSphere, CarArchExtrudedFlare, //50
GlassCube, //52 Cube1X1,
GlassSlicedCube, Cube1X2,
GlassSlope, Cube1X3,
GlassCorner, Cube1X4,
GlassPyramidSegment, Cube1X6,
GlassRoundedSlicedCube, Cube2X2,
GlassRoundedSlope, Cube2X3,
GlassRoundedCorner, Cube2X4,
GlassConeSegment, Cube2X6,
GlassCylinder, Wedge1X1, //60
GlassSphere, Wedge1X2,
Lever, //63 Wedge1X3,
WoodenSlatsDoor = 65, Wedge2X1,
PlayerSpawn, //Crashes without special handling Wedge2X2,
SmallSpawn, Wedge2X3,
MediumSpawn, RoundedWedge1X1,
LargeSpawn, RoundedWedge1X2,
RoundedWedge1X3,
RoundedWedge2X1,
RoundedWedge2X2, //70
RoundedWedge2X3,
Plate1X1,
Plate1X2,
Plate1X3,
Plate1X4,
Plate2X2,
Plate2X3,
Plate2X4,
Plate3X3,
Plate3X4, //80
Cube1X1S1,
Cube1X2S1,
Cube1X3S1,
Wedge1X1S1,
Wedge1X2S1,
Wedge1X3S1,
Wedge2X1S1,
Wedge2X2S1,
Wedge2X3S1,
Wedge3X1S1, //90
Wedge3X2S1,
Wedge3X3S1,
NegativeTetrahedron1X1S1,
NegativeTetrahedron1X2S1,
NegativeTetrahedron1X3S1,
NegativeTetrahedron2X1S1,
NegativeTetrahedron2X2S1,
NegativeTetrahedron2X3S1,
NegativeTetrahedron3X1S1,
Axle, //100
Hinge,
BallJoint, BallJoint,
UniversalJoint, UniversalJoint,
ServoAxle,
ServoHinge,
StepperAxle,
StepperHinge,
TelescopicJoint, TelescopicJoint,
HingeSpring,
AxleSpring,
DampedSpring, DampedSpring,
ServoPiston, WheelRigNoSteering,
StepperPiston, WheelRigWithSteering,
PneumaticPiston, //80 NegativeTetrahedron3X2S1, //110
PneumaticHinge, NegativeTetrahedron3X3S1,
PneumaticAxle, Tetrahedron1X1S1,
WindowedDoor, Tetrahedron1X2S1,
Bench, Tetrahedron1X3S1,
Chair, Tetrahedron2X1S1,
Stool, Tetrahedron2X2S1,
DampedHingeSpring, Tetrahedron2X3S1,
PlainGlassDoor, Tetrahedron3X1S1,
PlainWoodenDoor, Tetrahedron3X2S1,
PilotSeat, //Might crash Tetrahedron3X3S1, //120
QuarterPyramid1X1S1,
QuarterPyramid1X2S1,
QuarterPyramid1X3S1,
QuarterPyramid2X1S1,
QuarterPyramid2X2S1,
QuarterPyramid2X3S1,
QuarterPyramid3X1S1,
QuarterPyramid3X2S1,
QuarterPyramid3X3S1,
PlateTriangle, //130
PlateCircle,
PlateQtrCircle,
PlateRWedge,
PlateRTetrahedron,
DriverSeat = 150,
PassengerSeat, PassengerSeat,
PilotControls, Engine,
GrassCube, CarWheelWideProfile = 200,
DirtCube, CarWheel,
GrassConeSegment,
GrassCorner,
GrassRoundedCorner,
GrassSlicedCube,
GrassRoundedSlicedCube,
GrassPyramidSegment,
GrassSlope,
GrassRoundedSlope,
DirtConeSegment,
DirtCorner,
DirtRoundedCorner,
DirtSlicedCube,
DirtRoundedSlicedCube,
DirtPyramidSegment,
DirtSlope,
DirtRoundedSlope,
RubberHemisphere,
AluminiumHemisphere,
GrassInnerCornerBulged,
DirtInnerCornerBulged,
IronHemisphere,
OiledHemisphere,
GlassHemisphere,
TyreS,
ThreeWaySwitch,
Dial, //120
CharacterOnEnterTrigger, //Probably crashes
CharacterOnLeaveTrigger,
CharacterOnStayTrigger,
ObjectOnEnterTrigger,
ObjectOnLeaveTrigger,
ObjectOnStayTrigger,
Button,
Switch,
TextBlock, //Brings up a screen
ConsoleBlock, //Brings up a screen
Door,
GlassDoor,
PoweredDoor,
PoweredGlassDoor,
AluminiumTubeCorner,
IronTubeCorner,
WoodCube,
WoodSlicedCube,
WoodSlope,
WoodCorner,
WoodPyramidSegment,
WoodConeSegment,
WoodRoundedSlicedCube,
WoodRoundedSlope,
WoodRoundedCorner,
WoodCylinder,
WoodHemisphere,
WoodSphere,
BrickCube,
DampedAxleSpring, //150
BrickSlicedCube,
BrickSlope,
BrickCorner,
ConcreteCube,
ConcreteSlicedCube,
ConcreteSlope,
ConcreteCorner,
RoadCarTyre,
OffRoadCarTyre,
RacingCarTyre,
BicycleTyre,
FrontBikeTyre,
RearBikeTyre,
ChopperBikeTyre,
TractorTyre,
MonsterTruckTyre,
MotocrossBikeTyre,
CartTyre, //168
ObjectIdentifier,
ANDLogicBlock,
NANDLogicBlock,
NORLogicBlock,
NOTLogicBlock,
ORLogicBlock,
XNORLogicBlock,
XORLogicBlock,
AbsoluteMathsBlock,
AdderMathsBlock,
DividerMathsBlock,
SignMathsBlock, //180
MaxMathsBlock,
MinMathsBlock,
MultiplierMathsBlock,
SubtractorMathsBlock,
SimpleConnector,
MeanMathsBlock,
Bit,
Counter,
Timer,
ObjectFilter,
PlayerFilter,
TeamFilter,
Number2Text, //193
DestructionManager = 260,
ChunkHealthModifier,
ClusterHealthModifier, //262
BeachTree1 = 200,
BeachTree2,
BeachTree3,
Rock1,
Rock2,
Rock3,
Rock4,
BirchTree1,
BirchTree2,
BirchTree3,
PineTree1,
PineTree2,
PineTree3,
Flower1,
Flower2,
Flower3,
Shrub1,
Shrub2,
Shrub3,
CliffCube,
CliffSlicedCorner,
CliffCornerA,
CliffCornerB,
CliffSlopeA,
CliffSlopeB,
GrassEdge,
GrassEdgeInnerCorner,
GrassEdgeCorner,
GrassEdgeSlope,
CentreHUD,
ObjectiveHUD,
GameStatsHUD, //231
GameOverBlock,
SFXBlockGameplay = 240,
SFXBlock8Bit,
SFXBlockInstrument,
SFXBlockSciFi,
SFXBlockLoops,
SFXBlockVocal,
MovementConstrainer, //246
RotationConstrainer,
AdvancedMovementDampener,
AdvancedRotationDampener,
Mover = 250,
Rotator,
MovementDampener,
RotationDampener,
AdvancedMover,
AdvancedRotator,
MusicBlock, //256
PlasmaCannonBlock,
QuantumRiflePickup = 300,
QuantumRifleAmmoPickup,
AluminiumSlicedFraction,
AluminiumSlicedSlope,
AluminiumHalfPyramidLeft = 305,
AluminiumHalfPyramidRight,
AluminiumPyramidSliced,
AluminiumTubeCross,
AluminiumTubeT,
AluminiumPlateSquare,
AluminiumPlateCircle,
AluminiumPlateTriangle, //312
OiledSlicedFraction = 314,
OiledSlicedSlope,
OiledHalfPyramidLeft,
OiledHalfPyramidRight,
OiledPyramidSliced,
GlassSlicedFraction,
GlassSlicedSlope,
GlassHalfPyramidLeft,
GlassHalfPyramidRight,
GlassPyramidSliced,
RubberSlicedFraction,
RubberSlicedSlope,
RubberHalfPyramidLeft,
RubberHalfPyramidRight,
RubberPyramidSliced,
WoodSlicedFraction,
WoodSlicedSlope, //330
WoodHalfPyramidLeft,
WoodHalfPyramidRight,
WoodPyramidSliced,
HexNetSlicedFraction,
HexNetSlicedSlope,
HexNetHalfPyramidLeft,
HexNetHalfPyramidRight,
HexNetPyramidSliced,
OiledTubeCross,
OiledTubeT, //340
GlassTubeCross,
GlassTubeT,
RubberTubeCross,
RubberTubeT,
WoodTubeCross,
WoodTubeT,
HexNetTubeCross,
HexNetTubeT,
BouncyCube,
BouncySlicedCube, //350
BouncySlope,
BouncyCorner,
OiledTubeCorner,
GlassTubeCorner,
RubberTubeCorner,
WoodTubeCorner,
Basketball,
BowlingBall,
SoccerBall,
GolfBall, //360
HockeyPuck,
PoolBall,
BouncyBall,
TennisBall,
UnlitCube,
IronSlicedFraction,
IronSlicedSlope,
IronHalfPyramidLeft,
IronHalfPyramidRight,
IronPyramidSliced, //370
IronTubeCross,
IronTubeT,
SFXBlockMob = 374,
PointLight,
SpotLight,
SunLight,
AmbientLight,
UnlitGlowCube = 381,
PointLightInvisible,
SpotLightInvisible,
UnlitSlope,
UnlitGlowSlope,
Fog,
Sky,
GridCube,
GridSlicedCube,
GridSlope,
GridCorner,
MagmaRockCube = 777,
MagmaRockCubeSliced,
MagmaRockSlope,
MagmaRockCorner,
MagmaRockPyramidSegment,
MagmaRockConeSegment,
MagmaRockSlicedRounded,
MagmaRockSlopeRounded,
MagmaRockCornerRounded,
HexNetCube,
HexNetCubeSliced,
HexNetSlope,
HexNetCorner,
HexNetPyramidSegment,
HexNetConeSegment,
HexNetSlicedRounded,
HexNetSlopeRounded,
HexNetCornerRounded, //794
MagmaRockBulgedInner,
HexNetCylinder = 797,
HexNetHemisphere,
HexNetSphere,
HexNetTubeCorner, //800
CenterOfMassBlock = 1346
} }
} }

View file

@ -19,14 +19,14 @@ namespace GamecraftModdingAPI.Blocks
[APITestCase(TestType.EditMode)] [APITestCase(TestType.EditMode)]
public static void TestPlaceNew() public static void TestPlaceNew()
{ {
Block newBlock = Block.PlaceNew(BlockIDs.AluminiumCube, Unity.Mathematics.float3.zero); Block newBlock = Block.PlaceNew(BlockIDs.Cube, Unity.Mathematics.float3.zero);
Assert.NotNull(newBlock.Id, "Newly placed block is missing Id. This should be populated when the block is placed.", "Newly placed block Id is not null, block successfully placed."); Assert.NotNull(newBlock.Id, "Newly placed block is missing Id. This should be populated when the block is placed.", "Newly placed block Id is not null, block successfully placed.");
} }
[APITestCase(TestType.EditMode)] [APITestCase(TestType.EditMode)]
public static void TestInitProperty() public static void TestInitProperty()
{ {
Block newBlock = Block.PlaceNew(BlockIDs.AluminiumCube, Unity.Mathematics.float3.zero + 2); Block newBlock = Block.PlaceNew(BlockIDs.Cube, Unity.Mathematics.float3.zero + 2);
if (!Assert.CloseTo(newBlock.Position, (Unity.Mathematics.float3.zero + 2), $"Newly placed block at {newBlock.Position} is expected at {Unity.Mathematics.float3.zero + 2}.", "Newly placed block position matches.")) return; if (!Assert.CloseTo(newBlock.Position, (Unity.Mathematics.float3.zero + 2), $"Newly placed block at {newBlock.Position} is expected at {Unity.Mathematics.float3.zero + 2}.", "Newly placed block position matches.")) return;
//Assert.Equal(newBlock.Exists, true, "Newly placed block does not exist, possibly because Sync() skipped/missed/failed.", "Newly placed block exists, Sync() successful."); //Assert.Equal(newBlock.Exists, true, "Newly placed block does not exist, possibly because Sync() skipped/missed/failed.", "Newly placed block exists, Sync() successful.");
} }

View file

@ -18,6 +18,7 @@ using UnityEngine.AddressableAssets;
using Material = UnityEngine.Material; using Material = UnityEngine.Material;
using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Utility;
using ServiceLayer;
namespace GamecraftModdingAPI.Blocks namespace GamecraftModdingAPI.Blocks
{ {
@ -114,7 +115,7 @@ namespace GamecraftModdingAPI.Blocks
{ {
public static void Prefix(IDataDB dataDB) public static void Prefix(IDataDB dataDB)
{ {
//var abd = dataDB.GetValue<CubeListData>((int) BlockIDs.AluminiumCube); //var abd = dataDB.GetValue<CubeListData>((int) BlockIDs.Cube);
foreach (var (key, type) in CustomBlocks) foreach (var (key, type) in CustomBlocks)
{ {
var attr = type.GetCustomAttribute<CustomBlockAttribute>(); var attr = type.GetCustomAttribute<CustomBlockAttribute>();
@ -146,6 +147,12 @@ namespace GamecraftModdingAPI.Blocks
foreach (var (id, action) in BlockChangeActions) foreach (var (id, action) in BlockChangeActions)
action(dataDB.GetValue<CubeListData>(id)); action(dataDB.GetValue<CubeListData>(id));
/*foreach (var (key, value) in dataDB.GetValues<CubeListData>())
{
var data = (CubeListData) value;
Console.WriteLine($"ID: {key} - Name: {data.CubeNameKey}: {LocalizationService.Localize(data.CubeNameKey)}");
}*/
_canRegister = false; _canRegister = false;
} }

View file

@ -53,7 +53,7 @@ namespace GamecraftModdingAPI.Input
/// <param name="hotbarPage">Select the hotbar page by number?</param> /// <param name="hotbarPage">Select the hotbar page by number?</param>
/// <param name="quickSave">Quicksave?</param> /// <param name="quickSave">Quicksave?</param>
/// <param name="paste">Paste?</param> /// <param name="paste">Paste?</param>
public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool commandLine = false, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, bool colour = false, int hotbarPage = -1, bool quickSave = false, bool paste = false) public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, int hotbarPage = -1, bool quickSave = false, bool paste = false)
{ {
if (playerID == uint.MaxValue) if (playerID == uint.MaxValue)
{ {
@ -76,7 +76,6 @@ namespace GamecraftModdingAPI.Input
case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_9; break; case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_9; break;
default: break; default: break;
} }
//if (commandLine) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleCommandLine; - TODO
if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape; if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape;
if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return; if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return;
if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay; if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay;
@ -97,6 +96,7 @@ namespace GamecraftModdingAPI.Input
case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage10; break; case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage10; break;
default: break; default: break;
} }
//RewiredConsts.Action
if (quickSave) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.QuickSave; if (quickSave) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.QuickSave;
if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.PasteSelection; if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.PasteSelection;
} }
@ -118,8 +118,8 @@ namespace GamecraftModdingAPI.Input
if (left) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Left; if (left) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Left;
if (right) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Right; if (right) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Right;
if (sprint) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Sprint; if (sprint) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Sprint;
if (toggleFly) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SwitchFlyMode; //if (toggleFly) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SwitchFlyMode;
if (alt) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.AltAction; //if (alt) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.AltAction;
if (primary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.PrimaryAction; if (primary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.PrimaryAction;
if (secondary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SecondaryAction; if (secondary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SecondaryAction;
if (tertiary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.TertiaryAction; if (tertiary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.TertiaryAction;

View file

@ -91,7 +91,7 @@ namespace GamecraftModdingAPI
AsyncUtils.Init(); AsyncUtils.Init();
GamecraftModdingAPI.App.Client.Init(); GamecraftModdingAPI.App.Client.Init();
GamecraftModdingAPI.App.Game.Init(); GamecraftModdingAPI.App.Game.Init();
CustomBlock.Init(); //CustomBlock.Init();
// init UI // init UI
Interface.IMGUI.Constants.Init(); Interface.IMGUI.Constants.Init();
Interface.IMGUI.IMGUIManager.Init(); Interface.IMGUI.IMGUIManager.Init();

View file

@ -26,8 +26,11 @@ using GamecraftModdingAPI.Commands;
using GamecraftModdingAPI.Events; using GamecraftModdingAPI.Events;
using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Utility;
using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Input;
using GamecraftModdingAPI.Interface.IMGUI; using GamecraftModdingAPI.Interface.IMGUI;
using GamecraftModdingAPI.Players; using GamecraftModdingAPI.Players;
using RobocraftX.Common.Input;
using Svelto.DataStructures;
using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.AsyncOperations;
@ -171,7 +174,7 @@ namespace GamecraftModdingAPI.Tests
.Description("Place a block of aluminium at the given coordinates") .Description("Place a block of aluminium at the given coordinates")
.Action((float x, float y, float z) => .Action((float x, float y, float z) =>
{ {
var block = Block.PlaceNew(BlockIDs.AluminiumCube, new float3(x, y, z)); var block = Block.PlaceNew(BlockIDs.Cube, new float3(x, y, z));
Logging.CommandLog("Block placed with type: " + block.Type); Logging.CommandLog("Block placed with type: " + block.Type);
}) })
.Build(); .Build();
@ -185,7 +188,7 @@ namespace GamecraftModdingAPI.Tests
var sw = Stopwatch.StartNew(); var sw = Stopwatch.StartNew();
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++) for (int j = 0; j < 100; j++)
Block.PlaceNew(BlockIDs.AluminiumCube, new float3(x + i, y, z + j)); Block.PlaceNew(BlockIDs.Cube, new float3(x + i, y, z + j));
//Block.Sync(); //Block.Sync();
sw.Stop(); sw.Stop();
Logging.CommandLog("Finished in " + sw.ElapsedMilliseconds + "ms"); Logging.CommandLog("Finished in " + sw.ElapsedMilliseconds + "ms");
@ -264,7 +267,7 @@ namespace GamecraftModdingAPI.Tests
}) })
.Build();*/ .Build();*/
CommandBuilder.Builder() /*CommandBuilder.Builder()
.Name("WireTest") .Name("WireTest")
.Description("Place two blocks and then wire them together") .Description("Place two blocks and then wire them together")
.Action(() => .Action(() =>
@ -275,7 +278,7 @@ namespace GamecraftModdingAPI.Tests
Wire conn = notBlock.Connect(0, andBlock, 1); Wire conn = notBlock.Connect(0, andBlock, 1);
Logging.CommandLog(conn.ToString()); Logging.CommandLog(conn.ToString());
}) })
.Build(); .Build();*/
CommandBuilder.Builder("TestChunkHealth", "Sets the chunk looked at to the given health.") CommandBuilder.Builder("TestChunkHealth", "Sets the chunk looked at to the given health.")
.Action((float val, float max) => .Action((float val, float max) =>
@ -291,13 +294,13 @@ namespace GamecraftModdingAPI.Tests
.Action((float x, float y, float z) => .Action((float x, float y, float z) =>
{ {
var pos = new float3(x, y, z); var pos = new float3(x, y, z);
var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.AluminiumCube, pos, var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.Cube, pos,
color: BlockColors.Aqua)); color: BlockColors.Aqua));
Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Blue) Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Blue)
.BlockGroup = group; .BlockGroup = group;
Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Green) Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Green)
.BlockGroup = group; .BlockGroup = group;
Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Lime) Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Lime)
.BlockGroup = group; .BlockGroup = group;
}).Build(); }).Build();
@ -328,7 +331,7 @@ namespace GamecraftModdingAPI.Tests
} }
}, "MoveLastBlock", "Move the most-recently-placed block, and any connected blocks by the given offset")); }, "MoveLastBlock", "Move the most-recently-placed block, and any connected blocks by the given offset"));
CommandManager.AddCommand(new SimpleCustomCommandEngine<float, float, float>( CommandManager.AddCommand(new SimpleCustomCommandEngine<float, float, float>(
(x, y, z) => { Blocks.Placement.PlaceBlock(Blocks.BlockIDs.AluminiumCube, new Unity.Mathematics.float3(x, y, z)); }, (x, y, z) => { Blocks.Placement.PlaceBlock(Blocks.BlockIDs.Cube, new Unity.Mathematics.float3(x, y, z)); },
"PlaceAluminium", "Place a block of aluminium at the given coordinates")); "PlaceAluminium", "Place a block of aluminium at the given coordinates"));
System.Random random = new System.Random(); // for command below System.Random random = new System.Random(); // for command below
CommandManager.AddCommand(new SimpleCustomCommandEngine( CommandManager.AddCommand(new SimpleCustomCommandEngine(
@ -368,7 +371,7 @@ namespace GamecraftModdingAPI.Tests
Logging.Log("Compatible GamecraftScripting detected"); Logging.Log("Compatible GamecraftScripting detected");
} }
// Interface test // Interface test
Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true); /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true);
Interface.IMGUI.Button button = new Button("TEST"); Interface.IMGUI.Button button = new Button("TEST");
button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");};
Interface.IMGUI.Button button2 = new Button("TEST2"); Interface.IMGUI.Button button2 = new Button("TEST2");
@ -382,16 +385,16 @@ namespace GamecraftModdingAPI.Tests
uiGroup.AddElement(button2); uiGroup.AddElement(button2);
uiGroup.AddElement(uiText); uiGroup.AddElement(uiText);
uiGroup.AddElement(uiLabel); uiGroup.AddElement(uiLabel);
uiGroup.AddElement(uiImg); uiGroup.AddElement(uiImg);*/
Addressables.LoadAssetAsync<Texture2D>("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg") /*Addressables.LoadAssetAsync<Texture2D>("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg")
.Completed += .Completed +=
handle => handle =>
{ {
uiImg.Texture = handle.Result; uiImg.Texture = handle.Result;
uiImg.Enabled = true; uiImg.Enabled = true;
Logging.MetaDebugLog($"Got blue bg asset {handle.Result}"); Logging.MetaDebugLog($"Got blue bg asset {handle.Result}");
}; };*/
CommandBuilder.Builder("enableCompletions") CommandBuilder.Builder("enableCompletions")
@ -414,8 +417,11 @@ namespace GamecraftModdingAPI.Tests
Logging.MetaDebugLog("Test custom block catalog not found"); Logging.MetaDebugLog("Test custom block catalog not found");
} }
CustomBlock.ChangeExistingBlock((ushort) BlockIDs.TyreS, CustomBlock.ChangeExistingBlock((ushort) BlockIDs.CarWheel,
cld => cld.scalingPermission = ScalingPermission.NonUniform); cld => cld.scalingPermission = ScalingPermission.NonUniform);
/*((FasterList<GuiInputMap.GuiInputMapElement>)AccessTools.Property(typeof(GuiInputMap), "GuiInputsButtonDown").GetValue(null))
.Add(new GuiInputMap.GuiInputMapElement(RewiredConsts.Action.ToggleCommandLine, GuiIn))*/
#if TEST #if TEST
TestRoot.RunTests(); TestRoot.RunTests();
#endif #endif
@ -465,6 +471,12 @@ namespace GamecraftModdingAPI.Tests
} }
} }
public override void OnUpdate()
{
if(UnityEngine.Input.GetKeyDown(KeyCode.Backslash))
FakeInput.CustomInput(new LocalInputEntityStruct{commandLineToggleInput = true});
}
[HarmonyPatch] [HarmonyPatch]
public class MinimumSpecsPatch public class MinimumSpecsPatch
{ {