Finish code generator (mostly)

Made the generated members public and final
Removed the comment from the start of the files
Generating the files directly into the project folder
Added comments describing the generated constructors and properties
Using SignalingBlock as a base class
Added support for renaming properties
Added support for getting the name from the tweakable stat name
Added/updated functional block classes
This commit is contained in:
Norbi Peti 2021-08-11 23:44:26 +02:00
parent 3351993936
commit c0eae77421
10 changed files with 716 additions and 175 deletions

View file

@ -1,7 +1,11 @@
using System;
using System.CodeDom; using System.CodeDom;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using Gamecraft.Tweaks;
using RobocraftX.Common; using RobocraftX.Common;
using Svelto.ECS; using Svelto.ECS;
using Techblox.EngineBlock; using Techblox.EngineBlock;
@ -10,7 +14,7 @@ namespace CodeGenerator
{ {
public class BlockClassGenerator public class BlockClassGenerator
{ {
public void Generate(string name, string group) public void Generate(string name, string group = null, Dictionary<string, string> renames = null, params Type[] types)
{ {
if (group is null) if (group is null)
{ {
@ -19,17 +23,25 @@ namespace CodeGenerator
group = GetGroup(name) + "_BLOCK_BUILD_GROUP"; group = GetGroup(name) + "_BLOCK_BUILD_GROUP";
} }
if (!group.Contains("."))
group = "CommonExclusiveGroups." + group;
var codeUnit = new CodeCompileUnit(); var codeUnit = new CodeCompileUnit();
var ns = new CodeNamespace("TechbloxModdingAPI.Blocks"); var ns = new CodeNamespace("TechbloxModdingAPI.Blocks");
ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common")); ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common"));
ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS")); ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS"));
var cl = new CodeTypeDeclaration(name); var cl = new CodeTypeDeclaration(name);
cl.BaseTypes.Add(new CodeTypeReference("Block")); //cl.BaseTypes.Add(baseClass != null ? new CodeTypeReference(baseClass) : new CodeTypeReference("Block"));
cl.BaseTypes.Add(new CodeTypeReference("SignalingBlock"));
cl.Members.Add(new CodeConstructor cl.Members.Add(new CodeConstructor
{ {
Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")}, Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")},
Comments = {new CodeCommentStatement($"{name} constructor", true)}, Comments =
BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")} {
_start, new CodeCommentStatement($"Constructs a(n) {name} object representing an existing block.", true), _end
},
BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")},
Attributes = MemberAttributes.Public | MemberAttributes.Final
}); });
cl.Members.Add(new CodeConstructor cl.Members.Add(new CodeConstructor
{ {
@ -37,23 +49,33 @@ namespace CodeGenerator
{ {
new CodeParameterDeclarationExpression(typeof(uint), "id") new CodeParameterDeclarationExpression(typeof(uint), "id")
}, },
Comments = {new CodeCommentStatement($"{name} constructor", true)}, Comments =
{
_start, new CodeCommentStatement($"Constructs a(n) {name} object representing an existing block.", true), _end
},
BaseConstructorArgs = BaseConstructorArgs =
{ {
new CodeObjectCreateExpression("EGID", new CodeVariableReferenceExpression("id"), new CodeObjectCreateExpression("EGID", new CodeVariableReferenceExpression("id"),
new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("CommonExclusiveGroups"), new CodeVariableReferenceExpression(group))
group)) },
} Attributes = MemberAttributes.Public | MemberAttributes.Final
}); });
GenerateProperties<EngineBlockComponent>(cl); foreach (var type in types)
{
GenerateProperties(cl, type, name, renames);
}
ns.Types.Add(cl); ns.Types.Add(cl);
codeUnit.Namespaces.Add(ns); codeUnit.Namespaces.Add(ns);
var provider = CodeDomProvider.CreateProvider("CSharp"); var provider = CodeDomProvider.CreateProvider("CSharp");
using (var sw = new StreamWriter($"{name}.cs")) var path = $@"..\..\..\TechbloxModdingAPI\Blocks\{name}.cs";
using (var sw = new StreamWriter(path))
{ {
provider.GenerateCodeFromCompileUnit(codeUnit, sw, new CodeGeneratorOptions {BracingStyle = "C"}); provider.GenerateCodeFromCompileUnit(codeUnit, sw, new CodeGeneratorOptions {BracingStyle = "C"});
} }
File.WriteAllLines(path,
File.ReadAllLines(path).SkipWhile(line => line.StartsWith("//") || line.Length == 0));
} }
private static string GetGroup(string name) private static string GetGroup(string name)
@ -70,12 +92,22 @@ namespace CodeGenerator
return ret; return ret;
} }
private void GenerateProperties<T>(CodeTypeDeclaration cl) where T : IEntityComponent private void GenerateProperties(CodeTypeDeclaration cl, Type type, string baseClass,
Dictionary<string, string> renames)
{ {
var type = typeof(T); if (!typeof(IEntityComponent).IsAssignableFrom(type))
throw new ArgumentException("Type must be an entity component");
foreach (var field in type.GetFields()) foreach (var field in type.GetFields())
{ {
var propName = char.ToUpper(field.Name[0]) + field.Name.Substring(1); var attr = field.GetCustomAttribute<TweakableStatAttribute>();
if (renames == null || !renames.TryGetValue(field.Name, out var propName))
{
propName = field.Name;
if (attr != null)
propName = attr.propertyName;
}
propName = char.ToUpper(propName[0]) + propName.Substring(1);
var structFieldReference = new CodeFieldReferenceExpression(new CodeMethodInvokeExpression( var structFieldReference = new CodeFieldReferenceExpression(new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(new CodeSnippetExpression("BlockEngine"), new CodeMethodReferenceExpression(new CodeSnippetExpression("BlockEngine"),
"GetBlockInfo", new CodeTypeReference(type)), "GetBlockInfo", new CodeTypeReference(type)),
@ -93,9 +125,18 @@ namespace CodeGenerator
{ {
new CodeAssignStatement(structFieldReference, new CodePropertySetValueReferenceExpression()) new CodeAssignStatement(structFieldReference, new CodePropertySetValueReferenceExpression())
}, },
Type = new CodeTypeReference(field.FieldType) Type = new CodeTypeReference(field.FieldType),
Attributes = MemberAttributes.Public | MemberAttributes.Final,
Comments =
{
_start, new CodeCommentStatement($"Gets or sets the {baseClass}'s {propName} property." +
$" {(attr != null ? "Tweakable stat." : "May not be saved.")}", true), _end
}
}); });
} }
} }
private static readonly CodeCommentStatement _start = new CodeCommentStatement("<summary>", true);
private static readonly CodeCommentStatement _end = new CodeCommentStatement("</summary>", true);
} }
} }

