diff --git a/CodeGenerator/BlockClassGenerator.cs b/CodeGenerator/BlockClassGenerator.cs index 5a2e748..c2307a0 100644 --- a/CodeGenerator/BlockClassGenerator.cs +++ b/CodeGenerator/BlockClassGenerator.cs @@ -1,7 +1,11 @@ +using System; using System.CodeDom; using System.CodeDom.Compiler; +using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; +using Gamecraft.Tweaks; using RobocraftX.Common; using Svelto.ECS; using Techblox.EngineBlock; @@ -10,7 +14,7 @@ namespace CodeGenerator { public class BlockClassGenerator { - public void Generate(string name, string group) + public void Generate(string name, string group = null, Dictionary renames = null, params Type[] types) { if (group is null) { @@ -19,17 +23,25 @@ namespace CodeGenerator group = GetGroup(name) + "_BLOCK_BUILD_GROUP"; } + if (!group.Contains(".")) + group = "CommonExclusiveGroups." + group; + var codeUnit = new CodeCompileUnit(); var ns = new CodeNamespace("TechbloxModdingAPI.Blocks"); ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common")); ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS")); 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 { Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")}, - Comments = {new CodeCommentStatement($"{name} constructor", true)}, - BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")} + Comments = + { + _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 { @@ -37,23 +49,33 @@ namespace CodeGenerator { 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 = { new CodeObjectCreateExpression("EGID", new CodeVariableReferenceExpression("id"), - new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("CommonExclusiveGroups"), - group)) - } + new CodeVariableReferenceExpression(group)) + }, + Attributes = MemberAttributes.Public | MemberAttributes.Final }); - GenerateProperties(cl); + foreach (var type in types) + { + GenerateProperties(cl, type, name, renames); + } ns.Types.Add(cl); codeUnit.Namespaces.Add(ns); 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"}); } + + File.WriteAllLines(path, + File.ReadAllLines(path).SkipWhile(line => line.StartsWith("//") || line.Length == 0)); } private static string GetGroup(string name) @@ -70,12 +92,22 @@ namespace CodeGenerator return ret; } - private void GenerateProperties(CodeTypeDeclaration cl) where T : IEntityComponent + private void GenerateProperties(CodeTypeDeclaration cl, Type type, string baseClass, + Dictionary 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()) { - var propName = char.ToUpper(field.Name[0]) + field.Name.Substring(1); + var attr = field.GetCustomAttribute(); + 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( new CodeMethodReferenceExpression(new CodeSnippetExpression("BlockEngine"), "GetBlockInfo", new CodeTypeReference(type)), @@ -93,9 +125,18 @@ namespace CodeGenerator { 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("", true); + private static readonly CodeCommentStatement _end = new CodeCommentStatement("", true); } } \ No newline at end of file diff --git a/CodeGenerator/Program.cs b/CodeGenerator/Program.cs index 15a7e1c..0af44ab 100644 --- a/CodeGenerator/Program.cs +++ b/CodeGenerator/Program.cs @@ -1,6 +1,8 @@ -using System.CodeDom; -using System.CodeDom.Compiler; -using System.IO; +using System.Collections.Generic; +using RobocraftX.Blocks; +using RobocraftX.PilotSeat; +using Techblox.EngineBlock; +using Techblox.WheelRigBlock; namespace CodeGenerator { @@ -9,8 +11,31 @@ namespace CodeGenerator public static void Main(string[] args) { var bcg = new BlockClassGenerator(); - bcg.Generate("TestBlock", "TEST_BLOCK"); - bcg.Generate("Engine", null); + bcg.Generate("Engine", null, new Dictionary + { + { "engineOn", "On" } + }, typeof(EngineBlockComponent), // Simulation time properties + typeof(EngineBlockTweakableComponent), typeof(EngineBlockReadonlyComponent)); + bcg.Generate("DampedSpring", "DAMPEDSPRING_BLOCK_GROUP", new Dictionary + { + {"maxExtent", "MaxExtension"} + }, + typeof(TweakableJointDampingComponent), typeof(DampedSpringReadOnlyStruct)); + bcg.Generate("LogicGate", "LOGIC_BLOCK_GROUP"); + bcg.Generate("Servo", types: typeof(ServoReadOnlyStruct), renames: new Dictionary + { + {"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 + { + {"pistonVelocity", "MaximumForce"} + }, typeof(PistonReadOnlyStruct)); } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs index afff30b..9408f31 100644 --- a/TechbloxModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -1,47 +1,71 @@ -using RobocraftX.Blocks; -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { - public class DampedSpring : Block + using RobocraftX.Common; + using Svelto.ECS; + + + public class DampedSpring : SignalingBlock { - public DampedSpring(EGID id) : base(id) + + /// + /// Constructs a(n) DampedSpring object representing an existing block. + /// + public DampedSpring(EGID egid) : + base(egid) { } - - public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP)) + + /// + /// Constructs a(n) DampedSpring object representing an existing block. + /// + public DampedSpring(uint id) : + base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP)) { } - + /// - /// The spring's stiffness. + /// Gets or sets the DampedSpring's Stiffness property. Tweakable stat. /// public float Stiffness { - get => BlockEngine.GetBlockInfo(this).stiffness; - - set => BlockEngine.GetBlockInfo(this).stiffness = value; + get + { + return BlockEngine.GetBlockInfo(this).stiffness; + } + set + { + BlockEngine.GetBlockInfo(this).stiffness = value; + } } - + /// - /// The spring's maximum damping force. + /// Gets or sets the DampedSpring's Damping property. Tweakable stat. /// public float Damping { - get => BlockEngine.GetBlockInfo(this).damping; - - set => BlockEngine.GetBlockInfo(this).damping = value; + get + { + return BlockEngine.GetBlockInfo(this).damping; + } + set + { + BlockEngine.GetBlockInfo(this).damping = value; + } } - + /// - /// The spring's maximum extension. + /// Gets or sets the DampedSpring's MaxExtension property. Tweakable stat. /// public float MaxExtension { - get => BlockEngine.GetBlockInfo(this).maxExtent; - - set => BlockEngine.GetBlockInfo(this).maxExtent = value; + get + { + return BlockEngine.GetBlockInfo(this).maxExtent; + } + set + { + BlockEngine.GetBlockInfo(this).maxExtent = value; + } } } -} \ No newline at end of file +} diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index 05c09e6..bb87ba8 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -1,35 +1,32 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - namespace TechbloxModdingAPI.Blocks { using RobocraftX.Common; using Svelto.ECS; - public class Engine : Block + public class Engine : SignalingBlock { - /// Engine constructor - private Engine(EGID egid) : + /// + /// Constructs a(n) Engine object representing an existing block. + /// + public Engine(EGID egid) : base(egid) { } - /// Engine constructor - private Engine(uint id) : + /// + /// Constructs a(n) Engine object representing an existing block. + /// + public Engine(uint id) : base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP)) { } - private bool EngineOn + /// + /// Gets or sets the Engine's On property. May not be saved. + /// + public bool On { get { @@ -41,7 +38,10 @@ namespace TechbloxModdingAPI.Blocks } } - private int CurrentGear + /// + /// Gets or sets the Engine's CurrentGear property. May not be saved. + /// + public int CurrentGear { get { @@ -53,7 +53,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float GearChangeCountdown + /// + /// Gets or sets the Engine's GearChangeCountdown property. May not be saved. + /// + public float GearChangeCountdown { get { @@ -65,7 +68,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentRpmAV + /// + /// Gets or sets the Engine's CurrentRpmAV property. May not be saved. + /// + public float CurrentRpmAV { get { @@ -77,7 +83,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentRpmLV + /// + /// Gets or sets the Engine's CurrentRpmLV property. May not be saved. + /// + public float CurrentRpmLV { get { @@ -89,7 +98,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TargetRpmAV + /// + /// Gets or sets the Engine's TargetRpmAV property. May not be saved. + /// + public float TargetRpmAV { get { @@ -101,7 +113,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TargetRpmLV + /// + /// Gets or sets the Engine's TargetRpmLV property. May not be saved. + /// + public float TargetRpmLV { get { @@ -113,7 +128,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentTorque + /// + /// Gets or sets the Engine's CurrentTorque property. May not be saved. + /// + public float CurrentTorque { get { @@ -125,7 +143,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TotalWheelVelocityAV + /// + /// Gets or sets the Engine's TotalWheelVelocityAV property. May not be saved. + /// + public float TotalWheelVelocityAV { get { @@ -137,7 +158,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TotalWheelVelocityLV + /// + /// Gets or sets the Engine's TotalWheelVelocityLV property. May not be saved. + /// + public float TotalWheelVelocityLV { get { @@ -149,7 +173,10 @@ namespace TechbloxModdingAPI.Blocks } } - private int TotalWheelCount + /// + /// Gets or sets the Engine's TotalWheelCount property. May not be saved. + /// + public int TotalWheelCount { get { @@ -161,7 +188,10 @@ namespace TechbloxModdingAPI.Blocks } } - private bool LastGearUpInput + /// + /// Gets or sets the Engine's LastGearUpInput property. May not be saved. + /// + public bool LastGearUpInput { get { @@ -173,7 +203,10 @@ namespace TechbloxModdingAPI.Blocks } } - private bool LastGearDownInput + /// + /// Gets or sets the Engine's LastGearDownInput property. May not be saved. + /// + public bool LastGearDownInput { get { @@ -185,7 +218,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float ManualToAutoGearCoolOffCounter + /// + /// Gets or sets the Engine's ManualToAutoGearCoolOffCounter property. May not be saved. + /// + public float ManualToAutoGearCoolOffCounter { get { @@ -197,7 +233,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float Load + /// + /// Gets or sets the Engine's Load property. May not be saved. + /// + public float Load { get { @@ -208,5 +247,155 @@ namespace TechbloxModdingAPI.Blocks BlockEngine.GetBlockInfo(this).load = value; } } + + /// + /// Gets or sets the Engine's Power property. Tweakable stat. + /// + public float Power + { + get + { + return BlockEngine.GetBlockInfo(this).power; + } + set + { + BlockEngine.GetBlockInfo(this).power = value; + } + } + + /// + /// Gets or sets the Engine's AutomaticGears property. Tweakable stat. + /// + public bool AutomaticGears + { + get + { + return BlockEngine.GetBlockInfo(this).automaticGears; + } + set + { + BlockEngine.GetBlockInfo(this).automaticGears = value; + } + } + + /// + /// Gets or sets the Engine's GearChangeTime property. May not be saved. + /// + public float GearChangeTime + { + get + { + return BlockEngine.GetBlockInfo(this).gearChangeTime; + } + set + { + BlockEngine.GetBlockInfo(this).gearChangeTime = value; + } + } + + /// + /// Gets or sets the Engine's MinRpm property. May not be saved. + /// + public float MinRpm + { + get + { + return BlockEngine.GetBlockInfo(this).minRpm; + } + set + { + BlockEngine.GetBlockInfo(this).minRpm = value; + } + } + + /// + /// Gets or sets the Engine's MaxRpm property. May not be saved. + /// + public float MaxRpm + { + get + { + return BlockEngine.GetBlockInfo(this).maxRpm; + } + set + { + BlockEngine.GetBlockInfo(this).maxRpm = value; + } + } + + /// + /// Gets or sets the Engine's GearDownRpms property. May not be saved. + /// + public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms + { + get + { + return BlockEngine.GetBlockInfo(this).gearDownRpms; + } + set + { + BlockEngine.GetBlockInfo(this).gearDownRpms = value; + } + } + + /// + /// Gets or sets the Engine's GearUpRpm property. May not be saved. + /// + public float GearUpRpm + { + get + { + return BlockEngine.GetBlockInfo(this).gearUpRpm; + } + set + { + BlockEngine.GetBlockInfo(this).gearUpRpm = value; + } + } + + /// + /// Gets or sets the Engine's MaxRpmChange property. May not be saved. + /// + public float MaxRpmChange + { + get + { + return BlockEngine.GetBlockInfo(this).maxRpmChange; + } + set + { + BlockEngine.GetBlockInfo(this).maxRpmChange = value; + } + } + + /// + /// Gets or sets the Engine's ManualToAutoGearCoolOffTime property. May not be saved. + /// + public float ManualToAutoGearCoolOffTime + { + get + { + return BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffTime; + } + set + { + 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/LogicGate.cs b/TechbloxModdingAPI/Blocks/LogicGate.cs index 50a819c..05cc3bf 100644 --- a/TechbloxModdingAPI/Blocks/LogicGate.cs +++ b/TechbloxModdingAPI/Blocks/LogicGate.cs @@ -1,16 +1,26 @@ -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { + using RobocraftX.Common; + using Svelto.ECS; + + public class LogicGate : SignalingBlock { - public LogicGate(EGID id) : base(id) + + /// + /// Constructs a(n) LogicGate object representing an existing block. + /// + public LogicGate(EGID egid) : + base(egid) { } - - public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) + + /// + /// Constructs a(n) LogicGate object representing an existing block. + /// + public LogicGate(uint id) : + base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) { } } -} \ No newline at end of file +} diff --git a/TechbloxModdingAPI/Blocks/Piston.cs b/TechbloxModdingAPI/Blocks/Piston.cs index 22ee052..c351d59 100644 --- a/TechbloxModdingAPI/Blocks/Piston.cs +++ b/TechbloxModdingAPI/Blocks/Piston.cs @@ -1,49 +1,70 @@ -using System; - -using RobocraftX.Blocks; -using Svelto.ECS; -using Unity.Mathematics; - -using TechbloxModdingAPI.Utility; -using RobocraftX.Common; - namespace TechbloxModdingAPI.Blocks { - public class Piston : SignalingBlock + using RobocraftX.Common; + using Svelto.ECS; + + + public class Piston : SignalingBlock { - public Piston(EGID id) : base(id) + + /// + /// Constructs a(n) Piston object representing an existing block. + /// + public Piston(EGID egid) : + base(egid) { } - - public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) + + /// + /// Constructs a(n) Piston object representing an existing block. + /// + public Piston(uint id) : + base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) { } - - // custom piston properties - + /// - /// The piston's max extension distance. + /// Gets or sets the Piston's MaximumForce property. Tweakable stat. /// - public float MaximumExtension + public float MaximumForce { - get => BlockEngine.GetBlockInfo(this).maxDeviation; - - set - { - BlockEngine.GetBlockInfo(this).maxDeviation = value; - } - } - - /// - /// The piston's max extension force. + get + { + return BlockEngine.GetBlockInfo(this).pistonVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).pistonVelocity = value; + } + } + + /// + /// Gets or sets the Piston's MaxExtension property. Tweakable stat. /// - public float MaximumForce - { - get => BlockEngine.GetBlockInfo(this).pistonVelocity; - + public float MaxExtension + { + get + { + return BlockEngine.GetBlockInfo(this).maxDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } + } + + /// + /// Gets or sets the Piston's InputIsExtension property. Tweakable stat. + /// + public bool InputIsExtension + { + get + { + return BlockEngine.GetBlockInfo(this).hasProportionalInput; + } set { - BlockEngine.GetBlockInfo(this).pistonVelocity = value; + BlockEngine.GetBlockInfo(this).hasProportionalInput = value; } } } diff --git a/TechbloxModdingAPI/Blocks/Seat.cs b/TechbloxModdingAPI/Blocks/Seat.cs new file mode 100644 index 0000000..e06077f --- /dev/null +++ b/TechbloxModdingAPI/Blocks/Seat.cs @@ -0,0 +1,56 @@ +namespace TechbloxModdingAPI.Blocks +{ + using RobocraftX.Common; + using Svelto.ECS; + + + public class Seat : SignalingBlock + { + + /// + /// Constructs a(n) Seat object representing an existing block. + /// + public Seat(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) Seat object representing an existing block. + /// + public Seat(uint id) : + base(new EGID(id, RobocraftX.PilotSeat.SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP)) + { + } + + /// + /// Gets or sets the Seat's FollowCam property. Tweakable stat. + /// + public bool FollowCam + { + get + { + return BlockEngine.GetBlockInfo(this).followCam; + } + set + { + BlockEngine.GetBlockInfo(this).followCam = value; + } + } + + /// + /// Gets or sets the Seat's CharacterColliderHeight property. May not be saved. + /// + public float CharacterColliderHeight + { + get + { + return BlockEngine.GetBlockInfo(this).characterColliderHeight; + } + set + { + BlockEngine.GetBlockInfo(this).characterColliderHeight = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Blocks/Servo.cs b/TechbloxModdingAPI/Blocks/Servo.cs index 613ab65..89bd194 100644 --- a/TechbloxModdingAPI/Blocks/Servo.cs +++ b/TechbloxModdingAPI/Blocks/Servo.cs @@ -1,71 +1,146 @@ -using RobocraftX.Blocks; -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { - public class Servo : SignalingBlock + using RobocraftX.Common; + using Svelto.ECS; + + + public class Servo : SignalingBlock { - public Servo(EGID id) : base(id) + + /// + /// Constructs a(n) Servo object representing an existing block. + /// + public Servo(EGID egid) : + base(egid) { } - - public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) + + /// + /// Constructs a(n) Servo object representing an existing block. + /// + public Servo(uint id) : + base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) + { + } + + /// + /// Gets or sets the Servo's MaximumForce property. Tweakable stat. + /// + public float MaximumForce { + get + { + return BlockEngine.GetBlockInfo(this).servoVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).servoVelocity = value; + } } - - // custom servo properties - + /// - /// The servo's minimum angle. + /// Gets or sets the Servo's MinimumAngle property. Tweakable stat. /// public float MinimumAngle { - get => BlockEngine.GetBlockInfo(this).minDeviation; - - set - { - BlockEngine.GetBlockInfo(this).minDeviation = value; - } - } - - /// - /// The servo's maximum angle. + get + { + return BlockEngine.GetBlockInfo(this).minDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).minDeviation = value; + } + } + + /// + /// Gets or sets the Servo's MaximumAngle property. Tweakable stat. /// public float MaximumAngle { - get => BlockEngine.GetBlockInfo(this).maxDeviation; - - set - { - BlockEngine.GetBlockInfo(this).maxDeviation = value; - } + get + { + return BlockEngine.GetBlockInfo(this).maxDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } } - - /// - /// The servo's maximum force. + + /// + /// Gets or sets the Servo's Reverse property. Tweakable stat. /// - public float MaximumForce + public bool Reverse { - get => BlockEngine.GetBlockInfo(this).servoVelocity; - - set - { - BlockEngine.GetBlockInfo(this).servoVelocity = value; - } + get + { + return BlockEngine.GetBlockInfo(this).reverse; + } + set + { + BlockEngine.GetBlockInfo(this).reverse = value; + } } - - /// - /// The servo's direction. + + /// + /// Gets or sets the Servo's InputIsAngle property. Tweakable stat. /// - public bool Reverse + public bool InputIsAngle + { + get + { + return BlockEngine.GetBlockInfo(this).hasProportionalInput; + } + set + { + BlockEngine.GetBlockInfo(this).hasProportionalInput = value; + } + } + + /// + /// Gets or sets the Servo's DirectionVector property. May not be saved. + /// + public Unity.Mathematics.float3 DirectionVector + { + get + { + return BlockEngine.GetBlockInfo(this).directionVector; + } + set + { + BlockEngine.GetBlockInfo(this).directionVector = value; + } + } + + /// + /// Gets or sets the Servo's RotationAxis property. May not be saved. + /// + public Unity.Mathematics.float3 RotationAxis + { + get + { + return BlockEngine.GetBlockInfo(this).rotationAxis; + } + set + { + BlockEngine.GetBlockInfo(this).rotationAxis = value; + } + } + + /// + /// Gets or sets the Servo's ForceAxis property. May not be saved. + /// + public Unity.Mathematics.float3 ForceAxis { - get => BlockEngine.GetBlockInfo(this).reverse; - - set - { - BlockEngine.GetBlockInfo(this).reverse = value; - } + get + { + return BlockEngine.GetBlockInfo(this).forceAxis; + } + set + { + BlockEngine.GetBlockInfo(this).forceAxis = value; + } } } } diff --git a/TechbloxModdingAPI/Blocks/WheelRig.cs b/TechbloxModdingAPI/Blocks/WheelRig.cs new file mode 100644 index 0000000..1eb4c0b --- /dev/null +++ b/TechbloxModdingAPI/Blocks/WheelRig.cs @@ -0,0 +1,101 @@ +namespace TechbloxModdingAPI.Blocks +{ + using RobocraftX.Common; + using Svelto.ECS; + + + public class WheelRig : SignalingBlock + { + + /// + /// Constructs a(n) WheelRig object representing an existing block. + /// + public WheelRig(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) WheelRig object representing an existing block. + /// + public WheelRig(uint id) : + base(new EGID(id, CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP)) + { + } + + /// + /// Gets or sets the WheelRig's BrakingStrength property. Tweakable stat. + /// + public float BrakingStrength + { + get + { + return BlockEngine.GetBlockInfo(this).brakingStrength; + } + set + { + BlockEngine.GetBlockInfo(this).brakingStrength = value; + } + } + + /// + /// Gets or sets the WheelRig's MaxVelocity property. May not be saved. + /// + public float MaxVelocity + { + get + { + return BlockEngine.GetBlockInfo(this).maxVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).maxVelocity = value; + } + } + + /// + /// Gets or sets the WheelRig's SteerAngle property. Tweakable stat. + /// + public float SteerAngle + { + get + { + return BlockEngine.GetBlockInfo(this).steerAngle; + } + set + { + BlockEngine.GetBlockInfo(this).steerAngle = value; + } + } + + /// + /// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved. + /// + public float VelocityForMinAngle + { + get + { + return BlockEngine.GetBlockInfo(this).velocityForMinAngle; + } + set + { + BlockEngine.GetBlockInfo(this).velocityForMinAngle = value; + } + } + + /// + /// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved. + /// + public float MinSteerAngleFactor + { + get + { + return BlockEngine.GetBlockInfo(this).minSteerAngleFactor; + } + set + { + BlockEngine.GetBlockInfo(this).minSteerAngleFactor = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 2410f1b..79f7175 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using Svelto.DataStructures; using Svelto.ECS;