From 9693341d7ae370c84b2c58d9ad6121474403154e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 12 Aug 2021 00:34:39 +0200 Subject: [PATCH] Add block types, run tests, remove unintended properties --- TechbloxModdingAPI/Block.cs | 11 ++++++++++- TechbloxModdingAPI/Blocks/Engine.cs | 25 +++---------------------- TechbloxModdingAPI/Blocks/WheelRig.cs | 5 +++++ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index efea216..d4dead6 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -10,6 +10,7 @@ using RobocraftX.Blocks; using Unity.Mathematics; using Gamecraft.Blocks.GUI; using HarmonyLib; +using RobocraftX.PilotSeat; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Blocks.Engines; @@ -93,7 +94,13 @@ namespace TechbloxModdingAPI new Dictionary, Type)> { {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP, (id => new DampedSpring(id), typeof(DampedSpring))}, - {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))} + {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))}, + {CommonExclusiveGroups.LOGIC_BLOCK_GROUP, (id => new LogicGate(id), typeof(LogicGate))}, + {CommonExclusiveGroups.PISTON_BLOCK_GROUP, (id => new Piston(id), typeof(Piston))}, + {SeatGroups.PASSENGER_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, + {SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, + {CommonExclusiveGroups.SERVO_BLOCK_GROUP, (id => new Servo(id), typeof(Servo))}, + {CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP, (id => new WheelRig(id), typeof(WheelRig))} }; internal static Block New(EGID egid) @@ -340,6 +347,8 @@ namespace TechbloxModdingAPI return; } blockGroup?.RemoveInternal(this); + if (!InitData.Valid) + return; BlockEngine.GetBlockInfo(this).currentBlockGroup = (int?) value?.Id.entityID ?? -1; value?.AddInternal(this); blockGroup = value; diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index bb87ba8..6140b11 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -324,17 +324,13 @@ namespace TechbloxModdingAPI.Blocks } /// - /// Gets or sets the Engine's GearDownRpms property. May not be saved. + /// Gets the Engine's GearDownRpms property. May not be saved. /// - public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms + public float[] GearDownRpms { get { - return BlockEngine.GetBlockInfo(this).gearDownRpms; - } - set - { - BlockEngine.GetBlockInfo(this).gearDownRpms = value; + return BlockEngine.GetBlockInfo(this).gearDownRpms.ToManagedArray(); } } @@ -382,20 +378,5 @@ namespace TechbloxModdingAPI.Blocks BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffTime = value; } } - - /// - /// Gets or sets the Engine's EngineBlockDataId property. May not be saved. - /// - public int EngineBlockDataId - { - get - { - return BlockEngine.GetBlockInfo(this).engineBlockDataId; - } - set - { - BlockEngine.GetBlockInfo(this).engineBlockDataId = value; - } - } } } diff --git a/TechbloxModdingAPI/Blocks/WheelRig.cs b/TechbloxModdingAPI/Blocks/WheelRig.cs index 1eb4c0b..28ba739 100644 --- a/TechbloxModdingAPI/Blocks/WheelRig.cs +++ b/TechbloxModdingAPI/Blocks/WheelRig.cs @@ -1,3 +1,5 @@ +using TechbloxModdingAPI.Tests; + namespace TechbloxModdingAPI.Blocks { using RobocraftX.Common; @@ -56,6 +58,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's SteerAngle property. Tweakable stat. /// + [TestValue(0f)] // Can be 0 for no steer variant public float SteerAngle { get @@ -71,6 +74,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved. /// + [TestValue(0f)] public float VelocityForMinAngle { get @@ -86,6 +90,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved. /// + [TestValue(0f)] public float MinSteerAngleFactor { get