View file

@ -1,6 +1,8 @@
using System.CodeDom; using System.Collections.Generic;
using System.CodeDom.Compiler; using RobocraftX.Blocks;
using System.IO; using RobocraftX.PilotSeat;
using Techblox.EngineBlock;
using Techblox.WheelRigBlock;
namespace CodeGenerator namespace CodeGenerator
{ {
@ -9,8 +11,31 @@ namespace CodeGenerator
public static void Main(string[] args) public static void Main(string[] args)
{ {
var bcg = new BlockClassGenerator(); var bcg = new BlockClassGenerator();
bcg.Generate("TestBlock", "TEST_BLOCK"); bcg.Generate("Engine", null, new Dictionary<string, string>
bcg.Generate("Engine", null); {
{ "engineOn", "On" }
}, typeof(EngineBlockComponent), // Simulation time properties
typeof(EngineBlockTweakableComponent), typeof(EngineBlockReadonlyComponent));
bcg.Generate("DampedSpring", "DAMPEDSPRING_BLOCK_GROUP", new Dictionary<string, string>
{
{"maxExtent", "MaxExtension"}
},
typeof(TweakableJointDampingComponent), typeof(DampedSpringReadOnlyStruct));
bcg.Generate("LogicGate", "LOGIC_BLOCK_GROUP");
bcg.Generate("Servo", types: typeof(ServoReadOnlyStruct), renames: new Dictionary<string, string>
{
{"minDeviation", "MinimumAngle"},
{"maxDeviation", "MaximumAngle"},
{"servoVelocity", "MaximumForce"}
});
bcg.Generate("WheelRig", "WHEELRIG_BLOCK_BUILD_GROUP", null,
typeof(WheelRigTweakableStruct), typeof(WheelRigReadOnlyStruct),
typeof(WheelRigSteerableTweakableStruct), typeof(WheelRigSteerableReadOnlyStruct));
bcg.Generate("Seat", "RobocraftX.PilotSeat.SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP", null, typeof(SeatFollowCamComponent), typeof(SeatReadOnlySettingsComponent));
bcg.Generate("Piston", null, new Dictionary<string, string>
{
{"pistonVelocity", "MaximumForce"}
}, typeof(PistonReadOnlyStruct));
} }
} }
} }

