Remove no clip and update set limits command
This commit is contained in:
parent
2ec15427d6
commit
343867e67c
4 changed files with 813 additions and 727 deletions
|
@ -215,22 +215,10 @@ namespace BuildingTools
|
||||||
return copy;
|
return copy;
|
||||||
}).ToArray();
|
}).ToArray();
|
||||||
}).Build();
|
}).Build();
|
||||||
CommandBuilder.Builder("setLimits", "Sets the CPU and power limits.")
|
var setLimits = new SetLimitsCommandEngine();
|
||||||
.Action((int cpu, int power) =>
|
CommandBuilder.Builder("setLimits", "Set build limits").Action((Action<int, int>)setLimits.SetLimits).Build();
|
||||||
{
|
GameEngineManager.AddGameEngine(setLimits);
|
||||||
//MachineRulesComponent 0U, GroupCompound<MACHINE, LOCAL>.BuildGroup
|
|
||||||
//var data = FullGameFields._dataDb.GetValue<BuildRulesData>(1);
|
|
||||||
var data = new BuildRulesData(); //TODO
|
|
||||||
Logging.CommandLog($"Old CPU limit: {data.CPULimitMax}, power limit: {data.PowerLimitMax}");
|
|
||||||
data.PowerLimitMax = power;
|
|
||||||
data.CPULimitMax = cpu;
|
|
||||||
Logging.CommandLog($"New CPU limit: {data.CPULimitMax}, power limit: {data.PowerLimitMax}");
|
|
||||||
}).Build();
|
|
||||||
|
|
||||||
var noClip = new NoClipCommand();
|
|
||||||
GameEngineManager.AddGameEngine(noClip);
|
|
||||||
CommandBuilder.Builder("noclip", "Allows you to go through blocks. Run again to disable. Disable before entering the menu.")
|
|
||||||
.Action(noClip.Toggle).Build();
|
|
||||||
CommandBuilder.Builder("freeScaling", "This command removes scaling restrictions on the selected block. Reselect block to apply.")
|
CommandBuilder.Builder("freeScaling", "This command removes scaling restrictions on the selected block. Reselect block to apply.")
|
||||||
.Action(() =>
|
.Action(() =>
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,110 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using TechbloxModdingAPI;
|
|
||||||
using TechbloxModdingAPI.Engines;
|
|
||||||
using TechbloxModdingAPI.Utility;
|
|
||||||
using RobocraftX.Character;
|
|
||||||
using RobocraftX.Common;
|
|
||||||
using RobocraftX.Common.Input;
|
|
||||||
using RobocraftX.UECS;
|
|
||||||
using Svelto.ECS;
|
|
||||||
using Svelto.Tasks.ExtraLean;
|
|
||||||
using Unity.Entities;
|
|
||||||
using Unity.Physics;
|
|
||||||
using Yield = Svelto.Tasks.Yield;
|
|
||||||
|
|
||||||
namespace BuildingTools
|
|
||||||
{
|
|
||||||
public class NoClipCommand : IApiEngine
|
|
||||||
{
|
|
||||||
private readonly CollisionFilter _collisionFilter = new CollisionFilter
|
|
||||||
{ //AddCollidersToRigidBodyEngineUECS._simCubeNoCollisionFilter
|
|
||||||
BelongsTo = 0,
|
|
||||||
CollidesWith = 239532
|
|
||||||
};
|
|
||||||
|
|
||||||
private EntityManager _entityManager;
|
|
||||||
private CollisionFilter _oldFilter;
|
|
||||||
private bool _enabled;
|
|
||||||
|
|
||||||
private void Enable()
|
|
||||||
{
|
|
||||||
if (_entityManager == default) _entityManager = FullGameFields._physicsWorld.EntityManager;
|
|
||||||
Logging.CommandLog("Enabling noclip");
|
|
||||||
_oldFilter = ChangeCollider(_collisionFilter);
|
|
||||||
OnUpdate().RunOn(TechbloxModdingAPI.Tasks.Scheduler.extraLeanRunner);
|
|
||||||
_enabled = true;
|
|
||||||
Logging.CommandLog("Noclip enabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Disable()
|
|
||||||
{
|
|
||||||
Logging.CommandLog("Disabling noclip");
|
|
||||||
ChangeCollider(_oldFilter);
|
|
||||||
_enabled = false;
|
|
||||||
Logging.CommandLog("Noclip disabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Toggle()
|
|
||||||
{
|
|
||||||
if (!_enabled) Enable();
|
|
||||||
else Disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerator OnUpdate()
|
|
||||||
{ //ScreenshotTakerCompositionRoot
|
|
||||||
while (_enabled)
|
|
||||||
{
|
|
||||||
EnsureFlying();
|
|
||||||
ChangeCollider(_collisionFilter);
|
|
||||||
if (!entitiesDB.Exists<LocalPlayerInputEntityStruct>(0U, CommonExclusiveGroups.GameStateGroup))
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return Yield.It;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private CollisionFilter ChangeCollider(CollisionFilter newFilter)
|
|
||||||
{
|
|
||||||
foreach (var group in CharacterExclusiveGroups.AllCharacters)
|
|
||||||
{
|
|
||||||
if (!entitiesDB.Exists<UECSPhysicsEntityStruct>(new EGID(Player.LocalPlayer.Id, group)))
|
|
||||||
continue;
|
|
||||||
ref var uecsEntity =
|
|
||||||
ref entitiesDB.QueryEntity<UECSPhysicsEntityStruct>(new EGID(Player.LocalPlayer.Id, group));
|
|
||||||
var collider = _entityManager.GetComponentData<PhysicsCollider>(uecsEntity.uecsEntity);
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
var coll = (CompoundCollider*) collider.Value.GetUnsafePtr();
|
|
||||||
var filter = coll->Filter;
|
|
||||||
coll->Filter = newFilter;
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new InvalidOperationException("No character physics found!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnsureFlying()
|
|
||||||
{
|
|
||||||
/*foreach (var ((coll, count), _) in entitiesDB.QueryEntities<CharacterMovementEntityStruct>(CharacterExclusiveGroups.AllCharacters))
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
coll[i].moveState = MovementState.Flying;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Ready()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntitiesDB entitiesDB { get; set; }
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; } = "BuildingToolsNoClipEngine";
|
|
||||||
public bool isRemovable { get; } = true;
|
|
||||||
}
|
|
||||||
}
|
|
32
BuildingTools/SetLimitsCommandEngine.cs
Normal file
32
BuildingTools/SetLimitsCommandEngine.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using Svelto.ECS;
|
||||||
|
using Techblox.Building.Rules;
|
||||||
|
using Techblox.Building.Rules.Entities;
|
||||||
|
using TechbloxModdingAPI.Engines;
|
||||||
|
using TechbloxModdingAPI.Utility;
|
||||||
|
|
||||||
|
namespace BuildingTools
|
||||||
|
{
|
||||||
|
public class SetLimitsCommandEngine : IApiEngine
|
||||||
|
{
|
||||||
|
public void Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntitiesDB entitiesDB { get; set; }
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLimits(int cpu, int power)
|
||||||
|
{
|
||||||
|
ref var rules = ref entitiesDB.QueryUniqueEntity<MachineRulesComponent>(GroupCompound<MACHINE, LOCAL>.BuildGroup);
|
||||||
|
Logging.CommandLog($"Old CPU limit: {rules.cpu.max}, power limit: {rules.power.max}");
|
||||||
|
rules.cpu.max = cpu;
|
||||||
|
rules.power.max = power;
|
||||||
|
Logging.CommandLog($"New CPU limit: {rules.cpu.max}, power limit: {rules.power.max}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name => "SetLimitsEngine";
|
||||||
|
public bool isRemovable => true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue