Exemple #1
0
        public static EaseInSubMenu CreateSubMenu(TextMenu menu, bool inGame)
        {
            subMenuItem = new EaseInSubMenu("Show Hitboxes".ToDialogText(), false).Apply(subMenu => {
                subMenu.Add(new TextMenu.OnOff("Enabled".ToDialogText(), Settings.ShowHitboxes).Change(value => Settings.ShowHitboxes = value));
                subMenu.Add(new TextMenu.OnOff("Show Trigger Hitboxes".ToDialogText(), Settings.ShowTriggerHitboxes).Change(value =>
                                                                                                                            Settings.ShowTriggerHitboxes = value));
                subMenu.Add(new TextMenu.OnOff("Show Unloaded Rooms Hitboxes".ToDialogText(), Settings.ShowUnloadedRoomsHitboxes).Change(value =>
                                                                                                                                         Settings.ShowUnloadedRoomsHitboxes = value));
                subMenu.Add(new TextMenu.Option <ActualCollideHitboxType>("Actual Collide Hitboxes".ToDialogText()).Apply(option => {
                    Array enumValues = Enum.GetValues(typeof(ActualCollideHitboxType));
                    foreach (ActualCollideHitboxType value in enumValues)
                    {
                        option.Add(value.ToString().SpacedPascalCase().ToDialogText(), value, value.Equals(Settings.ShowActualCollideHitboxes));
                    }

                    option.Change(value => Settings.ShowActualCollideHitboxes = value);
                }));
                subMenu.Add(new TextMenu.OnOff("Simplified Hitboxes".ToDialogText(), Settings.SimplifiedHitboxes).Change(value =>
                                                                                                                         Settings.SimplifiedHitboxes = value));
                subMenu.Add(HitboxColor.CreateEntityHitboxColorButton(menu, inGame));
                subMenu.Add(HitboxColor.CreateTriggerHitboxColorButton(menu, inGame));
                subMenu.Add(HitboxColor.CreatePlatformHitboxColorButton(menu, inGame));
            });
            return(subMenuItem);
        }
Exemple #2
0
 public static void Unload()
 {
     HitboxTriggerSpikes.Unload();
     ActualEntityCollideHitbox.Unload();
     HitboxFixer.Unload();
     HitboxSimplified.Unload();
     HitboxHideTrigger.Unload();
     HitboxColor.Unload();
     HitboxFinalBoss.Unload();
     HitboxOptimized.Unload();
     HitboxNpc.Unload();
     HitboxRoomBoundary.Unload();
 }
