예제 #1
0
#pragma warning disable SA1313 // Parameter names should begin with lower-case letter
        private static void Prefix(
            ObstacleController __instance,
            ObstacleData ____obstacleData,
            AudioTimeSyncController ____audioTimeSyncController,
            float ____startTimeOffset,
            ref Vector3 ____startPos,
            ref Vector3 ____midPos,
            ref Vector3 ____endPos,
            float ____move1Duration,
            float ____move2Duration,
            float ____obstacleDuration,
            ref Quaternion ____worldRotation,
            ref Quaternion ____inverseWorldRotation,
            ref Bounds ____bounds)
#pragma warning restore SA1313 // Parameter names should begin with lower-case letter
        {
            if (____obstacleData is CustomObstacleData customData)
            {
                dynamic dynData = customData.customData;

                Track   track           = Trees.at(dynData, "track");
                dynamic animationObject = Trees.at(dynData, "_animation");
                if (track != null || animationObject != null)
                {
                    // idk i just copied base game time
                    float elapsedTime = ____audioTimeSyncController.songTime - ____startTimeOffset;
                    float normalTime  = (elapsedTime - ____move1Duration) / (____move2Duration + ____obstacleDuration);

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

                    if (positionOffset.HasValue)
                    {
                        Vector3 startPos = Trees.at(dynData, "startPos");
                        Vector3 midPos   = Trees.at(dynData, "midPos");
                        Vector3 endPos   = Trees.at(dynData, "endPos");

                        Vector3 offset = positionOffset.Value;
                        ____startPos = startPos + offset;
                        ____midPos   = midPos + offset;
                        ____endPos   = endPos + 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);
                            ____worldRotation        = worldRotationQuatnerion;
                            ____inverseWorldRotation = inverseWorldRotation;
                        }

                        worldRotationQuatnerion *= localRotation;

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

                        transform.localRotation = worldRotationQuatnerion;
                    }

                    bool cuttableEnabled = true;
                    if (cuttable.HasValue)
                    {
                        cuttableEnabled = cuttable.Value >= 1;
                        if (cuttableEnabled)
                        {
                            if (____bounds.size != _vectorZero)
                            {
                                ____bounds.size = _vectorZero;
                            }
                        }
                        else
                        {
                            Vector3 boundsSize = Trees.at(dynData, "boundsSize");
                            if (____bounds.size != boundsSize)
                            {
                                ____bounds.size = boundsSize;
                            }
                        }
                    }

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

                    if (dissolve.HasValue)
                    {
                        CutoutAnimateEffect cutoutAnimateEffect = Trees.at(dynData, "cutoutAnimateEffect");
                        if (cutoutAnimateEffect == null)
                        {
                            ObstacleDissolve obstacleDissolve = __instance.gameObject.GetComponent <ObstacleDissolve>();
                            cutoutAnimateEffect         = _obstacleCutoutAnimateEffectAccessor(ref obstacleDissolve);
                            dynData.cutoutAnimateEffect = cutoutAnimateEffect;
                        }

                        cutoutAnimateEffect.SetCutout(1 - dissolve.Value);
                    }
                }
            }
        }
예제 #2
0
        private static void Prefix(
            ObstacleController __instance,
            ObstacleData ____obstacleData,
            AudioTimeSyncController ____audioTimeSyncController,
            float ____startTimeOffset,
            ref Vector3 ____startPos,
            ref Vector3 ____midPos,
            ref Vector3 ____endPos,
            float ____move1Duration,
            float ____move2Duration,
            float ____obstacleDuration,
            ref Quaternion ____worldRotation,
            ref Quaternion ____inverseWorldRotation,
            ref Bounds ____bounds)
        {
            if (__instance is MultiplayerConnectedPlayerObstacleController)
            {
                return;
            }

            NoodleObstacleData noodleData = (NoodleObstacleData)NoodleObjectDatas[____obstacleData];

            Track track = noodleData.Track;

            NoodleObjectData.AnimationObjectData animationObject = noodleData.AnimationObject;
            if (track != null || animationObject != null)
            {
                // idk i just copied base game time
                float elapsedTime = ____audioTimeSyncController.songTime - ____startTimeOffset;
                float normalTime  = (elapsedTime - ____move1Duration) / (____move2Duration + ____obstacleDuration);

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

                if (positionOffset.HasValue)
                {
                    Vector3 startPos = noodleData.StartPos;
                    Vector3 midPos   = noodleData.MidPos;
                    Vector3 endPos   = noodleData.EndPos;

                    Vector3 offset = positionOffset.Value;
                    ____startPos = startPos + offset;
                    ____midPos   = midPos + offset;
                    ____endPos   = endPos + 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);
                        ____worldRotation        = worldRotationQuatnerion;
                        ____inverseWorldRotation = inverseWorldRotation;
                    }

                    worldRotationQuatnerion *= localRotation;

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

                    transform.localRotation = worldRotationQuatnerion;
                }

                bool cuttableEnabled = true;
                if (cuttable.HasValue)
                {
                    cuttableEnabled = cuttable.Value >= 1;
                    if (cuttableEnabled)
                    {
                        if (____bounds.size != _vectorZero)
                        {
                            ____bounds.size = _vectorZero;
                        }
                    }
                    else
                    {
                        Vector3 boundsSize = noodleData.BoundsSize;
                        if (____bounds.size != boundsSize)
                        {
                            ____bounds.size = boundsSize;
                        }
                    }
                }

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

                if (dissolve.HasValue)
                {
                    CutoutAnimateEffect cutoutAnimateEffect = noodleData.CutoutAnimateEffect;
                    if (cutoutAnimateEffect == null)
                    {
                        ObstacleDissolve obstacleDissolve = __instance.gameObject.GetComponent <ObstacleDissolve>();
                        cutoutAnimateEffect            = _obstacleCutoutAnimateEffectAccessor(ref obstacleDissolve);
                        noodleData.CutoutAnimateEffect = cutoutAnimateEffect;
                    }

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

            if (noodleData.DoUnhide)
            {
                __instance.hide = false;
            }
        }