View file

@ -1,47 +1,71 @@
using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
public class DampedSpring : Block using RobocraftX.Common;
{ using Svelto.ECS;
public DampedSpring(EGID id) : base(id)
{
}
public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP))
public class DampedSpring : SignalingBlock
{
/// <summary>
/// Constructs a(n) DampedSpring object representing an existing block.
/// </summary>
public DampedSpring(EGID egid) :
base(egid)
{ {
} }
/// <summary> /// <summary>
/// The spring's stiffness. /// Constructs a(n) DampedSpring object representing an existing block.
/// </summary>
public DampedSpring(uint id) :
base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP))
{
}
/// <summary>
/// Gets or sets the DampedSpring's Stiffness property. Tweakable stat.
/// </summary> /// </summary>
public float Stiffness public float Stiffness
{ {
get => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).stiffness; get
{
set => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).stiffness = value; return BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).stiffness;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).stiffness = value;
}
} }
/// <summary> /// <summary>
/// The spring's maximum damping force. /// Gets or sets the DampedSpring's Damping property. Tweakable stat.
/// </summary> /// </summary>
public float Damping public float Damping
{ {
get => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).damping; get
{
set => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).damping = value; return BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).damping;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).damping = value;
}
} }
/// <summary> /// <summary>
/// The spring's maximum extension. /// Gets or sets the DampedSpring's MaxExtension property. Tweakable stat.
/// </summary> /// </summary>
public float MaxExtension public float MaxExtension
{ {
get => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).maxExtent; get
{
set => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).maxExtent = value; return BlockEngine.GetBlockInfo<RobocraftX.Blocks.DampedSpringReadOnlyStruct>(this).maxExtent;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.DampedSpringReadOnlyStruct>(this).maxExtent = value;
}
} }
} }
} }

View file

