Advertisement
JackCeparou

DoorsPlugin

Feb 9th, 2017
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.JackCeparouCompass
  7. {
  8.     public class DoorsPlugin : BasePlugin
  9.     {
  10.         public WorldDecoratorCollection DoorsDecorators { get; set; }
  11.         public WorldDecoratorCollection BreakablesDoorsDecorators { get; set; }
  12.         public WorldDecoratorCollection BridgesDecorators { get; set; }
  13.  
  14.         public bool OutOfTownOnly { get; set; }
  15.         public bool GroundLabelsOutOfScreenOnly { get; set; }
  16.  
  17.         private readonly uint[] bridgesIds = new uint[] { 309432, 54850, 404043, 198125 };
  18.         private readonly HashSet<uint> breakableDoorsIds = new HashSet<uint> { 55325, 427495, 5792, 95481, 379048, 95481, 230324, };// 258064 };
  19.         private readonly HashSet<uint> doorsIdsBlackList = new HashSet<uint>() {
  20.             197939, 169502, 214333, 181195, 190236, // A2 to belial
  21.             167185, // A2 Alcarnus
  22.             200371, 5503, // A2 City
  23.             198977, 52685, // A3 rakkis crossing
  24.             112316, // A3 stonefort
  25.             356879,
  26.         };
  27.         //170245
  28.         private readonly HashSet<uint> doorsDebugWhiteList = new HashSet<uint>() {
  29.             309222, 308241, 454, // ??
  30.             309812, // X1 ??
  31.             104888,
  32.             258595,
  33.             4267,
  34.             362651,
  35.             447673,
  36.             162386,
  37.             415665,
  38.             4393,
  39.             219702,
  40.             250031,
  41.             153752,
  42.             //102711
  43.             343582,
  44.             230324,
  45.         };
  46.  
  47.         public DoorsPlugin()
  48.         {
  49.             Enabled = true;
  50.             GroundLabelsOutOfScreenOnly = false;
  51.         }
  52.  
  53.         public override void Load(IController hud)
  54.         {
  55.             base.Load(hud);
  56.  
  57.             DoorsDecorators = CreateDecorators(255, 216, 0);
  58.             BreakablesDoorsDecorators = CreateDecorators(250, 0, 0);
  59.             BridgesDecorators = CreateDecorators(0, 195, 255);
  60.         }
  61.  
  62.         public override void PaintWorld(WorldLayer layer)
  63.         {
  64.             if (Hud.Game.IsInTown && OutOfTownOnly) return;
  65.  
  66.             Hud.Game.Actors
  67.                 .Where(a => a.GizmoType == GizmoType.Door || a.GizmoType == GizmoType.BreakableDoor)
  68.                 .ForEach(door =>
  69.                 {
  70.                     if (breakableDoorsIds.Contains(door.SnoActor.Sno))
  71.                     {
  72.                         PaintActor(layer, door, BreakablesDoorsDecorators);
  73.                     }
  74.                     else if (door.GizmoType == GizmoType.Door && !door.IsOperated && !door.IsDisabled && !doorsIdsBlackList.Contains(door.SnoActor.Sno))
  75.                     {
  76.                         PaintActor(layer, door, bridgesIds.Contains(door.SnoActor.Sno) ? BridgesDecorators : DoorsDecorators);
  77.                         //if (!doorsDebugWhiteList.Contains(door.SnoActor.Sno))
  78.                             //Simon.Says.Debug(string.Format("DOOR?? {0} {1} {2} {3} {4} {5} {6}", door.SnoActor.Sno, door.SnoActor.NameLocalized, door.IsOperated, door.IsClickable, door.IsDisabled, door.SnoActor.Kind, door.SnoActor.Code));/**/
  79.                     }
  80.  
  81.                     //if (!doorsDebugWhiteList.Contains(door.SnoActor.Sno))
  82.                         //Simon.Says.Debug(string.Format("DOOR?? {0} {1} {2} {3} {4} {5} {6}", door.SnoActor.Sno, door.SnoActor.NameLocalized, door.IsOperated, door.IsClickable, door.IsDisabled, door.SnoActor.Kind, door.SnoActor.Code));/**/
  83.                 });
  84.         }
  85.  
  86.         private WorldDecoratorCollection CreateDecorators(int r, int g, int b)
  87.         {
  88.             return new WorldDecoratorCollection(
  89.                 new GroundLabelDecorator(Hud)
  90.                 {
  91.                     TextFont = Hud.Render.CreateFont("tahoma", 18, 200, r, g, b, false, false, true),
  92.                     //BackgroundBrush = Hud.Render.CreateBrush(142, 0, 0, 0, 0),
  93.                     //BorderBrush = Hud.Render.CreateBrush(178, r, g, b, 1),
  94.                 },
  95.                 new MapShapeDecorator(Hud)
  96.                 {
  97.                     ShapePainter = new DoorShapePainter(Hud),
  98.                     Radius = 6f,
  99.                     Brush = Hud.Render.CreateBrush(200, r, g, b, 1),
  100.                 }
  101.             );
  102.         }
  103.  
  104.         private void PaintActor(WorldLayer layer, IActor actor, WorldDecoratorCollection decorator)
  105.         {
  106.             if (GroundLabelsOutOfScreenOnly)
  107.                 decorator.ToggleDecorators<GroundLabelDecorator>(!actor.IsOnScreen);
  108.  
  109.             //decorator.Paint(layer, actor, actor.FloorCoordinate, actor.SnoActor.NameEnglish);// "\uD83D\uDEAA");
  110.             decorator.Paint(layer, actor, actor.FloorCoordinate, "\uD83D\uDEAA");
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement