@@ -1,69 +0,0 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using Svelto.Tasks; | |||
using Svelto.Tasks.ExtraLean; | |||
using RobocraftX; | |||
using RobocraftX.Schedulers; | |||
using GamecraftModdingAPI.Commands; | |||
using GamecraftModdingAPI.Tasks; | |||
using GamecraftModdingAPI.Utility; | |||
namespace ExtraCommands.Basics | |||
{ | |||
//[CustomCommand("Chain")] | |||
class ChainCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Run two commands one after the other"; | |||
public string Name => "Chain"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<string, string>(Name, ChainCommand, Description); | |||
} | |||
private void ChainCommand(string command1, string command2) | |||
{ | |||
string command1a = decomma(command1); | |||
string command2a = decomma(command2); | |||
ScheduleCommands(command1a, command2a).RunOn(Scheduler.extraLeanRunner); | |||
} | |||
private IEnumerator<TaskContract> ScheduleCommands(string c1, string c2) | |||
{ | |||
yield return Yield.It; | |||
bool success1 = uREPL.Evaluator.Evaluate(c1).type == CompileResult.Type.Success; | |||
if (!success1) | |||
{ | |||
Logging.CommandLogError("First command was not executed successfully"); | |||
} | |||
bool success2 = uREPL.Evaluator.Evaluate(c2).type == CompileResult.Type.Success; | |||
if (!success2) | |||
{ | |||
Logging.CommandLogError("Second command was not executed successfully"); | |||
} | |||
} | |||
private string decomma(string strIn) | |||
{ | |||
return strIn.Replace(", ", " "); | |||
} | |||
public void Dispose() | |||
{ | |||
CommandRegistrationHelper.Unregister("Chain"); | |||
} | |||
} | |||
} |
@@ -4,7 +4,7 @@ using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands | |||
{ | |||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] | |||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)] | |||
public class CustomCommandAttribute: Attribute | |||
{ | |||
public readonly string Name; | |||
@@ -1,14 +1,4 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
using GamecraftModdingAPI.Commands; | |||
@@ -25,15 +15,17 @@ using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Example | |||
{ | |||
// !!! Uncomment the line below this !!! | |||
// [CustomCommand("Example")] | |||
class ExampleCommandEngine : ICustomCommandEngine | |||
// !!! Uncomment the line below this !!! | |||
// [CustomCommand("Example")] | |||
class ExampleCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "This is an example command which does nothing!"; | |||
public string Name => "Example"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public bool isRemovable => true; | |||
// This class is a custom implementation of CustomCommandEngine specific to this command | |||
// You can use Svelto.ECS.IEntityDB entitiesDB to query game entities or one of the protected variables for other things | |||
@@ -1,29 +1,22 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Basics | |||
{ | |||
[CustomCommand("Exit")] | |||
[CustomCommand("Exit")] | |||
class ExitCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Close Gamecraft without any prompts"; | |||
public string Name => "Exit"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register(Name, ExitCommand, Description); | |||
} | |||
@@ -5,10 +5,6 @@ | |||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="Lib.Harmony" Version="1.2.0.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Reference Include="GamecraftModdingAPI"> | |||
<HintPath>..\ref\Plugins\GamecraftModdingAPI.dll</HintPath> | |||
@@ -28,7 +24,7 @@ | |||
<Reference Include="RobocraftX.Character"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll</HintPath> | |||
</Reference> | |||
<Reference Include="CommandLine"> | |||
<Reference Include="RobocraftX.Common"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll</HintPath> | |||
</Reference> | |||
<Reference Include="RobocraftX.Blocks"> | |||
@@ -76,12 +72,6 @@ | |||
<Reference Include="Unity.Entities.Hybrid"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Entities.Properties"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.Properties.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Entities.StaticTypeRegistry"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Entities.StaticTypeRegistry.dll</HintPath> | |||
</Reference> | |||
<Reference Include="Unity.Mathematics"> | |||
<HintPath>..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll</HintPath> | |||
</Reference> | |||
@@ -1,46 +1,38 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.Common; | |||
using RobocraftX.Blocks; | |||
using RobocraftX.Blocks.Ghost; | |||
using Svelto.ECS; | |||
using Svelto.ECS.EntityStructs; | |||
using Unity.Entities; | |||
using Svelto.Context; | |||
using Svelto.Tasks; | |||
using RobocraftX; | |||
using RobocraftX.SimulationModeState; | |||
using RobocraftX.UECS; | |||
using Unity.Transforms; | |||
//using Svelto.Context; | |||
using Unity.Mathematics; | |||
using UnityEngine; | |||
using GamecraftModdingAPI.Blocks; | |||
using GamecraftModdingAPI.Commands; | |||
using GamecraftModdingAPI; | |||
namespace ExtraCommands.Building | |||
{ | |||
//[CustomCommand("MoveBlocks", "Move all blocks (including ground) from their original position")] | |||
[CustomCommand("MoveLastBlock", "Move last block from original position")] | |||
[CustomCommand("MoveLastBlock", "Move last block from original position")] | |||
class MoveBlocksCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Move blocks"; | |||
public string Name => "MoveBlocks"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public bool isRemovable => false; | |||
public void Ready() | |||
{ | |||
//CustomCommandUtility.Register<float, float, float>("MoveBlocks", MoveBlocksCommand, "Move all blocks (including ground) from their original position"); | |||
CommandRegistrationHelper.Register<float, float, float>("MoveLastBlock", MoveLastBlockCommand, "Move last block from original position"); | |||
CommandRegistrationHelper.Register<float, float, float>("MoveLastBlock", MoveLastBlockCommand, "Move last block, and connecting blocks, from their original position"); | |||
} | |||
private void MoveLastBlockCommand(float x, float y, float z) | |||
{ | |||
float3 vector = new float3(x, y, z); | |||
Movement.MoveConnectedBlocks(BlockIdentifiers.LatestBlockID, vector); | |||
Block lastBlock = Block.GetLastPlacedBlock(); | |||
Block[] besideBlocks = lastBlock.GetConnectedCubes(); | |||
for (int i = 0; i < besideBlocks.Length; i++) | |||
{ | |||
besideBlocks[i].Position += vector; | |||
} | |||
//lastBlock.Position += vector; | |||
} | |||
public void Dispose() | |||
@@ -1,35 +1,24 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.Common; | |||
using Svelto.ECS; | |||
using Svelto.ECS.EntityStructs; | |||
using Unity.Entities; | |||
using Svelto.Context; | |||
using Svelto.Tasks; | |||
using RobocraftX; | |||
using RobocraftX.SimulationModeState; | |||
using RobocraftX.UECS; | |||
using Unity.Transforms; | |||
//using Svelto.Context; | |||
using Unity.Mathematics; | |||
using UnityEngine; | |||
using GamecraftModdingAPI.Commands; | |||
using GamecraftModdingAPI.Blocks; | |||
using GamecraftModdingAPI; | |||
namespace ExtraCommands.Building | |||
{ | |||
//[CustomCommand("RotateBlocks", "Rotate all blocks (including ground) from their original position")] | |||
[CustomCommand("RotateLastBlock", "Rotate last block from original position")] | |||
[CustomCommand("RotateLastBlock", "Rotate last block from original position")] | |||
class RotateBlocksCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Rotate last block from original position"; | |||
public string Name => "RotateLastBlock"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<float, float, float>(Name, RotateLastBlockCommand, Description); | |||
} | |||
@@ -38,7 +27,8 @@ namespace ExtraCommands.Building | |||
private void RotateLastBlockCommand(float x, float y, float z) | |||
{ | |||
float3 eulerAngles = new float3(x, y, z); | |||
GamecraftModdingAPI.Blocks.Rotation.RotateBlock(BlockIdentifiers.LatestBlockID, eulerAngles); | |||
Block.GetLastPlacedBlock().Rotation += eulerAngles; | |||
//GamecraftModdingAPI.Blocks.Rotation.RotateBlock(BlockIdentifiers.LatestBlockID, eulerAngles); | |||
} | |||
public void Dispose() | |||
@@ -1,15 +1,6 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
using Svelto.ECS.EntityStructs; | |||
//using Svelto.Context; | |||
using Unity.Mathematics; | |||
using RobocraftX.Character.Camera; | |||
using RobocraftX.Character.Factories; | |||
@@ -18,16 +9,18 @@ using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Basics | |||
{ | |||
[CustomCommand("Rotation")] | |||
[CustomCommand("Rotation")] | |||
class RotatePlayerCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Rotation"; | |||
public string Name => "Rotation commands"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<float, float>("RotateAbsolute", RotateAbsoluteCommand, "Rotate the player camera to the entered rotation"); | |||
CommandRegistrationHelper.Register<float, float>("RotateRelative", RotateRelativeCommand, "Rotate the player camera by the entered rotation"); | |||
@@ -37,7 +30,7 @@ namespace ExtraCommands.Basics | |||
private void RotateAbsoluteCommand(float vertical, float horizontal) | |||
{ | |||
uint count; | |||
CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup, out count); | |||
CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup).ToFastAccess(out count); | |||
int num2 = 0; | |||
while ((long)num2 < (long)((ulong)count)) | |||
{ | |||
@@ -61,7 +54,7 @@ namespace ExtraCommands.Basics | |||
{ | |||
float2 angleDelta = new float2(vertical, horizontal); | |||
uint count; | |||
ValueTuple<CharacterCameraSettingsEntityStruct[], CharacterCameraEntityStruct[]> tuple = this.entitiesDB.QueryEntities<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup, out count); | |||
ValueTuple<CharacterCameraSettingsEntityStruct[], CharacterCameraEntityStruct[]> tuple = this.entitiesDB.QueryEntities<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup).ToFastAccess(out count); | |||
CharacterCameraSettingsEntityStruct[] settings = tuple.Item1; | |||
CharacterCameraEntityStruct[] cameras = tuple.Item2; | |||
int num2 = 0; | |||
@@ -1,29 +1,23 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
//using Svelto.Context; | |||
using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Basics | |||
{ | |||
[CustomCommand("SetFieldOfView")] | |||
[CustomCommand("SetFieldOfView")] | |||
class SetFOVCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Set the camera's field of view"; | |||
public string Name => "SetFieldOfView"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<float>(Name, SetFieldOfViewCommand, Description); | |||
} | |||
@@ -1,27 +1,21 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
//using Svelto.Context; | |||
using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Basics | |||
{ | |||
[CustomCommand("SetTargetFPS")] | |||
[CustomCommand("SetTargetFPS")] | |||
class SetTargetFramerateCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Set Gamecraft's target FPS'"; | |||
public string Name => "SetTargetFPS"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
@@ -1,21 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using System.Collections.Generic; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
using RobocraftX.Physics; | |||
//using Svelto.Context; | |||
using GamecraftModdingAPI.Commands; | |||
using GamecraftModdingAPI; | |||
using GamecraftModdingAPI.Players; | |||
namespace ExtraCommands.Waypoints | |||
{ | |||
[CustomCommand("Waypoints")] | |||
[CustomCommand("Waypoints")] | |||
class TeleportWaypointCommandEngine : ICustomCommandEngine | |||
{ | |||
private Dictionary<object, float[]> _waypoints = new Dictionary<object, float[]>(); | |||
@@ -24,9 +17,11 @@ namespace ExtraCommands.Waypoints | |||
public string Name => "Waypoints"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public EntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
public bool isRemovable => true; | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<object>("CreateWaypoint", CreateWaypointCommand, "Create a waypoint in your current location"); | |||
CommandRegistrationHelper.Register<object>("TeleportPlayerWaypoint", TeleportToWaypointCommand, "Teleport to a waypoint"); | |||
@@ -34,8 +29,8 @@ namespace ExtraCommands.Waypoints | |||
private void CreateWaypointCommand(object name) | |||
{ | |||
ref RigidBodyEntityStruct reference = ref entitiesDB.QueryEntity<RigidBodyEntityStruct>(0u, CharacterExclusiveGroups.CharacterGroup); | |||
_waypoints[name] = new float[3] { reference.position.x, reference.position.y, reference.position.z }; | |||
Player reference = new Player(PlayerType.Local); | |||
_waypoints[name] = new float[3] { reference.Position.x, reference.Position.y, reference.Position.z }; | |||
uREPL.Log.Output("Saved " + name.ToString()); | |||
} | |||
@@ -1,41 +0,0 @@ | |||
using System; | |||
using RobocraftX.GUI.CommandLine; | |||
using RobocraftX.Multiplayer; | |||
using RobocraftX.StateSync; | |||
using RobocraftX.Character; | |||
using Svelto.ECS; | |||
using Unity.Entities; | |||
using UnityEngine; | |||
using uREPL; | |||
using Svelto.Context; | |||
using RobocraftX; | |||
using GamecraftModdingAPI.Commands; | |||
namespace ExtraCommands.Basics | |||
{ | |||
[CustomCommand("Wait")] | |||
class WaitCommandEngine : ICustomCommandEngine | |||
{ | |||
public string Description => "Delay execution (freeze the game) for a length of time (ms)"; | |||
public string Name => "Wait"; | |||
public IEntitiesDB entitiesDB { set; private get; } | |||
public void Ready() | |||
{ | |||
CommandRegistrationHelper.Register<int>("Wait", WaitCommand, "Delay execution (freeze the game) for a length of time (ms)"); | |||
} | |||
private void WaitCommand(int ms) | |||
{ | |||
System.Threading.Thread.Sleep(ms); | |||
} | |||
public void Dispose() | |||
{ | |||
CommandRegistrationHelper.Unregister("Wait"); | |||
} | |||
} | |||
} |