Browse Source

Add damped spring

tags/v1.6.1
NGnius (Graham) 3 years ago
parent
commit
c6a1ea35cc
3 changed files with 745 additions and 679 deletions
  1. +1
    -0
      GamecraftModdingAPI/Block.cs
  2. +48
    -0
      GamecraftModdingAPI/Blocks/DampedSpring.cs
  3. +696
    -679
      GamecraftModdingAPI/GamecraftModdingAPI.csproj

+ 1
- 0
GamecraftModdingAPI/Block.cs View File

@@ -139,6 +139,7 @@ namespace GamecraftModdingAPI
CommonExclusiveGroups.BUILD_LOOPEDSFX_BLOCK_GROUP
}
},
{typeof(DampedSpring), new [] {CommonExclusiveGroups.BUILD_DAMPEDSPRING_BLOCK_GROUP}},
{typeof(TextBlock), new[] {CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP}},
{typeof(Timer), new[] {CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP}}
};


+ 48
- 0
GamecraftModdingAPI/Blocks/DampedSpring.cs View File

@@ -0,0 +1,48 @@
using RobocraftX.Blocks;
using RobocraftX.Common;
using Svelto.ECS;

namespace GamecraftModdingAPI.Blocks
{
public class DampedSpring : Block
{
public DampedSpring(EGID id) : base(id)
{
}

public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_DAMPEDSPRING_BLOCK_GROUP))
{
}

/// <summary>
/// The spring's maximum force. This is known as Stiffness in-game
/// </summary>
public float MaxForce
{
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.maxForce);

set => BlockEngine.SetBlockInfo(this,
(ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.maxForce = val, value);
}

/// <summary>
/// Alias of MaxForce.
/// </summary>
public float Stiffness
{
get => MaxForce;
set => MaxForce = value;
}

/// <summary>
/// The spring's maximum damping force.
/// </summary>
public float Damping
{
get => BlockEngine.GetBlockInfo(this, (LinearJointForcesReadOnlyStruct ljf) => ljf.dampingForceMagnitude);

set => BlockEngine.SetBlockInfo(this,
(ref LinearJointForcesReadOnlyStruct ljf, float val) => ljf.dampingForceMagnitude = val, value);
}
}
}

+ 696
- 679
GamecraftModdingAPI/GamecraftModdingAPI.csproj
File diff suppressed because it is too large
View File


Loading…
Cancel
Save