@ -1,35 +1,32 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Ezt a kódot eszköz generálta.
// Futásidejű verzió:4.0.30319.42000
//
// Ennek a fájlnak a módosítása helytelen viselkedést eredményezhet, és elvész, ha
// a kódot újragenerálják.
// </auto-generated>
//------------------------------------------------------------------------------
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
using RobocraftX.Common; using RobocraftX.Common;
using Svelto.ECS; using Svelto.ECS;
public class Engine : Block public class Engine : SignalingBlock
{ {
/// Engine constructor /// <summary>
private Engine(EGID egid) : /// Constructs a(n) Engine object representing an existing block.
/// </summary>
public Engine(EGID egid) :
base(egid) base(egid)
{ {
} }
/// Engine constructor /// <summary>
private Engine(uint id) : /// Constructs a(n) Engine object representing an existing block.
/// </summary>
public Engine(uint id) :
base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP)) base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP))
{ {
} }
private bool EngineOn /// <summary>
/// Gets or sets the Engine's On property. May not be saved.
/// </summary>
public bool On
{ {
get get
{ {
@ -41,7 +38,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private int CurrentGear /// <summary>
/// Gets or sets the Engine's CurrentGear property. May not be saved.
/// </summary>
public int CurrentGear
{ {
get get
{ {
@ -53,7 +53,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float GearChangeCountdown /// <summary>
/// Gets or sets the Engine's GearChangeCountdown property. May not be saved.
/// </summary>
public float GearChangeCountdown
{ {
get get
{ {
@ -65,7 +68,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float CurrentRpmAV /// <summary>
/// Gets or sets the Engine's CurrentRpmAV property. May not be saved.
/// </summary>
public float CurrentRpmAV
{ {
get get
{ {
@ -77,7 +83,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float CurrentRpmLV /// <summary>
/// Gets or sets the Engine's CurrentRpmLV property. May not be saved.
/// </summary>
public float CurrentRpmLV
{ {
get get
{ {
@ -89,7 +98,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float TargetRpmAV /// <summary>
/// Gets or sets the Engine's TargetRpmAV property. May not be saved.
/// </summary>
public float TargetRpmAV
{ {
get get
{ {
@ -101,7 +113,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float TargetRpmLV /// <summary>
/// Gets or sets the Engine's TargetRpmLV property. May not be saved.
/// </summary>
public float TargetRpmLV
{ {
get get
{ {
@ -113,7 +128,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float CurrentTorque /// <summary>
/// Gets or sets the Engine's CurrentTorque property. May not be saved.
/// </summary>
public float CurrentTorque
{ {
get get
{ {
@ -125,7 +143,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float TotalWheelVelocityAV /// <summary>
/// Gets or sets the Engine's TotalWheelVelocityAV property. May not be saved.
/// </summary>
public float TotalWheelVelocityAV
{ {
get get
{ {
@ -137,7 +158,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float TotalWheelVelocityLV /// <summary>
/// Gets or sets the Engine's TotalWheelVelocityLV property. May not be saved.
/// </summary>
public float TotalWheelVelocityLV
{ {
get get
{ {
@ -149,7 +173,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private int TotalWheelCount /// <summary>
/// Gets or sets the Engine's TotalWheelCount property. May not be saved.
/// </summary>
public int TotalWheelCount
{ {
get get
{ {
@ -161,7 +188,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private bool LastGearUpInput /// <summary>
/// Gets or sets the Engine's LastGearUpInput property. May not be saved.
/// </summary>
public bool LastGearUpInput
{ {
get get
{ {
@ -173,7 +203,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private bool LastGearDownInput /// <summary>
/// Gets or sets the Engine's LastGearDownInput property. May not be saved.
/// </summary>
public bool LastGearDownInput
{ {
get get
{ {
@ -185,7 +218,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float ManualToAutoGearCoolOffCounter /// <summary>
/// Gets or sets the Engine's ManualToAutoGearCoolOffCounter property. May not be saved.
/// </summary>
public float ManualToAutoGearCoolOffCounter
{ {
get get
{ {
@ -197,7 +233,10 @@ namespace TechbloxModdingAPI.Blocks
} }
} }
private float Load /// <summary>
/// Gets or sets the Engine's Load property. May not be saved.
/// </summary>
public float Load
{ {
get get
{ {
@ -208,5 +247,155 @@ namespace TechbloxModdingAPI.Blocks
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).load = value; BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockComponent>(this).load = value;
} }
} }
/// <summary>
/// Gets or sets the Engine's Power property. Tweakable stat.
/// </summary>
public float Power
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockTweakableComponent>(this).power;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockTweakableComponent>(this).power = value;
}
}
/// <summary>
/// Gets or sets the Engine's AutomaticGears property. Tweakable stat.
/// </summary>
public bool AutomaticGears
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockTweakableComponent>(this).automaticGears;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockTweakableComponent>(this).automaticGears = value;
}
}
/// <summary>
/// Gets or sets the Engine's GearChangeTime property. May not be saved.
/// </summary>
public float GearChangeTime
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearChangeTime;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearChangeTime = value;
}
}
/// <summary>
/// Gets or sets the Engine's MinRpm property. May not be saved.
/// </summary>
public float MinRpm
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).minRpm;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).minRpm = value;
}
}
/// <summary>
/// Gets or sets the Engine's MaxRpm property. May not be saved.
/// </summary>
public float MaxRpm
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).maxRpm;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).maxRpm = value;
}
}
/// <summary>
/// Gets or sets the Engine's GearDownRpms property. May not be saved.
/// </summary>
public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearDownRpms;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearDownRpms = value;
}
}
/// <summary>
/// Gets or sets the Engine's GearUpRpm property. May not be saved.
/// </summary>
public float GearUpRpm
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearUpRpm;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).gearUpRpm = value;
}
}
/// <summary>
/// Gets or sets the Engine's MaxRpmChange property. May not be saved.
/// </summary>
public float MaxRpmChange
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).maxRpmChange;
}
set
{
BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).maxRpmChange = value;
}
}
/// <summary>
/// Gets or sets the Engine's ManualToAutoGearCoolOffTime property. May not be saved.
/// </summary>
public float ManualToAutoGearCoolOffTime
{
get
{
return BlockEngine.GetBlockInfo<Techblox.EngineBlock.EngineBlockReadonlyComponent>(this).manualToAutoGearCoolOffTime;
}
set
{
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,15 +1,25 @@
using RobocraftX.Common;
using Svelto.ECS;
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
using RobocraftX.Common;
using Svelto.ECS;
public class LogicGate : SignalingBlock public class LogicGate : SignalingBlock
{ {
public LogicGate(EGID id) : base(id)
/// <summary>
/// Constructs a(n) LogicGate object representing an existing block.
/// </summary>
public LogicGate(EGID egid) :
base(egid)
{ {
} }
public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) /// <summary>
/// Constructs a(n) LogicGate object representing an existing block.
/// </summary>
public LogicGate(uint id) :
base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP))
{ {
} }
} }

View file

@ -1,49 +1,70 @@
using System;
using RobocraftX.Blocks;
using Svelto.ECS;
using Unity.Mathematics;
using TechbloxModdingAPI.Utility;
using RobocraftX.Common;
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
public class Piston : SignalingBlock using RobocraftX.Common;
using Svelto.ECS;
public class Piston : SignalingBlock
{ {
public Piston(EGID id) : base(id)
{
}
public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP))
{
}
// custom piston properties
/// <summary> /// <summary>
/// The piston's max extension distance. /// Constructs a(n) Piston object representing an existing block.
/// </summary> /// </summary>
public float MaximumExtension public Piston(EGID egid) :
base(egid)
{ {
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation; }
set /// <summary>
{ /// Constructs a(n) Piston object representing an existing block.
BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation = value; /// </summary>
} public Piston(uint id) :
} base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP))
{
}
/// <summary> /// <summary>
/// The piston's max extension force. /// Gets or sets the Piston's MaximumForce property. Tweakable stat.
/// </summary> /// </summary>
public float MaximumForce public float MaximumForce
{ {
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).pistonVelocity; get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).pistonVelocity;
}
set set
{ {
BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).pistonVelocity = value; BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).pistonVelocity = value;
}
}
/// <summary>
/// Gets or sets the Piston's MaxExtension property. Tweakable stat.
/// </summary>
public float MaxExtension
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).maxDeviation;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).maxDeviation = value;
}
}
/// <summary>
/// Gets or sets the Piston's InputIsExtension property. Tweakable stat.
/// </summary>
public bool InputIsExtension
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).hasProportionalInput;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).hasProportionalInput = value;
} }
} }
} }

View file

@ -0,0 +1,56 @@
namespace TechbloxModdingAPI.Blocks
{
using RobocraftX.Common;
using Svelto.ECS;
public class Seat : SignalingBlock
{
/// <summary>
/// Constructs a(n) Seat object representing an existing block.
/// </summary>
public Seat(EGID egid) :
base(egid)
{
}
/// <summary>
/// Constructs a(n) Seat object representing an existing block.
/// </summary>
public Seat(uint id) :
base(new EGID(id, RobocraftX.PilotSeat.SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP))
{
}
/// <summary>
/// Gets or sets the Seat's FollowCam property. Tweakable stat.
/// </summary>
public bool FollowCam
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.PilotSeat.SeatFollowCamComponent>(this).followCam;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.PilotSeat.SeatFollowCamComponent>(this).followCam = value;
}
}
/// <summary>
/// Gets or sets the Seat's CharacterColliderHeight property. May not be saved.
/// </summary>
public float CharacterColliderHeight
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.PilotSeat.SeatReadOnlySettingsComponent>(this).characterColliderHeight;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.PilotSeat.SeatReadOnlySettingsComponent>(this).characterColliderHeight = value;
}
}
}
}

View file

@ -1,71 +1,146 @@
using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;
namespace TechbloxModdingAPI.Blocks namespace TechbloxModdingAPI.Blocks
{ {
public class Servo : SignalingBlock using RobocraftX.Common;
using Svelto.ECS;
public class Servo : SignalingBlock
{ {
public Servo(EGID id) : base(id)
{
}
public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP))
{
}
// custom servo properties
/// <summary> /// <summary>
/// The servo's minimum angle. /// Constructs a(n) Servo object representing an existing block.
/// </summary> /// </summary>
public float MinimumAngle public Servo(EGID egid) :
base(egid)
{ {
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation;
set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation = value;
}
}
/// <summary>
/// The servo's maximum angle.
/// </summary>
public float MaximumAngle
{
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation;
set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation = value;
}
} }
/// <summary> /// <summary>
/// The servo's maximum force. /// Constructs a(n) Servo object representing an existing block.
/// </summary>
public Servo(uint id) :
base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP))
{
}
/// <summary>
/// Gets or sets the Servo's MaximumForce property. Tweakable stat.
/// </summary> /// </summary>
public float MaximumForce public float MaximumForce
{ {
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity; get
{
set return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).servoVelocity;
{ }
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity = value; set
} {
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).servoVelocity = value;
}
} }
/// <summary> /// <summary>
/// The servo's direction. /// Gets or sets the Servo's MinimumAngle property. Tweakable stat.
/// </summary>
public float MinimumAngle
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).minDeviation;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).minDeviation = value;
}
}
/// <summary>
/// Gets or sets the Servo's MaximumAngle property. Tweakable stat.
/// </summary>
public float MaximumAngle
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).maxDeviation;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).maxDeviation = value;
}
}
/// <summary>
/// Gets or sets the Servo's Reverse property. Tweakable stat.
/// </summary> /// </summary>
public bool Reverse public bool Reverse
{ {
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse; get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).reverse;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).reverse = value;
}
}
set /// <summary>
{ /// Gets or sets the Servo's InputIsAngle property. Tweakable stat.
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse = value; /// </summary>
} public bool InputIsAngle
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).hasProportionalInput;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).hasProportionalInput = value;
}
}
/// <summary>
/// Gets or sets the Servo's DirectionVector property. May not be saved.
/// </summary>
public Unity.Mathematics.float3 DirectionVector
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).directionVector;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).directionVector = value;
}
}
/// <summary>
/// Gets or sets the Servo's RotationAxis property. May not be saved.
/// </summary>
public Unity.Mathematics.float3 RotationAxis
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).rotationAxis;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).rotationAxis = value;
}
}
/// <summary>
/// Gets or sets the Servo's ForceAxis property. May not be saved.
/// </summary>
public Unity.Mathematics.float3 ForceAxis
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).forceAxis;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).forceAxis = value;
}
} }
} }
} }

