TechbloxModdingAPI/GamecraftModdingAPI/Blocks/Piston.cs
NorbiPeti 7336fe8353 Add support for initializing blocks with properties
Newly created blocks use the initializer to set properties, allowing the user to set per-block properties
2020-07-24 11:11:52 -04:00

51 lines
1.2 KiB
C#

using System;
using RobocraftX.Blocks;
using Svelto.ECS;
using Unity.Mathematics;
using GamecraftModdingAPI.Utility;
using RobocraftX.Common;
namespace GamecraftModdingAPI.Blocks
{
public class Piston : Block
{
public Piston(EGID id) : base(id)
{
}
public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP))
{
}
// custom piston properties
/// <summary>
/// The piston's max extension distance.
/// </summary>
public float MaximumExtension
{
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxDeviation);
set
{
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxDeviation = val,
value);
}
}
/// <summary>
/// The piston's max extension force.
/// </summary>
public float MaximumForce
{
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxForce);
set
{
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxForce = val, value);
}
}
}
}