You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
-
- using RobocraftX.Blocks;
- using RobocraftX.Common;
- using Svelto.ECS;
- using Unity.Mathematics;
-
- using GamecraftModdingAPI.Utility;
-
- namespace GamecraftModdingAPI.Blocks
- {
- public class Motor : Block
- {
- public Motor(EGID id) : base(id)
- {
- if (!BlockEngine.GetBlockInfoExists<MotorReadOnlyStruct>(this.Id))
- {
- throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
- }
- }
-
- public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP))
- {
- if (!BlockEngine.GetBlockInfoExists<MotorReadOnlyStruct>(this.Id))
- {
- throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
- }
- }
-
- // custom motor properties
-
- /// <summary>
- /// The motor's maximum rotational velocity.
- /// </summary>
- public float TopSpeed
- {
- get
- {
- return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id).maxVelocity;
- }
-
- set
- {
- ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id);
- motor.maxVelocity = value;
- }
- }
-
- /// <summary>
- /// The motor's maximum rotational force.
- /// </summary>
- public float Torque
- {
- get
- {
- return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id).maxForce;
- }
-
- set
- {
- ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id);
- motor.maxForce = value;
- }
- }
-
- /// <summary>
- /// The motor's direction.
- /// </summary>
- public bool Reverse
- {
- get
- {
- return BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id).reverse;
- }
-
- set
- {
- ref MotorReadOnlyStruct motor = ref BlockEngine.GetBlockInfo<MotorReadOnlyStruct>(Id);
- motor.reverse = value;
- }
- }
- }
- }
|