Browse Source

Add free scaling and attempt to fix noclip

tags/v1.1.0
NorbiPeti 4 years ago
parent
commit
2b0cec100e
3 changed files with 36 additions and 45 deletions
  1. +9
    -0
      BuildingTools/BuildingTools.cs
  2. +1
    -37
      BuildingTools/BuildingTools.csproj
  3. +26
    -8
      BuildingTools/NoClipCommand.cs

+ 9
- 0
BuildingTools/BuildingTools.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DataLoader;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
@@ -158,6 +159,14 @@ namespace BuildingTools
GameEngineManager.AddGameEngine(noClip);
CommandBuilder.Builder("noClip", "Allows you to go through blocks. Run again to disable.")
.Action(noClip.Toggle).Build();
CommandBuilder.Builder("freeScaling", "This command removes scaling restrictions on the selected block. Reselect block to apply.")
.Action(() =>
{
var blockID = Player.LocalPlayer.SelectedBlock;
FullGameFields._dataDb.GetValue<CubeListData>((int) blockID).scalingPermission =
ScalingPermission.NonUniform;
Logging.CommandLog("Free scaling enabled for " + blockID + " until the game is restarted.");
}).Build();
}

private string GetBlockInfo()


+ 1
- 37
BuildingTools/BuildingTools.csproj View File

@@ -76,9 +76,6 @@
<Reference Include="Facepunch.Steamworks.Win64, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll</HintPath>
</Reference>
<Reference Include="FMOD, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\FMOD.dll</HintPath>
</Reference>
<Reference Include="FullGame, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\FullGame.dll</HintPath>
</Reference>
@@ -250,7 +247,7 @@
<Reference Include="Gamecraft.Wires.Mockup, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll</HintPath>
</Reference>
<Reference Include="GamecraftModdingAPI, Version=1.7.0.0, Culture=neutral, PublicKeyToken=null">
<Reference Include="GamecraftModdingAPI">
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll</HintPath>
</Reference>
<Reference Include="GameState, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
@@ -403,9 +400,6 @@
<Reference Include="RobocraftX.SaveGameDialog, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Serializers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll</HintPath>
</Reference>
@@ -439,27 +433,6 @@
<Reference Include="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.Curves, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.Curves.Hybrid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.DefaultGraphPipeline, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.DefaultGraphPipeline.Hybrid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.Graph, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll</HintPath>
</Reference>
<Reference Include="Unity.Animation.Hybrid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll</HintPath>
</Reference>
<Reference Include="Unity.Build.SlimPlayerRuntime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll</HintPath>
</Reference>
@@ -475,9 +448,6 @@
<Reference Include="Unity.Collections.LowLevel.ILSupport, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll</HintPath>
</Reference>
<Reference Include="Unity.DataFlowGraph, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll</HintPath>
</Reference>
<Reference Include="Unity.Deformations, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll</HintPath>
</Reference>
@@ -487,9 +457,6 @@
<Reference Include="Unity.Entities.Hybrid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll</HintPath>
</Reference>
<Reference Include="Unity.InternalAPIEngineBridge.002, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.002.dll</HintPath>
</Reference>
<Reference Include="Unity.Jobs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll</HintPath>
</Reference>
@@ -514,9 +481,6 @@
<Reference Include="Unity.Platforms.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll</HintPath>
</Reference>
<Reference Include="Unity.Postprocessing.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll</HintPath>
</Reference>
<Reference Include="Unity.Properties, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Properties.dll</HintPath>
</Reference>


+ 26
- 8
BuildingTools/NoClipCommand.cs View File

@@ -2,6 +2,7 @@
using System.Collections;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Engines;
using GamecraftModdingAPI.Players;
using GamecraftModdingAPI.Utility;
using RobocraftX.Character;
using RobocraftX.Character.Camera;
@@ -31,7 +32,7 @@ namespace BuildingTools
};

private EntityManager _entityManager;
private BlobAssetReference<Collider> _oldCollider;
private CollisionFilter _oldCollider;
private bool _enabled;

private void Enable()
@@ -47,7 +48,7 @@ namespace BuildingTools
private void Disable()
{
Logging.CommandLog("Disabling noclip");
ChangeCollider(null, _oldCollider).Dispose(); //Dispose old (cloned) collider
ChangeCollider(null, _oldCollider); //Dispose old (cloned) collider
_enabled = false;
Logging.CommandLog("Noclip disabled");
}
@@ -66,7 +67,7 @@ namespace BuildingTools
EnsureFlying();
if (!entitiesDB.Exists<LocalInputEntityStruct>(0U, CommonExclusiveGroups.GameStateGroup))
{
Disable();
//Disable();
yield break;
}

@@ -74,27 +75,44 @@ namespace BuildingTools
}
}

private BlobAssetReference<Collider> ChangeCollider(CollisionFilter? newFilter, BlobAssetReference<Collider>? newCollider)
private CollisionFilter ChangeCollider(CollisionFilter? newFilter, CollisionFilter? newCollider)
{
foreach (var group in CharacterExclusiveGroups.AllCharacters)
{
/*if (!Player.Exists(PlayerType.Local))
continue;*/
if (!entitiesDB.Exists<UECSPhysicsEntityStruct>(new EGID(Player.LocalPlayer.Id, group)))
continue;
ref var uecsEntity =
ref entitiesDB.QueryEntity<UECSPhysicsEntityStruct>(new EGID(Player.LocalPlayer.Id, group));
Console.WriteLine("Found physics entity " + uecsEntity.ID);
var collider = _entityManager.GetComponentData<PhysicsCollider>(uecsEntity.uecsEntity);
var oldCollider = collider.Value;
//var collider = _entityManager.GetComponentData<CharacterEnvironmentCollision>(uecsEntity.uecsEntity);
//Console.WriteLine("Collider: " + collider.sphereCollider.Value.Filter.BelongsTo);
unsafe
{
Console.WriteLine("Collider ptr: " + (long) collider.ColliderPtr);
}

var oldCollider = collider.Value.Value.Filter;
if (newFilter.HasValue)
{
unsafe
{
var colRef = ColliderUtilityUECS.ClonePhysicsCollider(collider.ColliderPtr, newFilter.Value);
collider.Value = colRef;
//var colRef = ColliderUtilityUECS.ClonePhysicsCollider(collider.ColliderPtr, newFilter.Value);
//collider.Value = colRef;
collider.Value.Value.Filter = newFilter.Value;
Console.WriteLine("New collider: " + (long) collider.ColliderPtr);
}
}
else if (newCollider.HasValue)
collider.Value = newCollider.Value;
collider.Value.Value.Filter = newCollider.Value;

//Console.WriteLine("New collider: " + collider.sphereCollider.Value.Filter.BelongsTo);
_entityManager.SetComponentData(uecsEntity.uecsEntity, collider);
Console.WriteLine("Resulting filter: " + _entityManager
.GetComponentData<PhysicsCollider>(uecsEntity.uecsEntity).Value.Value.Filter
.BelongsTo);
return oldCollider;
}



Loading…
Cancel
Save