コード例 #1
0
        static bool Prefix(int lineCount, ref ObstacleData __instance)
        {
            if (__instance.lineIndex > 3 || __instance.lineIndex < 0)
            {
                if (__instance.lineIndex >= 1000 || __instance.lineIndex <= -1000)
                {
                    int newIndex = __instance.lineIndex;

                    if (newIndex <= -1000)
                    {
                        newIndex += 2000;
                    }

                    newIndex = 5001 - __instance.width - newIndex;
                    if (newIndex <= 1000)
                    {
                        newIndex -= 2000;
                    }

                    __instance.SetProperty("lineIndex", newIndex);
                    return(false);
                }
                if (__instance.lineIndex == 4)
                {
                    __instance.SetProperty("lineIndex", -1);
                }
                if (__instance.lineIndex == -1)
                {
                    __instance.SetProperty("lineIndex", 4);
                }
                return(false);
            }
            return(true);
        }
コード例 #2
0
        static void Postfix(int lineCount, ref ObstacleData __instance, ref int __state)
        {
            if (!Plugin.active)
            {
                return;
            }
            bool precisionWidth = __instance.width >= 1000;

            //   Console.WriteLine("Width: " + __instance.width);
            if (__state > 3 || __state < 0 || precisionWidth)
            {
                if (__state >= 1000 || __state <= -1000 || precisionWidth) // precision lineIndex
                {
                    int newIndex = __state;
                    if (newIndex <= -1000) // normalize index values, we'll fix them later
                    {
                        newIndex += 1000;
                    }
                    else if (newIndex >= 1000)
                    {
                        newIndex += -1000;
                    }
                    else
                    {
                        newIndex = newIndex * 1000;               //convert lineIndex to precision if not already
                    }
                    newIndex = (((newIndex - 2000) * -1) + 2000); //flip lineIndex

                    int newWidth = __instance.width;              //normalize wall width
                    if (newWidth < 1000)
                    {
                        newWidth = newWidth * 1000;
                    }
                    else
                    {
                        newWidth -= 1000;
                    }
                    newIndex = newIndex - newWidth;

                    if (newIndex < 0)
                    { //this is where we fix them
                        newIndex -= 1000;
                    }
                    else
                    {
                        newIndex += 1000;
                    }
                    __instance.SetProperty("lineIndex", newIndex);
                }
                else // state > -1000 || state < 1000 assumes no precision width
                {
                    int mirrorLane = (((__state - 2) * -1) + 2); //flip lineIndex
                    __instance.SetProperty("lineIndex", mirrorLane - __instance.width); //adjust for wall width
                }
            }
        }
コード例 #3
0
        private static void Postfix(ObstacleData __instance, int __state)
        {
            bool precisionWidth = __instance.width >= 1000 || __instance.width <= -1000;

            if (__state is <= 3 and >= 0 && !precisionWidth)
            {
                return;
            }
            if (__state is >= 1000 or <= -1000 || precisionWidth) // precision lineIndex
            {
                int newIndex = __state;
                switch (newIndex)
                {
                case <= -1000:     // normalize index values, we'll fix them later
                    newIndex += 1000;
                    break;

                case >= 1000:
                    newIndex += -1000;
                    break;

                default:
                    newIndex *= 1000;     // convert lineIndex to precision if not already
                    break;
                }
                newIndex = (newIndex - 2000) * -1 + 2000; //flip lineIndex

                int newWidth = __instance.width;          // normalize wall width
                if (newWidth < 1000 && newWidth > -1000)
                {
                    newWidth *= 1000;
                }
                else
                {
                    if (newWidth >= 1000)
                    {
                        newWidth -= 1000;
                    }
                    if (newWidth <= -1000)
                    {
                        newWidth += 1000;
                    }
                }
                newIndex -= newWidth;

                if (newIndex < 0) // this is where we fix them
                {
                    newIndex -= 1000;
                }
                else
                {
                    newIndex += 1000;
                }
                __instance.SetProperty("lineIndex", newIndex);
            }