Browse Source

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
tags/v2.1.0
NorbiPeti 2 years ago
parent
commit
c0eae77421
10 changed files with 703 additions and 162 deletions
  1. +55
    -14
      CodeGenerator/BlockClassGenerator.cs
  2. +30
    -5
      CodeGenerator/Program.cs
  3. +48
    -24
      TechbloxModdingAPI/Blocks/DampedSpring.cs
  4. +219
    -30
      TechbloxModdingAPI/Blocks/Engine.cs
  5. +17
    -7
      TechbloxModdingAPI/Blocks/LogicGate.cs
  6. +54
    -33
      TechbloxModdingAPI/Blocks/Piston.cs
  7. +56
    -0
      TechbloxModdingAPI/Blocks/Seat.cs
  8. +123
    -48
      TechbloxModdingAPI/Blocks/Servo.cs
  9. +101
    -0
      TechbloxModdingAPI/Blocks/WheelRig.cs
  10. +0
    -1
      TechbloxModdingAPI/Utility/OptionalRef.cs

+ 55
- 14
CodeGenerator/BlockClassGenerator.cs View File

@@ -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<string, string> 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<EngineBlockComponent>(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<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())
{
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(
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("<summary>", true);
private static readonly CodeCommentStatement _end = new CodeCommentStatement("</summary>", true);
}
}

+ 30
- 5
CodeGenerator/Program.cs View File

@@ -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<string, string>
{
{ "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));
}
}
}

+ 48
- 24
TechbloxModdingAPI/Blocks/DampedSpring.cs View File

@@ -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)
/// <summary>
/// Constructs a(n) DampedSpring object representing an existing block.
/// </summary>
public DampedSpring(EGID egid) :
base(egid)
{
}

public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP))
/// <summary>
/// Constructs a(n) DampedSpring object representing an existing block.
/// </summary>
public DampedSpring(uint id) :
base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP))
{
}

/// <summary>
/// The spring's stiffness.
/// Gets or sets the DampedSpring's Stiffness property. Tweakable stat.
/// </summary>
public float Stiffness
{
get => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).stiffness;

set => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).stiffness = value;
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).stiffness;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).stiffness = value;
}
}

/// <summary>
/// The spring's maximum damping force.
/// Gets or sets the DampedSpring's Damping property. Tweakable stat.
/// </summary>
public float Damping
{
get => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).damping;

set => BlockEngine.GetBlockInfo<TweakableJointDampingComponent>(this).damping = value;
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).damping;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.TweakableJointDampingComponent>(this).damping = value;
}
}

/// <summary>
/// The spring's maximum extension.
/// Gets or sets the DampedSpring's MaxExtension property. Tweakable stat.
/// </summary>
public float MaxExtension
{
get => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).maxExtent;

set => BlockEngine.GetBlockInfo<DampedSpringReadOnlyStruct>(this).maxExtent = value;
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.DampedSpringReadOnlyStruct>(this).maxExtent;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.DampedSpringReadOnlyStruct>(this).maxExtent = value;
}
}
}
}
}

+ 219
- 30
TechbloxModdingAPI/Blocks/Engine.cs 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
{
using RobocraftX.Common;
using Svelto.ECS;
public class Engine : Block
public class Engine : SignalingBlock
{
/// Engine constructor
private Engine(EGID egid) :
/// <summary>
/// Constructs a(n) Engine object representing an existing block.
/// </summary>
public Engine(EGID egid) :
base(egid)
{
}
/// Engine constructor
private Engine(uint id) :
/// <summary>
/// Constructs a(n) Engine object representing an existing block.
/// </summary>
public Engine(uint id) :
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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -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
{
@@ -208,5 +247,155 @@ namespace TechbloxModdingAPI.Blocks
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;
}
}
}
}

+ 17
- 7
TechbloxModdingAPI/Blocks/LogicGate.cs View File

@@ -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)
/// <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))
{
}
}
}
}

+ 54
- 33
TechbloxModdingAPI/Blocks/Piston.cs 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
{
public class Piston : SignalingBlock
using RobocraftX.Common;
using Svelto.ECS;
public class Piston : SignalingBlock
{
public Piston(EGID id) : base(id)
/// <summary>
/// Constructs a(n) Piston object representing an existing block.
/// </summary>
public Piston(EGID egid) :
base(egid)
{
}

public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP))
/// <summary>
/// Constructs a(n) Piston object representing an existing block.
/// </summary>
public Piston(uint id) :
base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP))
{
}

// custom piston properties

/// <summary>
/// The piston's max extension distance.
/// Gets or sets the Piston's MaximumForce property. Tweakable stat.
/// </summary>
public float MaximumExtension
public float MaximumForce
{
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation;

set
{
BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).maxDeviation = value;
}
}

/// <summary>
/// The piston's max extension force.
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).pistonVelocity;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).pistonVelocity = value;
}
}
/// <summary>
/// Gets or sets the Piston's MaxExtension property. Tweakable stat.
/// </summary>
public float MaximumForce
{
get => BlockEngine.GetBlockInfo<PistonReadOnlyStruct>(this).pistonVelocity;

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<PistonReadOnlyStruct>(this).pistonVelocity = value;
BlockEngine.GetBlockInfo<RobocraftX.Blocks.PistonReadOnlyStruct>(this).hasProportionalInput = value;
}
}
}


+ 56
- 0
TechbloxModdingAPI/Blocks/Seat.cs 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;
}
}
}
}

+ 123
- 48
TechbloxModdingAPI/Blocks/Servo.cs View File

@@ -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)
/// <summary>
/// Constructs a(n) Servo object representing an existing block.
/// </summary>
public Servo(EGID egid) :
base(egid)
{
}

public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP))
/// <summary>
/// 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>
public float MaximumForce
{
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).servoVelocity;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).servoVelocity = value;
}
}

// custom servo properties

/// <summary>
/// The servo's minimum angle.
/// Gets or sets the Servo's MinimumAngle property. Tweakable stat.
/// </summary>
public float MinimumAngle
{
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation;

set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).minDeviation = value;
}
}

/// <summary>
/// The servo's maximum angle.
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 => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation;

set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).maxDeviation = value;
}
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).maxDeviation;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).maxDeviation = value;
}
}

/// <summary>
/// The servo's maximum force.
/// <summary>
/// Gets or sets the Servo's Reverse property. Tweakable stat.
/// </summary>
public float MaximumForce
public bool Reverse
{
get => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity;

set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).servoVelocity = value;
}
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).reverse;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).reverse = value;
}
}

/// <summary>
/// The servo's direction.
/// <summary>
/// Gets or sets the Servo's InputIsAngle property. Tweakable stat.
/// </summary>
public bool Reverse
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 => BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse;

set
{
BlockEngine.GetBlockInfo<ServoReadOnlyStruct>(this).reverse = value;
}
get
{
return BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).forceAxis;
}
set
{
BlockEngine.GetBlockInfo<RobocraftX.Blocks.ServoReadOnlyStruct>(this).forceAxis = value;
}
}
}
}

+ 101
- 0
TechbloxModdingAPI/Blocks/WheelRig.cs 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;
}
}
}
}

+ 0
- 1
TechbloxModdingAPI/Utility/OptionalRef.cs View File

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



Loading…
Cancel
Save