Browse Source

Fix issues with new update, waypoint fixes

Waypoints can be created from pilot seats now and it won't try to teleport to a waypoint if in a pilot seat
master
NorbiPeti 4 years ago
parent
commit
dce3045989
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
4 changed files with 43 additions and 29 deletions
  1. +2
    -2
      extracommands/ExtraCommands.csproj
  2. +6
    -9
      extracommands/RotatePlayerCommandEngine.cs
  3. +17
    -16
      extracommands/SetScaleCommandEngine.cs
  4. +18
    -2
      extracommands/TeleportWaypointCommandEngine.cs

+ 2
- 2
extracommands/ExtraCommands.csproj View File

@@ -44,7 +44,7 @@
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.MachineEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.MachineEditor.dll</HintPath>
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.MainGame">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll</HintPath>
@@ -62,7 +62,7 @@
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Services, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\ref\RobocraftX.Services.dll</HintPath>
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.StateSync">
<HintPath>..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll</HintPath>


+ 6
- 9
extracommands/RotatePlayerCommandEngine.cs View File

@@ -9,7 +9,6 @@ using UnityEngine;
using uREPL;
using Svelto.Context;
using RobocraftX;
using Svelto.ECS.EntityStructs;
using Unity.Mathematics;
using RobocraftX.Character.Camera;
using RobocraftX.Character.Factories;
@@ -36,10 +35,9 @@ namespace ExtraCommands.Basics

