Browse Source

Update to Gamecraft 2020.12.16.14.19 and custom block stuff

- Fixed the crash on second time start
- Tweaked more stuff about the block

Breaking changes coming from FMOD 2.0:
- Audio[int index] changed to Audio[PARAMETER_ID index]
- Audio.Parameters removed
tags/v1.8.0
NorbiPeti 4 years ago
parent
commit
a7f6a16231
8 changed files with 40 additions and 44 deletions
  1. +1
    -1
      GamecraftModdingAPI/Blocks/BlockEngine.cs
  2. +10
    -2
      GamecraftModdingAPI/Blocks/CustomBlock.cs
  3. +4
    -4
      GamecraftModdingAPI/Blocks/DampedSpring.cs
  4. +2
    -2
      GamecraftModdingAPI/Blocks/Piston.cs
  5. +2
    -2
      GamecraftModdingAPI/Blocks/Servo.cs
  6. +1
    -5
      GamecraftModdingAPI/Blocks/TextBlock.cs
  7. +15
    -7
      GamecraftModdingAPI/GamecraftModdingAPI.csproj
  8. +5
    -21
      GamecraftModdingAPI/Utility/Audio.cs

+ 1
- 1
GamecraftModdingAPI/Blocks/BlockEngine.cs View File

@@ -227,7 +227,7 @@ namespace GamecraftModdingAPI.Blocks
for (int i = 0; i < joints.count; i++)
{
ref var joint = ref joints.buffer[i];
if (joint.jointState == JointState.Broken) continue;
if (joint.isBroken) continue;
if (joint.connectedEntityA == id) list.Add(new SimBody(joint.connectedEntityB));
else if (joint.connectedEntityB == id) list.Add(new SimBody(joint.connectedEntityA));
}


+ 10
- 2
GamecraftModdingAPI/Blocks/CustomBlock.cs View File

@@ -20,6 +20,7 @@ using UnityEngine.AddressableAssets;
using BoxCollider = UnityEngine.BoxCollider;
using Material = UnityEngine.Material;
using Object = UnityEngine.Object;
using ScalingPermission = DataLoader.ScalingPermission;

namespace GamecraftModdingAPI.Blocks
{
@@ -266,8 +267,15 @@ namespace GamecraftModdingAPI.Blocks
SelectableFaces = new[] {0, 1, 2, 3, 4, 5},
GridScale = new[] {1, 1, 1},
Mass = 1,
JointBreakAngle = 1,
Material = abd.Material
Material = abd.Material,
scalingPermission = ScalingPermission.NonUniform,
SortIndex = 12,
DefaultColour = (byte) BlockColors.Lime,
Volume = 1f,
timeRunningCollision = TimeRunningCollision.Enabled,
IsIsolator = false,
EdgeConnectingFaces = new[] {0, 1, 2, 3, 4, 5},
PointDataVolumeMultiplier = 1f
};
Console.WriteLine("Aluminium block data:\n" + abd);
Console.WriteLine("Material: " + abd.Material);


+ 4
- 4
GamecraftModdingAPI/Blocks/DampedSpring.cs View File

@@ -19,10 +19,10 @@ namespace GamecraftModdingAPI.Blocks
/// </summary>
public float MaxForce
{
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.maxForce);
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.springFrequency);

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

/// <summary>
@@ -39,10 +39,10 @@ namespace GamecraftModdingAPI.Blocks
/// </summary>
public float Damping
{
get => BlockEngine.GetBlockInfo(this, (LinearJointForcesReadOnlyStruct ljf) => ljf.dampingForceMagnitude);
get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.springDamping);

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

+ 2
- 2
GamecraftModdingAPI/Blocks/Piston.cs View File

@@ -40,11 +40,11 @@ namespace GamecraftModdingAPI.Blocks
/// </summary>
public float MaximumForce
{
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxForce);
get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.pistonVelocity);

set
{
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxForce = val, value);
BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.pistonVelocity = val, value);
}
}
}


+ 2
- 2
GamecraftModdingAPI/Blocks/Servo.cs View File

@@ -52,11 +52,11 @@ namespace GamecraftModdingAPI.Blocks
/// </summary>
public float MaximumForce
{
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxForce);
get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.servoVelocity);

set
{
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxForce = val, value);
BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.servoVelocity = val, value);
}
}



+ 1
- 5
GamecraftModdingAPI/Blocks/TextBlock.cs View File

@@ -35,10 +35,8 @@ namespace GamecraftModdingAPI.Blocks
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
{
tbds.textCurrent.Set(val);
tbds.textStored.Set(val);
tbds.textStored.Set(val, true);
}, value);
BlockEngine.SetBlockInfo(this,
(ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockStringContent.Set(val), value);
}
}

@@ -54,8 +52,6 @@ namespace GamecraftModdingAPI.Blocks
if (value == null) value = "";
BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) =>
tbds.textBlockID.Set(val), value);
BlockEngine.SetBlockInfo(this,
(ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockID.Set(val), value);
}
}
}


+ 15
- 7
GamecraftModdingAPI/GamecraftModdingAPI.csproj View File

@@ -78,9 +78,9 @@
<HintPath>..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
</Reference>
<Reference Include="FMOD">
<HintPath>..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath>
<Reference Include="FMODUnity">
<HintPath>..\ref\Gamecraft_Data\Managed\FMODUnity.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\FMODUnity.dll</HintPath>
</Reference>
<Reference Include="FullGame">
<HintPath>..\ref\Gamecraft_Data\Managed\FullGame.dll</HintPath>
@@ -266,6 +266,10 @@
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll</HintPath>
</Reference>
<Reference Include="Gamecraft.NetStrings">
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll</HintPath>
</Reference>
<Reference Include="Gamecraft.PerformanceWarnings">
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll</HintPath>
@@ -286,6 +290,10 @@
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll</HintPath>
</Reference>
<Reference Include="Gamecraft.Serialization">
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll</HintPath>
</Reference>
<Reference Include="Gamecraft.Tweaks">
<HintPath>..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll</HintPath>
@@ -510,6 +518,10 @@
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Multiplayer.Serializers">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.MultiplayerInput">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll</HintPath>
@@ -554,10 +566,6 @@
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Serializers">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Services">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll</HintPath>


+ 5
- 21
GamecraftModdingAPI/Utility/Audio.cs View File

@@ -43,40 +43,24 @@ namespace GamecraftModdingAPI.Utility
{
get
{
sound.getParameterValue(key, out float val, out float finalVal);
sound.getParameterByName(key, out float val, out float finalVal);
return val;
}

set => sound.setParameterValue(key, value);
set => sound.setParameterByName(key, value);
}

public float this[int index]
public float this[PARAMETER_ID index]
{
get
{
sound.getParameterValueByIndex(index, out float val, out float finalVal);
sound.getParameterByID(index, out float val, out float finalVal);
return val;
}

set => sound.setParameterValueByIndex(index, value);
set => sound.setParameterByID(index, value);
}

public string[] Parameters
{
get
{
sound.getParameterCount(out int count);
string[] parameters = new string[count];
for (int i = 0; i < count; i++)
{
sound.getParameterByIndex(i, out ParameterInstance param);
param.getDescription(out PARAMETER_DESCRIPTION desc);
parameters[i] = desc.name;
}
return parameters;
}
}

public float3 Position
{
get


Loading…
Cancel
Save