Example #1
0
        public override void Render()
        {
            base.Render();

            Player player = Scene.Tracker.GetEntity <Player>();

            if (player != null)
            {
                MTexture jumpIndicator = GFX.Game["ExtendedVariantMode/jumpindicator"];

                // draw no indicator in the case of infinite jumps.
                int jumpIndicatorsToDraw = settings.JumpCount == 6 ? 0 : JumpCount.GetJumpBuffer();

                int lines = 1 + (jumpIndicatorsToDraw - 1) / 5;

                for (int line = 0; line < lines; line++)
                {
                    int jumpIndicatorsToDrawOnLine = Math.Min(jumpIndicatorsToDraw, 5);
                    int totalWidth = jumpIndicatorsToDrawOnLine * 6 - 2;
                    for (int i = 0; i < jumpIndicatorsToDrawOnLine; i++)
                    {
                        jumpIndicator.DrawJustified(player.Center + new Vector2(-totalWidth / 2 + i * 6, -15f - line * 6), new Vector2(0f, 0.5f));
                    }
                    jumpIndicatorsToDraw -= jumpIndicatorsToDrawOnLine;
                }
            }
        }
        public override void Render()
        {
            if (!settings.DisplayDashCount)
            {
                // hide the dash count.
                return;
            }

            base.Render();

            float minX = float.MaxValue, maxX = float.MaxValue, minY = float.MaxValue, maxY = float.MaxValue;

            Player player = Scene.Tracker.GetEntity <Player>();

            if (player != null)
            {
                if (hiddenPlayerStates.Contains(player.StateMachine.State))
                {
                    // the player is in one of the states that should have the dash count hidden.
                    return;
                }

                // compute the jump count so that we can put the dash count above it.
                int jumpIndicatorsToDraw = settings.JumpCount == 6 ? 0 : JumpCount.GetJumpBuffer();
                int jumpCountLines       = jumpIndicatorsToDraw == 0 ? 0 : 1 + (jumpIndicatorsToDraw - 1) / 5;

                // draw Madeline's dash count, digit by digit.
                string dashCount  = player.Dashes.ToString();
                int    totalWidth = dashCount.Length * 4 - 1;
                for (int i = 0; i < dashCount.Length; i++)
                {
                    Vector2 position = player.Center + new Vector2(-totalWidth / 2 + i * 4, -18f - jumpCountLines * 6f);
                    numbers[dashCount.ToCharArray()[i] - '0'].DrawOutline(position, new Vector2(0f, 0.5f));

                    if (minX == float.MaxValue)
                    {
                        minX = maxX = position.X;
                        minY = maxY = position.Y;
                    }
                    else
                    {
                        minX = Math.Min(minX, position.X);
                        maxX = Math.Max(maxX, position.X);
                        minY = Math.Min(minY, position.Y);
                        maxY = Math.Max(maxY, position.Y);
                    }
                }
            }

            if (minX != float.MaxValue)
            {
                Collider = new Hitbox(maxX - minX + 5, maxY - minY + 6, minX - 1, minY - 1);
            }
            else
            {
                Collider = null;
            }
        }
Example #3
0
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            NativeArray <JumpCount> chunkJumpCount = chunk.GetNativeArray(JumpCount);

            for (int i = 0; i < chunk.Count; i++)
            {
                chunkJumpCount[i] = new JumpCount()
                {
                    Value = 0
                };
            }
        }
Example #4
0
        public override void Render()
        {
            base.Render();

            float minX = float.MaxValue, maxX = float.MaxValue, minY = float.MaxValue, maxY = float.MaxValue;

            Player player = Scene.Tracker.GetEntity <Player>();

            if (player != null)
            {
                MTexture jumpIndicator = GFX.Game["ExtendedVariantMode/jumpindicator"];

                // draw no indicator in the case of infinite jumps.
                int jumpIndicatorsToDraw = settings.JumpCount == 6 ? 0 : JumpCount.GetJumpBuffer();

                int lines = 1 + (jumpIndicatorsToDraw - 1) / 5;

                for (int line = 0; line < lines; line++)
                {
                    int jumpIndicatorsToDrawOnLine = Math.Min(jumpIndicatorsToDraw, 5);
                    int totalWidth = jumpIndicatorsToDrawOnLine * 6 - 2;
                    for (int i = 0; i < jumpIndicatorsToDrawOnLine; i++)
                    {
                        Vector2 position = player.Center + new Vector2(-totalWidth / 2 + i * 6, -15f - line * 6);
                        jumpIndicator.DrawJustified(position, new Vector2(0f, 0.5f));

                        if (minX == float.MaxValue)
                        {
                            minX = maxX = position.X;
                            minY = maxY = position.Y;
                        }
                        else
                        {
                            minX = Math.Min(minX, position.X);
                            maxX = Math.Max(maxX, position.X);
                            minY = Math.Min(minY, position.Y);
                            maxY = Math.Max(maxY, position.Y);
                        }
                    }
                    jumpIndicatorsToDraw -= jumpIndicatorsToDrawOnLine;
                }
            }

            if (minX != float.MaxValue)
            {
                Collider = new Hitbox(maxX - minX + 4, maxY - minY + 3, minX, minY - 2);
            }
            else
            {
                Collider = null;
            }
        }
        internal static void OnLoad()
        {
            bool extendedVariantModeInstalled = Everest.Loader.DependencyLoaded(new EverestModuleMetadata
            {
                Name = "ExtendedVariantMode", Version = new Version(0, 15, 20)
            });

            if (extendedVariantModeInstalled)
            {
                all.Add(new SaveLoadAction(
                            (savedValues, level) => {
                    savedValues.Add("jumpBuffer", JumpCount.GetJumpBuffer());
                },
                            (savedValues, level) => {
                    typeof(JumpCount).SetFieldValue("jumpBuffer", savedValues["jumpBuffer"]);
                }
                            ));
            }
        }
    public string GetValueString(RecordDataType dataType)
    {
        switch (dataType)
        {
        case RecordDataType.PlayTime:
            return((Mathf.Floor(PlayTime * 100f) / 100f).ToString() + "s");

        case RecordDataType.FallCount:
            return(FallCount.ToString());

        case RecordDataType.JumpCount:
            return(JumpCount.ToString());

        case RecordDataType.MovedDistance:
            return(MovedDistance.ToString("#.#") + "M");

        case RecordDataType.HitCount:
            return(HitCount.ToString());
        }

        return(null);
    }