private void RotateAbsoluteCommand(float vertical, float horizontal)
{
uint count;
CharacterCameraEntityStruct[] cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup, out count);
EntityCollection<CharacterCameraEntityStruct> cameras = entitiesDB.QueryEntities<CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup);
int num2 = 0;
while ((long)num2 < (long)((ulong)count))
while (num2 < cameras.length)
{
cameras[num2].eulerRotation.x = vertical;
cameras[num2].eulerRotation.y = horizontal;
@@ -60,12 +58,11 @@ namespace ExtraCommands.Basics
private void RotateRelativeCommand(float vertical, float horizontal)
{
float2 angleDelta = new float2(vertical, horizontal);
uint count;
ValueTuple<CharacterCameraSettingsEntityStruct[], CharacterCameraEntityStruct[]> tuple = this.entitiesDB.QueryEntities<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup, out count);
CharacterCameraSettingsEntityStruct[] settings = tuple.Item1;
CharacterCameraEntityStruct[] cameras = tuple.Item2;
EntityCollection<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct> tuple = this.entitiesDB.QueryEntities<CharacterCameraSettingsEntityStruct, CharacterCameraEntityStruct>(CameraExclusiveGroups.VisualCameraGroup);
EntityCollection<CharacterCameraSettingsEntityStruct> settings = tuple.Item1;
EntityCollection<CharacterCameraEntityStruct> cameras = tuple.Item2;
int num2 = 0;
while ((long)num2 < (long)((ulong)count))
while (num2 < cameras.length)
{
CharacterCameraMovementUtility.UpdateCameraRotationFromDelta(ref cameras[num2], in settings[num2], angleDelta);
// TODO: Multiplayer compatibility


+ 17
- 16
extracommands/SetScaleCommandEngine.cs View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Reflection;
using GamecraftModdingAPI.Commands;
using Harmony;
using RobocraftX.GUI.CommandLine;
using RobocraftX.Multiplayer;
@@ -22,17 +23,16 @@ using Unity.Mathematics;
namespace ExtraCommands.Basics
{
[CustomCommand("SetScale")]
class SetScaleCommandEngine : CustomCommandEngine
class SetScaleCommandEngine : ICustomCommandEngine
{
public SetScaleCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
{
}

public override void Ready()
public void Ready()
{
CustomCommandUtility.Register<float, float, float>("SetScale", SetScaleCommand, "Set the scale for the next block. Use 0 0 0 to reset. The displayed cube is uniformly scaled until placed.");
CommandRegistrationHelper.Register<float, float, float>("SetScale", SetScaleCommand, "Set the scale for the next block. Use 0 0 0 to reset. The displayed cube is uniformly scaled until placed.");
}

public IEntitiesDB entitiesDB { get; set; }

private static float3 _scale;
//private HarmonyInstance harmony;

@@ -49,19 +49,17 @@ namespace ExtraCommands.Basics
}*/

_scale = new float3(x, y, z);
GhostScalingEntityStruct[] scalings =
EntityCollection<GhostScalingEntityStruct> scalings =
entitiesDB.QueryEntities<GhostScalingEntityStruct>(
(ExclusiveGroup.ExclusiveGroupStruct) NamedExclusiveGroup<GHOST_BLOCKS>.Group, out uint count);
Console.WriteLine("Found " + count + "/" + scalings.Length + " scalings.");
(ExclusiveGroupStruct) NamedExclusiveGroup<GHOST_BLOCKS>.Group);
Console.WriteLine("Found " + scalings.length + " scalings.");
var egid = new EGID(0, NamedExclusiveGroup<GHOST_BLOCKS>.Group);
for (int index = 0; index < count; index++)
for (int index = 0; index < scalings.length; index++)
{
Console.WriteLine("G scaling " + index + ": " + scalings[index].ghostScale);
ref var scaling = ref entitiesDB.QueryEntities<ScalingEntityStruct>(
(ExclusiveGroup.ExclusiveGroupStruct) NamedExclusiveGroup<GHOST_BLOCKS>.Group, out _)[index];
ref var scaling = ref entitiesDB.QueryEntity<ScalingEntityStruct>(egid);
Console.WriteLine("Scaling " + index + ": " + scaling);
ref var scale = ref entitiesDB.QueryEntities<BlockPlacementScaleEntityStruct>(
(ExclusiveGroup.ExclusiveGroupStruct) NamedExclusiveGroup<GHOST_BLOCKS>.Group, out _)[index];
ref var scale = ref entitiesDB.QueryEntity<BlockPlacementScaleEntityStruct>(egid);
Console.WriteLine("Scale " + index + ": " + scale.snapGridScale);
UpdateScale(ref scale, ref scaling, ref scalings[index], egid);
}
@@ -87,9 +85,9 @@ namespace ExtraCommands.Basics
Console.WriteLine("Scale updated (" + scaling.scale + ")");
}

public override void Dispose()
public void Dispose()
{
CustomCommandUtility.Unregister("SetScale");
CommandRegistrationHelper.Unregister("SetScale");
}

/*public void Add(ref GhostScalingEntityStruct entityView, EGID egid)
@@ -153,5 +151,8 @@ namespace ExtraCommands.Basics
.First(m => m.Name.Contains("UpdatePlacementCursorScales"));
}
}

public string Name { get; } = "SetScale";
public string Description { get; } = "Set the scale for the next block to be placed.";
}
}

+ 18
- 2
extracommands/TeleportWaypointCommandEngine.cs View File

@@ -34,7 +34,17 @@ namespace ExtraCommands.Waypoints

private void CreateWaypointCommand(object name)
{
ref RigidBodyEntityStruct reference = ref entitiesDB.QueryEntity<RigidBodyEntityStruct>(0u, CharacterExclusiveGroups.CharacterGroup);
RigidBodyEntityStruct reference;
if (entitiesDB.TryQueryEntitiesAndIndex(0u, CharacterExclusiveGroups.OnFootGroup, out uint index,
out RigidBodyEntityStruct[] array)
|| entitiesDB.TryQueryEntitiesAndIndex(0u, CharacterExclusiveGroups.InPilotSeatGroup, out index,
out array))
reference = array[index];
else
{
Log.Output("Player not found!");
return;
}
_waypoints[name] = new float[3] { reference.position.x, reference.position.y, reference.position.z };
uREPL.Log.Output("Saved " + name.ToString());
}
@@ -46,7 +56,13 @@ namespace ExtraCommands.Waypoints
uREPL.Log.Error("Waypoint not found");
return;
}
float[] loc = _waypoints[name];

if (entitiesDB.Exists<RigidBodyEntityStruct>(0u, CharacterExclusiveGroups.InPilotSeatGroup))
{
Log.Error("Cannot teleport from a pilot seat");
return;
}
float[] loc = _waypoints[name];
uREPL.RuntimeCommands.Call<float, float, float>("TeleportPlayerAbsolute", loc[0], loc[1], loc[2]);
}



Loading…
Cancel
Save