예제 #1
0
        private static void Prefix(NoteController __instance, NoteData ____noteData, NoteMovement ____noteMovement)
        {
            if (__instance is MultiplayerConnectedPlayerNoteController)
            {
                NoodleData = null;
                return;
            }

            NoodleData = NoodleObjectDatas[____noteData];
            NoodleNoteData noodleData = (NoodleNoteData)NoodleData;

            Track track = noodleData.Track;

            NoodleObjectData.AnimationObjectData animationObject = noodleData.AnimationObject;
            if (track != null || animationObject != null)
            {
                NoteJump          noteJump      = NoteControllerInit._noteJumpAccessor(ref ____noteMovement);
                NoteFloorMovement floorMovement = NoteControllerInit._noteFloorMovementAccessor(ref ____noteMovement);

                // idk i just copied base game time
                float jumpDuration = _jumpDurationAccessor(ref noteJump);
                float elapsedTime  = _audioTimeSyncControllerAccessor(ref noteJump).songTime - (____noteData.time - (jumpDuration * 0.5f));
                elapsedTime = NoteJumpManualUpdate.NoteJumpTimeAdjust(elapsedTime, jumpDuration);
                float normalTime = elapsedTime / jumpDuration;

                AnimationHelper.GetObjectOffset(animationObject, track, normalTime, out Vector3? positionOffset, out Quaternion? rotationOffset, out Vector3? scaleOffset, out Quaternion? localRotationOffset, out float?dissolve, out float?dissolveArrow, out float?cuttable);

                if (positionOffset.HasValue)
                {
                    Vector3 moveStartPos = noodleData.MoveStartPos;
                    Vector3 moveEndPos   = noodleData.MoveEndPos;
                    Vector3 jumpEndPos   = noodleData.JumpEndPos;

                    Vector3 offset = positionOffset.Value;
                    _floorStartPosAccessor(ref floorMovement) = moveStartPos + offset;
                    _floorEndPosAccessor(ref floorMovement)   = moveEndPos + offset;
                    _jumpStartPosAccessor(ref noteJump)       = moveEndPos + offset;
                    _jumpEndPosAccessor(ref noteJump)         = jumpEndPos + offset;
                }

                Transform transform = __instance.transform;

                if (rotationOffset.HasValue || localRotationOffset.HasValue)
                {
                    Quaternion worldRotation = noodleData.WorldRotation;
                    Quaternion localRotation = noodleData.LocalRotation;

                    Quaternion worldRotationQuatnerion = worldRotation;
                    if (rotationOffset.HasValue)
                    {
                        worldRotationQuatnerion *= rotationOffset.Value;
                        Quaternion inverseWorldRotation = Quaternion.Inverse(worldRotationQuatnerion);
                        NoteControllerInit._worldRotationJumpAccessor(ref noteJump)              = worldRotationQuatnerion;
                        NoteControllerInit._inverseWorldRotationJumpAccessor(ref noteJump)       = inverseWorldRotation;
                        NoteControllerInit._worldRotationFloorAccessor(ref floorMovement)        = worldRotationQuatnerion;
                        NoteControllerInit._inverseWorldRotationFloorAccessor(ref floorMovement) = inverseWorldRotation;
                    }

                    worldRotationQuatnerion *= localRotation;

                    if (localRotationOffset.HasValue)
                    {
                        worldRotationQuatnerion *= localRotationOffset.Value;
                    }

                    transform.localRotation = worldRotationQuatnerion;
                }

                if (scaleOffset.HasValue)
                {
                    transform.localScale = scaleOffset.Value;
                }

                if (dissolve.HasValue)
                {
                    CutoutEffect cutoutEffect = noodleData.CutoutEffect;
                    if (cutoutEffect == null)
                    {
                        BaseNoteVisuals     baseNoteVisuals     = __instance.gameObject.GetComponent <BaseNoteVisuals>();
                        CutoutAnimateEffect cutoutAnimateEffect = _noteCutoutAnimateEffectAccessor(ref baseNoteVisuals);
                        CutoutEffect[]      cutoutEffects       = _cutoutEffectAccessor(ref cutoutAnimateEffect);
                        cutoutEffect            = cutoutEffects.First(n => n.name != "NoteArrow"); // 1.11 NoteArrow has been added to the CutoutAnimateEffect and we don't want that
                        noodleData.CutoutEffect = cutoutEffect;
                    }

                    cutoutEffect.SetCutout(1 - dissolve.Value);
                }

                if (dissolveArrow.HasValue && __instance.noteData.colorType != ColorType.None)
                {
                    MonoBehaviour disappearingArrowController = noodleData.DisappearingArrowController;
                    if (disappearingArrowController == null)
                    {
                        disappearingArrowController = __instance.gameObject.GetComponent <DisappearingArrowControllerBase <GameNoteController> >();
                        if (disappearingArrowController == null)
                        {
                            disappearingArrowController = __instance.gameObject.GetComponent <DisappearingArrowControllerBase <MultiplayerConnectedPlayerGameNoteController> >();
                        }

                        noodleData.DisappearingArrowController = disappearingArrowController;
                        noodleData.DisappearingArrowMethod     = GetSetArrowTransparency(disappearingArrowController.GetType());
                    }

                    // gross nasty reflection
                    noodleData.DisappearingArrowMethod.Invoke(disappearingArrowController, new object[] { dissolveArrow.Value });
                }

                if (cuttable.HasValue)
                {
                    bool enabled = cuttable.Value >= 1;

                    switch (__instance)
                    {
                    case GameNoteController gameNoteController:
                        BoxCuttableBySaber[] bigCuttableBySaberList = _gameNoteBigCuttableAccessor(ref gameNoteController);
                        foreach (BoxCuttableBySaber bigCuttableBySaber in bigCuttableBySaberList)
                        {
                            if (bigCuttableBySaber.canBeCut != enabled)
                            {
                                bigCuttableBySaber.canBeCut = enabled;
                            }
                        }

                        BoxCuttableBySaber[] smallCuttableBySaberList = _gameNoteSmallCuttableAccessor(ref gameNoteController);
                        foreach (BoxCuttableBySaber smallCuttableBySaber in smallCuttableBySaberList)
                        {
                            if (smallCuttableBySaber.canBeCut != enabled)
                            {
                                smallCuttableBySaber.canBeCut = enabled;
                            }
                        }

                        break;

                    case BombNoteController bombNoteController:
                        CuttableBySaber boxCuttableBySaber = _bombNoteCuttableAccessor(ref bombNoteController);
                        if (boxCuttableBySaber.canBeCut != enabled)
                        {
                            boxCuttableBySaber.canBeCut = enabled;
                        }

                        break;
                    }
                }
            }
        }