Example #7
0
        public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            NativeArray <PhysicsVelocity> chunkVelocities    = chunk.GetNativeArray(Velocity);
            NativeArray <JumpCount>       chunkJumpCount     = chunk.GetNativeArray(JumpCount);
            NativeArray <JumpForce>       chunkJumpForces    = chunk.GetNativeArray(JumpForce);
            NativeArray <MaxJumpCount>    chunkMaxJumpCounts = chunk.GetNativeArray(MaxJumpCount);
            NativeArray <JumpTrigger>     chunkJumpTrigger   = chunk.GetNativeArray(JumpTrigger);

            for (int i = 0; i < chunk.Count; i++)
            {
                if (!chunkJumpTrigger[i].Value)
                {
                    return;
                }

                chunkJumpTrigger[i] = new JumpTrigger()
                {
                    Value = false
                };

                chunkJumpCount[i] = new JumpCount()
                {
                    Value = chunkJumpCount[i].Value + 1
                };

                if (chunkJumpCount[i].Value > chunkMaxJumpCounts[i].Value)
                {
                    return;
                }

                chunkVelocities[i] = new PhysicsVelocity
                {
                    Angular = chunkVelocities[i].Angular,
                    Linear  = math.select(chunkVelocities[i].Linear + new float3(0, chunkJumpForces[i].Value, 0),
                                          new float3(chunkVelocities[i].Linear.x, chunkJumpForces[i].Value, chunkVelocities[i].Linear.z),
                                          chunkJumpForces[i].IsAbsolute)
                };
            }
        }
        public JumpRefill(EntityData data, Vector2 offset, bool extraJumpRefill)
            : base(data, offset)
        {
            this.extraJumpRefill = extraJumpRefill;
            extraJumps           = data.Int("extraJumps", 1);
            capped           = data.Bool("capped", false);
            cap              = data.Int("cap", -1);
            respawnTime      = data.Float("respawnTime", defaultValue: 2.5f);
            jumpCountVariant = ExtendedVariantsModule.Instance.VariantHandlers[ExtendedVariantsModule.Variant.JumpCount] as JumpCount;

            string texture = data.Attr("texture", "ExtendedVariantMode/jumprefill");

            // clean up stuff from vanilla we don't want.
            List <Component> toRemove = new List <Component>();

            foreach (Component c in this)
            {
                if (c.GetType() == typeof(Sprite) || c.GetType() == typeof(Image) || c.GetType() == typeof(PlayerCollider) || c.GetType() == typeof(Wiggler))
                {
                    toRemove.Add(c);
                }
            }
            Remove(toRemove.ToArray());

            // load our own sprites and create a wiggler to attach to them.
            Sprite  sprite;
            Sprite  flash;
            Image   outline;
            Wiggler wiggler;

            Add(outline = new Image(GFX.Game[$"objects/{texture}/outline"]));
            outline.CenterOrigin();
            outline.Visible = false;

            bool oneUseSprite = data.Bool("oneUse") && Everest.Loader.DependencyLoaded(new EverestModuleMetadata {
                Name = "BetterRefillGems", Version = new Version(1, 0, 1)
            }) &&
                                betterRefillGemsEnabled() && GFX.Game.Has($"objects/{texture}/oneuse_idle00");

            Add(sprite = new Sprite(GFX.Game, oneUseSprite ? $"objects/{texture}/oneuse_idle" : $"objects/{texture}/idle"));
            sprite.AddLoop("idle", "", 0.1f);
            sprite.Play("idle");
            sprite.CenterOrigin();

            Add(flash = new Sprite(GFX.Game, $"objects/{texture}/flash"));
            flash.Add("flash", "", 0.05f);
            flash.OnFinish = delegate {
                flash.Visible = false;
            };
            flash.CenterOrigin();

            Add(wiggler = Wiggler.Create(1f, 4f, delegate(float v) {
                sprite.Scale = (flash.Scale = Vector2.One * (1f + v * 0.2f));
            }));

            f_sprite.SetValue(this, sprite);
            f_outline.SetValue(this, outline);
            f_flash.SetValue(this, flash);
            f_wiggler.SetValue(this, wiggler);

            // wire the collider to our implementation instead.
            Add(new PlayerCollider(OnPlayer));
        }
 public void AddJump()
 {
     JumpCount.IncreaseValue(1);
 }