Files
Nitrox/NitroxPatcher/Patches/Dynamic/Player_Start_Patch.cs
2025-07-06 00:23:46 +02:00

24 lines
722 B
C#

using System.Reflection;
using NitroxClient.MonoBehaviours;
using NitroxModel.Helper;
namespace NitroxPatcher.Patches.Dynamic;
/// <summary>
/// Adds <see cref="CyclopsMotor"/> to the Player's object when it's initialized
/// </summary>
public sealed partial class Player_Start_Patch : NitroxPatch, IDynamicPatch
{
private static readonly MethodInfo TARGET_METHOD = Reflect.Method((Player t) => t.Start());
public static void Postfix()
{
if (Player.mainObject.GetComponent<CyclopsMotor>())
{
return;
}
GroundMotor groundMotor = Player.mainObject.GetComponent<GroundMotor>();
Player.mainObject.AddComponent<CyclopsMotor>().Initialize(groundMotor);
}
}