예제 #2
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Prefix(NoteController __instance, NoteData ____noteData, NoteMovement ____noteMovement)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (____noteData is CustomNoteData customData)
            {
                CustomNoteData = customData;

                dynamic dynData = customData.customData;

                Track   track           = Trees.at(dynData, "track");
                dynamic animationObject = Trees.at(dynData, "_animation");
                if (track != null || animationObject != null)
                {
                    NoteJump          noteJump      = NoteControllerInit._noteJumpAccessor(ref ____noteMovement);
                    NoteFloorMovement floorMovement = NoteControllerInit._noteFloorMovementAccessor(ref ____noteMovement);

                    // idk i just copied base game time
                    float jumpDuration = _jumpDurationAccessor(ref noteJump);
                    float elapsedTime  = _audioTimeSyncControllerAccessor(ref noteJump).songTime - (____noteData.time - (jumpDuration * 0.5f));
                    elapsedTime = NoteJumpManualUpdate.NoteJumpTimeAdjust(elapsedTime, jumpDuration);
                    float normalTime = elapsedTime / jumpDuration;

                    AnimationHelper.GetObjectOffset(animationObject, track, normalTime, out Vector3? positionOffset, out Quaternion? rotationOffset, out Vector3? scaleOffset, out Quaternion? localRotationOffset, out float?dissolve, out float?dissolveArrow, out float?cuttable);

                    if (positionOffset.HasValue)
                    {
                        Vector3 moveStartPos = Trees.at(dynData, "moveStartPos");
                        Vector3 moveEndPos   = Trees.at(dynData, "moveEndPos");
                        Vector3 jumpEndPos   = Trees.at(dynData, "jumpEndPos");

                        Vector3 offset = positionOffset.Value;
                        _floorStartPosAccessor(ref floorMovement) = moveStartPos + offset;
                        _floorEndPosAccessor(ref floorMovement)   = moveEndPos + offset;
                        _jumpStartPosAccessor(ref noteJump)       = moveEndPos + offset;
                        _jumpEndPosAccessor(ref noteJump)         = jumpEndPos + offset;
                    }

                    Transform transform = __instance.transform;

                    if (rotationOffset.HasValue || localRotationOffset.HasValue)
                    {
                        Quaternion worldRotation = Trees.at(dynData, "worldRotation");
                        Quaternion localRotation = Trees.at(dynData, "localRotation");

                        Quaternion worldRotationQuatnerion = worldRotation;
                        if (rotationOffset.HasValue)
                        {
                            worldRotationQuatnerion *= rotationOffset.Value;
                            Quaternion inverseWorldRotation = Quaternion.Euler(-worldRotationQuatnerion.eulerAngles);
                            NoteControllerInit._worldRotationJumpAccessor(ref noteJump)              = worldRotationQuatnerion;
                            NoteControllerInit._inverseWorldRotationJumpAccessor(ref noteJump)       = inverseWorldRotation;
                            NoteControllerInit._worldRotationFloorAccessor(ref floorMovement)        = worldRotationQuatnerion;
                            NoteControllerInit._inverseWorldRotationFloorAccessor(ref floorMovement) = inverseWorldRotation;
                        }

                        worldRotationQuatnerion *= localRotation;

                        if (localRotationOffset.HasValue)
                        {
                            worldRotationQuatnerion *= localRotationOffset.Value;
                        }

                        transform.localRotation = worldRotationQuatnerion;
                    }

                    if (scaleOffset.HasValue)
                    {
                        transform.localScale = scaleOffset.Value;
                    }

                    if (dissolve.HasValue)
                    {
                        CutoutEffect cutoutEffect = Trees.at(dynData, "cutoutEffect");
                        if (cutoutEffect == null)
                        {
                            BaseNoteVisuals     baseNoteVisuals     = __instance.gameObject.GetComponent <BaseNoteVisuals>();
                            CutoutAnimateEffect cutoutAnimateEffect = _noteCutoutAnimateEffectAccessor(ref baseNoteVisuals);
                            CutoutEffect[]      cutoutEffects       = _cutoutEffectAccessor(ref cutoutAnimateEffect);
                            cutoutEffect = cutoutEffects.First(n => n.name != "NoteArrow"); // 1.11 NoteArrow has been added to the CutoutAnimateEffect and we don't want that
                            dynData.cutoutAnimateEffect = cutoutEffect;
                        }

                        cutoutEffect.SetCutout(1 - dissolve.Value);
                    }

                    if (dissolveArrow.HasValue && __instance.noteData.noteType != NoteType.Bomb)
                    {
                        DisappearingArrowController disappearingArrowController = Trees.at(dynData, "disappearingArrowController");
                        if (disappearingArrowController == null)
                        {
                            disappearingArrowController         = __instance.gameObject.GetComponent <DisappearingArrowController>();
                            dynData.disappearingArrowController = disappearingArrowController;
                        }

                        disappearingArrowController.SetArrowTransparency(dissolveArrow.Value);
                    }

                    if (cuttable.HasValue)
                    {
                        bool enabled = cuttable.Value >= 1;

                        switch (__instance)
                        {
                        case GameNoteController gameNoteController:
                            BoxCuttableBySaber bigCuttableBySaber = _gameNoteBigCuttableAccessor(ref gameNoteController);
                            if (bigCuttableBySaber.enabled != enabled)
                            {
                                bigCuttableBySaber.enabled = enabled;
                                _gameNoteSmallCuttableAccessor(ref gameNoteController).enabled = enabled;
                            }

                            break;

                        case BombNoteController bombNoteController:
                            CuttableBySaber boxCuttableBySaber = _bombNoteCuttableAccessor(ref bombNoteController);
                            if (boxCuttableBySaber.enabled != enabled)
                            {
                                boxCuttableBySaber.enabled = enabled;
                            }

                            break;
                        }
                    }
                }
            }
        }
