-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify teleport to move vehicle #2111
base: master
Are you sure you want to change the base?
Modify teleport to move vehicle #2111
Conversation
} | ||
catch (Exception e) | ||
{ | ||
// Freeze the player while he's loading its new position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Freeze the player while he's loading its new position |
NitroxClient/Communication/Packets/Processors/PlayerTeleportedProcessor.cs
Show resolved
Hide resolved
|
||
Vehicle currentVehicle = Player.main.currentMountedVehicle; | ||
// Check to make sure the player is in a vehicle | ||
if (currentVehicle != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's heavily advised to not check unity components and gameobjects against null. Instead just handle the object as a bool.
if (currentVehicle != null) | |
if (currentVehicle) |
See: https://discussions.unity.com/t/how-can-i-check-if-an-object-is-null/23224/4
public static bool Prefix(Vector3 position, bool gotoImmediate = false) | ||
{ | ||
Vehicle currentMountedVehicle = Player.main.currentMountedVehicle; | ||
if (currentMountedVehicle == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with checking against null
if (currentMountedVehicle == null) | |
if (!currentMountedVehicle) |
|
||
public sealed partial class GoTo_Patch : NitroxPatch, IDynamicPatch | ||
{ | ||
public static readonly MethodInfo TARGET_METHOD = Reflect.Method((GotoConsoleCommand gotoConsoleCommand) => gotoConsoleCommand.GotoPosition(default, default)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, just bc other patched have it this way:
public static readonly MethodInfo TARGET_METHOD = Reflect.Method((GotoConsoleCommand gotoConsoleCommand) => gotoConsoleCommand.GotoPosition(default, default)); | |
public static readonly MethodInfo TARGET_METHOD = Reflect.Method((GotoConsoleCommand t) => t.GotoPosition(default, default)); |
@@ -0,0 +1,22 @@ | |||
using System.Reflection; | |||
using HarmonyLib; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using HarmonyLib; |
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
public sealed partial class GoTo_Patch : NitroxPatch, IDynamicPatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patches are named like: <PatchedClass>_<PatchedMethod>_Patch.cs
. Could you rename the file and class in this fashion?
{ | ||
public static readonly MethodInfo TARGET_METHOD = Reflect.Method((GotoConsoleCommand t) => t.GotoPosition(default, default)); | ||
|
||
public static bool Prefix(Vector3 position, bool gotoImmediate = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to include the parameters if you don't need them.
public static bool Prefix(Vector3 position, bool gotoImmediate = false) | |
public static bool Prefix(Vector3 position) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except the one comment LGTM CW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is lacking a feature which is allowing the warpforward command to also work with vehicles as well
Also please apply a rebase to this branch so you can test it with the latest movement PR merged
…nd to teleport that Rigidbody if present
79b87b0
to
495287f
Compare
Attempting to modify the vehicle teleport behaviour.
Correctly updates player pos with player in seamoth / prawn