Exemplo n.º 1
0
 public override void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
 {
     PingsWorld.HighlightTile(i, j, ref drawColor);
 }
Exemplo n.º 2
0
 public override void PostUpdateEverything()
 {
     PingsWorld.UpdatePingDespawn();
     PingsWorld.UpdatePingDust();
 }
Exemplo n.º 3
0
 public override void DrawEffects(NPC npc, ref Color drawColor)
 {
     PingsWorld.HighlightNPC(npc, ref drawColor);
 }
Exemplo n.º 4
0
        private void HandleHotKey()
        {
            if (Main.mapFullscreen)
            {
                return;
            }

            bool?     notify = null;
            ModHotKey hotkey = PingsMod.PingHotKey;

            if (hotkey.JustPressed)
            {
                Main.PlaySound(SoundID.MenuOpen);
            }

            if (hotkey.Current)
            {
                if (!notifyAfterHeld)
                {
                    KeyHoldTimer++;
                    if (KeyHoldTimer > KeyHoldTimerMax)
                    {
                        PingsWorld.SpawnDustGoingOutwards(Main.MouseWorld, 10f, DustID.Fire, 10, 0.5f);

                        Main.PlaySound(SoundID.MaxMana);
                        notifyAfterHeld = true;
                    }
                }

                Vector2 size     = new Vector2(32);
                float   distance = 0.8f * Math.Min(KeyHoldTimer / (float)KeyHoldTimerMax, 1f);
                int     type     = 204;
                if (PingCooldownTimer > 0)
                {
                    type = 60;
                }
                PingsWorld.SpawnRotatingDust(Main.MouseWorld - size / 2, distance, size, type);
            }
            else if (hotkey.JustReleased)
            {
                notify = notifyAfterHeld;
            }
            else
            {
                notifyAfterHeld = false;
            }

            if (notify.HasValue && notify.Value is bool notified)
            {
                KeyHoldTimer    = 0;
                notifyAfterHeld = false;
                if (PingCooldownTimer > 0)
                {
                    //+60 so it doesn't say "0s"
                    CombatText.NewText(player.getRect(), Color.Cyan, $"Ping CD: {(PingCooldownTimer + 60) / 60}s");
                    return;
                }

                Ping ping = Ping.MakePing(player, Main.MouseWorld, notified);
                if (ping != null)
                {
                    PingCooldownTimer = 60 * ServerConfig.Instance.PingCooldown + 30;

                    bool?success = PingsWorld.AddOrRemove(ping);

                    if (success.HasValue && success.Value is bool added)
                    {
                        //PingsMod.Log($"Send ping {added}", true, true);
                        new PingPacket(ping).Send();

                        Main.PlaySound(added ? SoundID.Chat : SoundID.MenuClose);
                    }
                }
            }
        }