예제 #3
0
        private static void Prefix(NoteController __instance, NoteData ____noteData, NoteMovement ____noteMovement)
        {
            NoodleData = TryGetObjectData <NoodleObjectData>(____noteData);
            if (NoodleData == null)
            {
                return;
            }

            NoodleNoteData noodleData = (NoodleNoteData)NoodleData;

            IEnumerable <Track>?tracks = noodleData.Track;

            NoodleObjectData.AnimationObjectData?animationObject = noodleData.AnimationObject;
            if (tracks != null || animationObject != null)
            {
                NoteJump          noteJump      = NoteControllerInit._noteJumpAccessor(ref ____noteMovement);
                NoteFloorMovement floorMovement = NoteControllerInit._noteFloorMovementAccessor(ref ____noteMovement);

                // idk i just copied base game time
                float jumpDuration = _jumpDurationAccessor(ref noteJump);
                float elapsedTime  = _audioTimeSyncControllerAccessor(ref noteJump).songTime - (____noteData.time - (jumpDuration * 0.5f));
                elapsedTime = NoteJumpManualUpdate.NoteJumpTimeAdjust(elapsedTime, jumpDuration);
                float normalTime = elapsedTime / jumpDuration;

                Animation.AnimationHelper.GetObjectOffset(animationObject, tracks, normalTime, out Vector3? positionOffset, out Quaternion? rotationOffset, out Vector3? scaleOffset, out Quaternion? localRotationOffset, out float?dissolve, out float?dissolveArrow, out float?cuttable);

                if (positionOffset.HasValue)
                {
                    Vector3 moveStartPos = noodleData.MoveStartPos;
                    Vector3 moveEndPos   = noodleData.MoveEndPos;
                    Vector3 jumpEndPos   = noodleData.JumpEndPos;

                    Vector3 offset = positionOffset.Value;
                    _floorStartPosAccessor(ref floorMovement) = moveStartPos + offset;
                    _floorEndPosAccessor(ref floorMovement)   = moveEndPos + offset;
                    _jumpStartPosAccessor(ref noteJump)       = moveEndPos + offset;
                    _jumpEndPosAccessor(ref noteJump)         = jumpEndPos + offset;
                }

                Transform transform = __instance.transform;

                if (rotationOffset.HasValue || localRotationOffset.HasValue)
                {
                    Quaternion worldRotation = noodleData.WorldRotation;
                    Quaternion localRotation = noodleData.LocalRotation;

                    Quaternion worldRotationQuatnerion = worldRotation;
                    if (rotationOffset.HasValue)
                    {
                        worldRotationQuatnerion *= rotationOffset.Value;
                        Quaternion inverseWorldRotation = Quaternion.Inverse(worldRotationQuatnerion);
                        NoteControllerInit._worldRotationJumpAccessor(ref noteJump)              = worldRotationQuatnerion;
                        NoteControllerInit._inverseWorldRotationJumpAccessor(ref noteJump)       = inverseWorldRotation;
                        NoteControllerInit._worldRotationFloorAccessor(ref floorMovement)        = worldRotationQuatnerion;
                        NoteControllerInit._inverseWorldRotationFloorAccessor(ref floorMovement) = inverseWorldRotation;
                    }

                    worldRotationQuatnerion *= localRotation;

                    if (localRotationOffset.HasValue)
                    {
                        worldRotationQuatnerion *= localRotationOffset.Value;
                    }

                    transform.localRotation = worldRotationQuatnerion;
                }

                if (scaleOffset.HasValue)
                {
                    transform.localScale = scaleOffset.Value;
                }

                if (dissolve.HasValue)
                {
                    if (CutoutManager.NoteCutoutEffects.TryGetValue(__instance, out CutoutEffectWrapper cutoutEffect))
                    {
                        cutoutEffect.SetCutout(dissolve.Value);
                    }
                }

                if (dissolveArrow.HasValue && __instance.noteData.colorType != ColorType.None)
                {
                    if (CutoutManager.NoteDisappearingArrowWrappers.TryGetValue(__instance, out DisappearingArrowWrapper disappearingArrowWrapper))
                    {
                        disappearingArrowWrapper.SetCutout(dissolveArrow.Value);
                    }
                }

                if (cuttable.HasValue)
                {
                    bool enabled = cuttable.Value >= 1;

                    switch (__instance)
                    {
                    case GameNoteController gameNoteController:
                        BoxCuttableBySaber[] bigCuttableBySaberList = _gameNoteBigCuttableAccessor(ref gameNoteController);
                        foreach (BoxCuttableBySaber bigCuttableBySaber in bigCuttableBySaberList)
                        {
                            if (bigCuttableBySaber.canBeCut != enabled)
                            {
                                bigCuttableBySaber.canBeCut = enabled;
                            }
                        }

                        BoxCuttableBySaber[] smallCuttableBySaberList = _gameNoteSmallCuttableAccessor(ref gameNoteController);
                        foreach (BoxCuttableBySaber smallCuttableBySaber in smallCuttableBySaberList)
                        {
                            if (smallCuttableBySaber.canBeCut != enabled)
                            {
                                smallCuttableBySaber.canBeCut = enabled;
                            }
                        }

                        break;

                    case BombNoteController bombNoteController:
                        CuttableBySaber boxCuttableBySaber = _bombNoteCuttableAccessor(ref bombNoteController);
                        if (boxCuttableBySaber.canBeCut != enabled)
                        {
                            boxCuttableBySaber.canBeCut = enabled;
                        }

                        break;
                    }
                }
            }
        }