Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_VisitedMapPlugin : BasePlugin, IInGameTopPainter, IInGameWorldPainter, IAfterCollectHandler, INewAreaHandler {
- public float offsetY { get; set; }
- public string visitedMessage { get; set; }
- public IFont textFont { get; set; }
- public WorldDecoratorCollection PortalDecorator { get; set; }
- public bool Cow_Enable { get; set; }
- public bool Cow_InTownOnly { get; set; }
- public float Cow_xPos { get; set; }
- public float Cow_yPos { get; set; }
- public string Cow_Message { get; set; }
- public IFont Cow_Font { get; set; }
- private bool isListEmpty { get; set; } = true;
- private uint[] currentSno { get; set; } = new uint[] { 0, 0, 0, 0 };
- private List<uint> visitedList { get; set; } = new List<uint>();
- private List<uint> blackList { get; set; } = new List<uint> {
- 380773, 380774, 483058, 483085, // Vault
- 257116, 256767, 256106, 256742, 374239, // Uber
- };
- public DAV_VisitedMapPlugin() {
- Enabled = true;
- Order = 30000;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- offsetY = 2f;
- visitedMessage = "Visited";
- textFont = Hud.Render.CreateFont("Arial", 7f, 255, 255, 128, 51, true, true, 160, 51, 51, 51, true);
- Cow_Enable = true;
- Cow_InTownOnly = false;
- Cow_xPos = 120;
- Cow_yPos = 20;
- Cow_Message = "Not Cow Level Opened";
- Cow_Font = Hud.Render.CreateFont("Arial", 10f, 255, 255, 128, 51, true, true, 160, 51, 51, 51, true);
- PortalDecorator = new WorldDecoratorCollection(
- new MapLabelDecorator(Hud) {
- LabelFont = Hud.Render.CreateFont("Arial", 6f, 255, 255, 128, 51, true, true, 160, 51, 51, 51, true),
- RadiusOffset = 7.0f,
- Up = true,
- }
- );
- }
- public void PaintTopInGame(ClipState clipState) {
- if (isListEmpty) return;
- if (clipState != ClipState.AfterClip) return;
- if (!Hud.Render.WorldMapUiElement.Visible || Hud.Render.ActMapUiElement.Visible) return;
- var mapCurrentAct = Hud.Game.ActMapCurrentAct;
- var w = 220 * Hud.Window.HeightUiRatio;
- foreach (var waypoint in Hud.Game.ActMapWaypoints.Where(x => x.BountyAct == mapCurrentAct)) {
- if (!visitedList.Contains(waypoint.TargetSnoArea.Sno)) continue;
- var x = Hud.Render.WorldMapUiElement.Rectangle.X + waypoint.CoordinateOnMapUiElement.X * Hud.Window.HeightUiRatio;
- var y = Hud.Render.WorldMapUiElement.Rectangle.Y + waypoint.CoordinateOnMapUiElement.Y * Hud.Window.HeightUiRatio;
- var layout = textFont.GetTextLayout(visitedMessage);
- textFont.DrawText(layout, x + (w - layout.Metrics.Width) / 2, y - layout.Metrics.Height + offsetY);
- }
- }
- public void PaintWorld(WorldLayer layer) {
- if (isListEmpty) return;
- if (Cow_Enable && Hud.Game.SpecialArea == SpecialArea.None && visitedList.Contains(434650)) {
- if (!Cow_InTownOnly || (Cow_InTownOnly && Hud.Game.IsInTown))
- Cow_Font.DrawText(Cow_Message, Cow_xPos, Cow_yPos);
- }
- foreach (var portal in Hud.Game.Portals) {
- if (portal.TargetArea.Code.StartsWith("x1_lr_l")) continue; // Skip Rift Map
- if (blackList.Contains(portal.TargetArea.Sno)) continue;
- if (!visitedList.Contains(portal.TargetArea.Sno)) continue;
- PortalDecorator.Paint(layer, null, portal.FloorCoordinate, visitedMessage);
- }
- }
- public void AfterCollect() {
- if (!Hud.Game.IsInGame) return;
- foreach (var player in Hud.Game.Players) {
- if (player.IsInTown) continue;
- if (player.SnoArea.Sno == currentSno[player.Index]) continue;
- if (visitedList.Contains(player.SnoArea.Sno)) continue;
- visitedList.Add(player.SnoArea.Sno);
- isListEmpty = false;
- currentSno[player.Index] = player.SnoArea.Sno;
- }
- }
- public void OnNewArea(bool newGame, ISnoArea area) {
- if (newGame) {
- isListEmpty = true;
- visitedList.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement