Загрузка данных


using BepInEx;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.Injection;
using UnityEngine;

[BepInPlugin("my.noclip", "Noclip", "1.0")]
public class Plugin : BasePlugin
{
    public override void Load()
    {
        ClassInjector.RegisterTypeInIl2Cpp<NoclipBehaviour>();
        AddComponent<NoclipBehaviour>();
        Log.LogInfo("Noclip loaded, press F6");
    }
}

public class NoclipBehaviour : MonoBehaviour
{
    public NoclipBehaviour(System.IntPtr ptr) : base(ptr) { }

    bool on;
    Transform player;
    CharacterController cc;
    Rigidbody rb;

    void Update()
    {
        if (Input.GetKeyDown(KeyCode.F6)) Toggle();
        if (!on || player == null || Camera.main == null) return;

        var cam = Camera.main.transform;
        Vector3 dir = Vector3.zero;
        if (Input.GetKey(KeyCode.W)) dir += cam.forward;
        if (Input.GetKey(KeyCode.S)) dir -= cam.forward;
        if (Input.GetKey(KeyCode.D)) dir += cam.right;
        if (Input.GetKey(KeyCode.A)) dir -= cam.right;
        if (Input.GetKey(KeyCode.Space)) dir += Vector3.up;
        if (Input.GetKey(KeyCode.LeftControl)) dir -= Vector3.up;

        float speed = Input.GetKey(KeyCode.LeftShift) ? 30f : 10f;
        player.position += dir.normalized * speed * Time.deltaTime;
    }

    void Toggle()
    {
        on = !on;
        if (on)
        {
            cc = FindObjectOfType<CharacterController>();
            if (cc != null) { player = cc.transform; cc.enabled = false; }
            else
            {
                var go = GameObject.FindWithTag("Player");
                rb = go != null ? go.GetComponent<Rigidbody>() : null;
                if (rb != null) { player = rb.transform; rb.isKinematic = true; }
            }
        }
        else
        {
            if (cc != null) cc.enabled = true;
            if (rb != null