Exemple #3
0
 public static void Unload()
 {
     HitboxTriggerSpikes.Unload();
     ActualEntityCollideHitbox.Unload();
     ActualPlayerCollideHitbox.Unload();
     HitboxFixer.Unload();
     HitboxSimplified.Unload();
     HitboxColor.Unload();
     HitboxFinalBoss.Unload();
     On.Monocle.Entity.DebugRender         -= ModHitbox;
     IL.Celeste.PlayerCollider.DebugRender -= PlayerColliderOnDebugRender;
     On.Celeste.PlayerCollider.DebugRender -= AddFeatherHitbox;
     On.Monocle.Circle.Render           -= CircleOnRender;
     On.Celeste.SoundSource.DebugRender -= SoundSource_DebugRender;
 }
        private static void DrawSpikesHitboxes(TriggerSpikes triggerSpikes, Camera camera)
        {
            triggerSpikes.Collider?.Render(camera, HitboxColor.EntityColorInverselyLessAlpha);

            Vector2 offset, value;
            bool    vertical = false;

            switch (TriggerSpikesDirection(triggerSpikes))
            {
            case TriggerSpikes.Directions.Up:
                offset = new Vector2(-2f, -4f);
                value  = new Vector2(1f, 0f);
                break;

            case TriggerSpikes.Directions.Down:
                offset = new Vector2(-2f, 0f);
                value  = new Vector2(1f, 0f);
                break;

            case TriggerSpikes.Directions.Left:
                offset   = new Vector2(-4f, -2f);
                value    = new Vector2(0f, 1f);
                vertical = true;
                break;

            case TriggerSpikes.Directions.Right:
                offset   = new Vector2(0f, -2f);
                value    = new Vector2(0f, 1f);
                vertical = true;
                break;

            default:
                return;
            }

            Array spikes = TriggerSpikesSpikes(triggerSpikes) as Array;

            for (int i = 0; i < spikes.Length; i++)
            {
                object spikeInfo = spikes.GetValue(i);
                if (triggerSpikesTriggered == null)
                {
                    triggerSpikesTriggered = spikeInfo.GetType().GetField("Triggered", BindingFlags.Instance | BindingFlags.Public);
                }

                if (triggerSpikesLerp == null)
                {
                    triggerSpikesLerp = spikeInfo.GetType().GetField("Lerp", BindingFlags.Instance | BindingFlags.Public);
                }

                if ((bool)triggerSpikesTriggered.GetValue(spikeInfo) && (float)triggerSpikesLerp.GetValue(spikeInfo) >= 1f)
                {
                    Vector2 position = triggerSpikes.Position + value * (2 + i * 4) + offset;

                    int num = 1;
                    for (int j = i + 1; j < spikes.Length; j++)
                    {
                        object nextSpikeInfo = spikes.GetValue(j);
                        if ((bool)triggerSpikesTriggered.GetValue(nextSpikeInfo) && (float)triggerSpikesLerp.GetValue(nextSpikeInfo) >= 1f)
                        {
                            num++;
                            i++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    Draw.HollowRect(position, 4f * (vertical ? 1 : num), 4f * (vertical ? num : 1),
                                    HitboxColor.GetCustomColor(Color.Red, triggerSpikes));
                }
            }
        }
        private static void DrawSpikesHitboxes(TriggerSpikesOriginal triggerSpikes, Camera camera)
        {
            triggerSpikes.Collider?.Render(camera, HitboxColor.EntityColorInverselyLessAlpha);

            Vector2 offset;
            float   width, height;
            bool    vertical = false;

            switch (TriggerSpikesOriginalDirection(triggerSpikes))
            {
            case TriggerSpikesOriginal.Directions.Up:
                width  = 8f;
                height = 3f;
                offset = new Vector2(-4f, -4f);
                break;

            case TriggerSpikesOriginal.Directions.Down:
                width  = 8f;
                height = 3f;
                offset = new Vector2(-4f, 1f);
                break;

            case TriggerSpikesOriginal.Directions.Left:
                width    = 3f;
                height   = 8f;
                offset   = new Vector2(-4f, -4f);
                vertical = true;
                break;

            case TriggerSpikesOriginal.Directions.Right:
                width    = 3f;
                height   = 8f;
                offset   = new Vector2(1f, -4f);
                vertical = true;
                break;

            default:
                return;
            }

            Array spikes = TriggerSpikesOriginalSpikes(triggerSpikes) as Array;

            for (int i = 0; i < spikes.Length; i++)
            {
                object spikeInfo = spikes.GetValue(i);

                if (triggerSpikesOriginalTriggered == null)
                {
                    triggerSpikesOriginalTriggered = spikeInfo.GetType().GetField("Triggered", BindingFlags.Instance | BindingFlags.Public);
                }

                if (triggerSpikesOriginalLerp == null)
                {
                    triggerSpikesOriginalLerp = spikeInfo.GetType().GetField("Lerp", BindingFlags.Instance | BindingFlags.Public);
                }

                if (triggerSpikesOriginalPosition == null)
                {
                    triggerSpikesOriginalPosition = spikeInfo.GetType().GetField("Position", BindingFlags.Instance | BindingFlags.Public);
                }

                if ((bool)triggerSpikesOriginalTriggered.GetValue(spikeInfo) && (float)triggerSpikesOriginalLerp.GetValue(spikeInfo) >= 1)
                {
                    int num = 1;
                    for (int j = i + 1; j < spikes.Length; j++)
                    {
                        object nextSpikeInfo = spikes.GetValue(j);
                        if ((bool)triggerSpikesOriginalTriggered.GetValue(nextSpikeInfo) &&
                            (float)triggerSpikesOriginalLerp.GetValue(nextSpikeInfo) >= 1)
                        {
                            num++;
                            i++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    Vector2 position = (Vector2)triggerSpikesOriginalPosition.GetValue(spikeInfo) + triggerSpikes.Position + offset;
                    Draw.HollowRect(position, width * (vertical ? 1 : num), height * (vertical ? num : 1),
                                    HitboxColor.GetCustomColor(Color.Red, triggerSpikes));
                }
            }
        }
        private static void Entity_DebugRender(On.Monocle.Entity.orig_DebugRender orig, Entity self, Camera camera)
        {
            if (!CelesteTasModule.Settings.ShowHitboxes || !(self is TriggerSpikes) && !(self is TriggerSpikesOriginal))
            {
                orig(self, camera);
                return;
            }

            self.Collider?.Render(camera, HitboxColor.EntityColorInverselyLessAlpha);

            if (self is TriggerSpikes)
            {
                Vector2 offset, value;
                bool    vertical = false;
                switch (TriggerSpikesDirection.GetValue(self))
                {
                case TriggerSpikes.Directions.Up:
                    offset = new Vector2(-2f, -4f);
                    value  = new Vector2(1f, 0f);
                    break;

                case TriggerSpikes.Directions.Down:
                    offset = new Vector2(-2f, 0f);
                    value  = new Vector2(1f, 0f);
                    break;

                case TriggerSpikes.Directions.Left:
                    offset   = new Vector2(-4f, -2f);
                    value    = new Vector2(0f, 1f);
                    vertical = true;
                    break;

                case TriggerSpikes.Directions.Right:
                    offset   = new Vector2(0f, -2f);
                    value    = new Vector2(0f, 1f);
                    vertical = true;
                    break;

                default:
                    return;
                }

                Array spikes = TriggerSpikesSpikes.GetValue(self) as Array;
                for (int i = 0; i < spikes.Length; i++)
                {
                    object spikeInfo = spikes.GetValue(i);
                    if (triggerSpikesTriggered == null)
                    {
                        triggerSpikesTriggered = spikeInfo.GetType().GetField("Triggered", BindingFlags.Instance | BindingFlags.Public);
                    }

                    if (triggerSpikesLerp == null)
                    {
                        triggerSpikesLerp = spikeInfo.GetType().GetField("Lerp", BindingFlags.Instance | BindingFlags.Public);
                    }

                    if ((bool)triggerSpikesTriggered.GetValue(spikeInfo) && (float)triggerSpikesLerp.GetValue(spikeInfo) >= 1f)
                    {
                        Vector2 position = self.Position + value * (2 + i * 4) + offset;

                        int num = 1;
                        for (int j = i + 1; j < spikes.Length; j++)
                        {
                            object nextSpikeInfo = spikes.GetValue(j);
                            if ((bool)triggerSpikesTriggered.GetValue(nextSpikeInfo) && (float)triggerSpikesLerp.GetValue(nextSpikeInfo) >= 1f)
                            {
                                num++;
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }

                        Draw.HollowRect(position, 4f * (vertical ? 1 : num), 4f * (vertical ? num : 1),
                                        HitboxColor.GetCustomColor(Color.Red, self));
                    }
                }
            }
            else if (self is TriggerSpikesOriginal)
            {
                Vector2 offset;
                float   width, height;
                bool    vertical = false;
                switch (TriggerSpikesOriginalDirection.GetValue(self))
                {
                case TriggerSpikesOriginal.Directions.Up:
                    width  = 8f;
                    height = 3f;
                    offset = new Vector2(-4f, -4f);
                    break;

                case TriggerSpikesOriginal.Directions.Down:
                    width  = 8f;
                    height = 3f;
                    offset = new Vector2(-4f, 1f);
                    break;

                case TriggerSpikesOriginal.Directions.Left:
                    width    = 3f;
                    height   = 8f;
                    offset   = new Vector2(-4f, -4f);
                    vertical = true;
                    break;

                case TriggerSpikesOriginal.Directions.Right:
                    width    = 3f;
                    height   = 8f;
                    offset   = new Vector2(1f, -4f);
                    vertical = true;
                    break;

                default:
                    return;
                }

                Array spikes = TriggerSpikesOriginalSpikes.GetValue(self) as Array;
                for (int i = 0; i < spikes.Length; i++)
                {
                    object spikeInfo = spikes.GetValue(i);

                    if (triggerSpikesOriginalTriggered == null)
                    {
                        triggerSpikesOriginalTriggered = spikeInfo.GetType().GetField("Triggered", BindingFlags.Instance | BindingFlags.Public);
                    }

                    if (triggerSpikesOriginalLerp == null)
                    {
                        triggerSpikesOriginalLerp = spikeInfo.GetType().GetField("Lerp", BindingFlags.Instance | BindingFlags.Public);
                    }

                    if (triggerSpikesOriginalPosition == null)
                    {
                        triggerSpikesOriginalPosition = spikeInfo.GetType().GetField("Position", BindingFlags.Instance | BindingFlags.Public);
                    }

                    if ((bool)triggerSpikesOriginalTriggered.GetValue(spikeInfo) && (float)triggerSpikesOriginalLerp.GetValue(spikeInfo) >= 1)
                    {
                        int num = 1;
                        for (int j = i + 1; j < spikes.Length; j++)
                        {
                            object nextSpikeInfo = spikes.GetValue(j);
                            if ((bool)triggerSpikesOriginalTriggered.GetValue(nextSpikeInfo) &&
                                (float)triggerSpikesOriginalLerp.GetValue(nextSpikeInfo) >= 1)
                            {
                                num++;
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }

                        Vector2 position = (Vector2)triggerSpikesOriginalPosition.GetValue(spikeInfo) + self.Position + offset;
                        Draw.HollowRect(position, width * (vertical ? 1 : num), height * (vertical ? num : 1),
                                        HitboxColor.GetCustomColor(Color.Red, self));
                    }
                }
            }
        }
Exemple #7
0
 private static void CmdChangeSolidTilesHitboxColor(string color)
 {
     CelesteTasModule.Settings.SolidTilesHitboxColor = HitboxColor.HexToColor(color, CelesteTasModule.Settings.SolidTilesHitboxColor);
 }
Exemple #8
0
 private static void CmdChangeTriggerHitboxColor(string color)
 {
     CelesteTasModule.Settings.TriggerHitboxColor = HitboxColor.HexToColor(color, CelesteTasModule.Settings.TriggerHitboxColor);
 }