Add block types, run tests, remove unintended properties

This commit is contained in:
Norbi Peti 2021-08-12 00:34:39 +02:00
parent c0eae77421
commit 9693341d7a
3 changed files with 18 additions and 23 deletions

View file

@ -10,6 +10,7 @@ using RobocraftX.Blocks;
using Unity.Mathematics; using Unity.Mathematics;
using Gamecraft.Blocks.GUI; using Gamecraft.Blocks.GUI;
using HarmonyLib; using HarmonyLib;
using RobocraftX.PilotSeat;
using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Blocks.Engines; using TechbloxModdingAPI.Blocks.Engines;
@ -93,7 +94,13 @@ namespace TechbloxModdingAPI
new Dictionary<ExclusiveBuildGroup, (Func<EGID, Block>, Type)> new Dictionary<ExclusiveBuildGroup, (Func<EGID, Block>, Type)>
{ {
{CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP, (id => new DampedSpring(id), typeof(DampedSpring))}, {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) internal static Block New(EGID egid)
@ -340,6 +347,8 @@ namespace TechbloxModdingAPI
return; return;
} }
blockGroup?.RemoveInternal(this); blockGroup?.RemoveInternal(this);
if (!InitData.Valid)
return;
BlockEngine.GetBlockInfo<BlockGroupEntityComponent>(this).currentBlockGroup = (int?) value?.Id.entityID ?? -1; BlockEngine.GetBlockInfo<BlockGroupEntityComponent>(this).currentBlockGroup = (int?) value?.Id.entityID ?? -1;
value?.AddInternal(this); value?.AddInternal(this);
blockGroup = value; blockGroup = value;

View file

@ -324,17 +324,13 @@ namespace TechbloxModdingAPI.Blocks
} }
/// <summary> /// <summary>
/// Gets or sets the Engine's GearDownRpms property. May not be saved. /// Gets the Engine's GearDownRpms property. May not be saved.
/// </summary> /// </summary>
public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms public float[] GearDownRpms
{ {
get get
{ {
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearDownRpms; return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearDownRpms.ToManagedArray<float>();
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearDownRpms = value;
} }
} }
@ -382,20 +378,5 @@ namespace TechbloxModdingAPI.Blocks
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).manualToAutoGearCoolOffTime = value; BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).manualToAutoGearCoolOffTime = value;
} }
} }
/// <summary>
/// Gets or sets the Engine's EngineBlockDataId property. May not be saved.
/// </summary>
public int EngineBlockDataId
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).engineBlockDataId;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).engineBlockDataId = value;
}
}
} }
} }

View file

@ -1,3 +1,5 @@
using TechbloxModdingAPI.Tests;
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
using RobocraftX.Common; using RobocraftX.Common;
@ -56,6 +58,7 @@ namespace TechbloxModdingAPI.Blocks
/// <summary> /// <summary>
/// Gets or sets the WheelRig's SteerAngle property. Tweakable stat. /// Gets or sets the WheelRig's SteerAngle property. Tweakable stat.
/// </summary> /// </summary>
[TestValue(0f)] // Can be 0 for no steer variant
public float SteerAngle public float SteerAngle
{ {
get get
@ -71,6 +74,7 @@ namespace TechbloxModdingAPI.Blocks
/// <summary> /// <summary>
/// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved. /// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved.
/// </summary> /// </summary>
[TestValue(0f)]
public float VelocityForMinAngle public float VelocityForMinAngle
{ {
get get
@ -86,6 +90,7 @@ namespace TechbloxModdingAPI.Blocks
/// <summary> /// <summary>
/// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved. /// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved.
/// </summary> /// </summary>
[TestValue(0f)]
public float MinSteerAngleFactor public float MinSteerAngleFactor
{ {
get get