View file

@ -0,0 +1,101 @@
namespace TechbloxModdingAPI.Blocks
{
using RobocraftX.Common;
using Svelto.ECS;
public class WheelRig : SignalingBlock
{
/// <summary>
/// Constructs a(n) WheelRig object representing an existing block.
/// </summary>
public WheelRig(EGID egid) :
base(egid)
{
}
/// <summary>
/// Constructs a(n) WheelRig object representing an existing block.
/// </summary>
public WheelRig(uint id) :
base(new EGID(id, CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP))
{
}
/// <summary>
/// Gets or sets the WheelRig's BrakingStrength property. Tweakable stat.
/// </summary>
public float BrakingStrength
{
get
{
return BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigTweakableStruct>(this).brakingStrength;
}
set
{
BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigTweakableStruct>(this).brakingStrength = value;
}
}
/// <summary>
/// Gets or sets the WheelRig's MaxVelocity property. May not be saved.
/// </summary>
public float MaxVelocity
{
get
{
return BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigReadOnlyStruct>(this).maxVelocity;
}
set
{
BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigReadOnlyStruct>(this).maxVelocity = value;
}
}
/// <summary>
/// Gets or sets the WheelRig's SteerAngle property. Tweakable stat.
/// </summary>
public float SteerAngle
{
get
{
return BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableTweakableStruct>(this).steerAngle;
}
set
{
BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableTweakableStruct>(this).steerAngle = value;
}
}
/// <summary>
/// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved.
/// </summary>
public float VelocityForMinAngle
{
get
{
return BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableReadOnlyStruct>(this).velocityForMinAngle;
}
set
{
BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableReadOnlyStruct>(this).velocityForMinAngle = value;
}
}
/// <summary>
/// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved.
/// </summary>
public float MinSteerAngleFactor
{
get
{
return BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableReadOnlyStruct>(this).minSteerAngleFactor;
}
set
{
BlockEngine.GetBlockInfo<Techblox.WheelRigBlock.WheelRigSteerableReadOnlyStruct>(this).minSteerAngleFactor = value;
}
}
}
}

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Runtime.InteropServices;
using Svelto.DataStructures; using Svelto.DataStructures;
using Svelto.ECS; using Svelto.ECS;