2020-05-21 19:04:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using RobocraftX.Blocks;
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
2020-07-10 22:30:58 +00:00
|
|
|
|
using RobocraftX.Common;
|
2020-05-21 19:04:55 +00:00
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
|
|
|
|
public class Piston : Block
|
|
|
|
|
{
|
2020-07-13 19:55:48 +00:00
|
|
|
|
public Piston(EGID id) : base(id)
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<PistonReadOnlyStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP))
|
2020-05-21 19:04:55 +00:00
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<PistonReadOnlyStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom piston properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The piston's max extension distance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float MaximumExtension
|
|
|
|
|
{
|
|
|
|
|
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(Id).maxDeviation;
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ref PistonReadOnlyStruct piston = ref BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(Id);
|
|
|
|
|
piston.maxDeviation = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The piston's max extension force.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float MaximumForce
|
|
|
|
|
{
|
|
|
|
|
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(Id).maxForce;
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ref PistonReadOnlyStruct piston = ref BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(Id);
|
|
|
|
|
piston.maxForce = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|