Advertisement
s4000

DAV_SpecMonsterPlugin

Sep 4th, 2019
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.93 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using Turbo.Plugins.Default;
  3. using System.Linq;
  4. using System;
  5.  
  6. namespace Turbo.Plugins.DavMonster
  7. {
  8.     public class DAV_SpecMonsterPlugin : BasePlugin, IInGameWorldPainter {
  9.         public float xPos { get; set; }
  10.         public float yPos { get; set; }
  11.         public List<DAV_SpecMon> SpMonsterList { get; set; } = new List<DAV_SpecMon>();
  12.  
  13.         public DAV_SpecMonsterPlugin() {
  14.             Enabled = true;
  15.             Order = 2005;
  16.         }
  17.  
  18.         public override void Load(IController hud) {
  19.             base.Load(hud);
  20.  
  21.             xPos = Hud.Window.Size.Width * 0.7f;
  22.             yPos = Hud.Window.Size.Height * 0.4f;
  23.  
  24.             var tmpFont = Hud.Render.CreateFont("arial", 8, 255, 0, 255, 0, true, false, true);
  25.             SpMonsterList.Add(new DAV_SpecMon("召喚師") { // Summoner
  26.                 showCustName = true, // customized name on decorator (if apply), show full localized name if false
  27.                 showCount = true,
  28.                 offsetZ = 3f, // greater than 0 if GroundLabelDecorator exist
  29.                 textFont = tmpFont,
  30.                 Members = new List<ActorSnoEnum> {
  31.                     ActorSnoEnum._skeletonsummoner_a, ActorSnoEnum._skeletonsummoner_b, ActorSnoEnum._skeletonsummoner_c,
  32.                     ActorSnoEnum._skeletonsummoner_d, ActorSnoEnum._skeletonsummoner_e
  33.                 },
  34.                 Decorator = new WorldDecoratorCollection(
  35.                     new GroundLabelDecorator(Hud) {
  36.                         BackgroundBrush = Hud.Render.CreateBrush(200, 178, 255, 102, 0),
  37.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  38.                     },
  39.                     new MapShapeDecorator(Hud) {
  40.                         Brush = Hud.Render.CreateBrush(220, 255, 255, 0, 3f),
  41.                         ShapePainter = new RectangleShapePainter(Hud),
  42.                         Radius = 8
  43.                     }
  44.                 )
  45.             });
  46.  
  47.             SpMonsterList.Add(new DAV_SpecMon("嘔吐女屍") { // Retching Cadaver
  48.                 showCustName = true,
  49.                 showCount = true,
  50.                 offsetZ = 3f,
  51.                 textFont = tmpFont,
  52.                 Members = new List<ActorSnoEnum> {
  53.                     ActorSnoEnum._zombiefemale_a, ActorSnoEnum._zombiefemale_b, ActorSnoEnum._zombiefemale_c,
  54.                     ActorSnoEnum._zombiefemale_d, ActorSnoEnum._zombiefemale_spitter_a,
  55.                 },
  56.                 Decorator = new WorldDecoratorCollection(
  57.                     new GroundLabelDecorator(Hud) {
  58.                         BackgroundBrush = Hud.Render.CreateBrush(200, 178, 255, 102, 0),
  59.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  60.                     },
  61.                     new MapShapeDecorator(Hud) {
  62.                         Brush = Hud.Render.CreateBrush(220, 255, 51, 153, 3f),
  63.                         ShapePainter = new TriangleShapePainter(Hud),
  64.                         Radius = 8
  65.                     }
  66.                 )
  67.             });
  68.  
  69.             SpMonsterList.Add(new DAV_SpecMon("召喚師") { // Triune Summoner
  70.                 showCustName = true,
  71.                 showCount = true,
  72.                 offsetZ = 3f,
  73.                 textFont = tmpFont,
  74.                 Members = new List<ActorSnoEnum> {
  75.                     ActorSnoEnum._triunesummoner_a, ActorSnoEnum._triunesummoner_b, ActorSnoEnum._triunesummoner_c, ActorSnoEnum._triunesummoner_d
  76.                 },
  77.                 Decorator = new WorldDecoratorCollection(
  78.                     new GroundLabelDecorator(Hud) {
  79.                         BackgroundBrush = Hud.Render.CreateBrush(200, 178, 255, 102, 0),
  80.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  81.                     },
  82.                     new MapShapeDecorator(Hud) {
  83.                         Brush = Hud.Render.CreateBrush(220, 51, 153, 255, 3f),
  84.                         ShapePainter = new TriangleShapePainter(Hud),
  85.                         Radius = 8
  86.                     }
  87.                 )
  88.             });
  89.  
  90.             SpMonsterList.Add(new DAV_SpecMon("變身哥") { // Dark Vessel
  91.                 showCustName = true,
  92.                 showCount = true,
  93.                 offsetZ = 3f,
  94.                 textFont = tmpFont,
  95.                 Members = new List<ActorSnoEnum> {
  96.                     ActorSnoEnum._triunevessel_a,
  97.                 },
  98.                 Decorator = new WorldDecoratorCollection(
  99.                     new GroundCircleDecorator(Hud) {
  100.                         Brush = Hud.Render.CreateBrush(255, 255, 255, 0, 2, SharpDX.Direct2D1.DashStyle.Dash),
  101.                         Radius = 2,
  102.                     },
  103.                     new MapShapeDecorator(Hud) {
  104.                         Brush = Hud.Render.CreateBrush(255, 255, 255, 0, 3f),
  105.                         ShapePainter = new CircleShapePainter(Hud),
  106.                         Radius = 8,
  107.                     }
  108.                 )
  109.             });
  110.  
  111.             SpMonsterList.Add(new DAV_SpecMon("蛆蟲巢獸") { // Maggot Brood
  112.                 showCustName = true,
  113.                 showCount = true,
  114.                 offsetZ = 3f,
  115.                 textFont = tmpFont,
  116.                 Members = new List<ActorSnoEnum> {
  117.                     ActorSnoEnum._p1_lr_bogblight_a,
  118.                 },
  119.                 Decorator = new WorldDecoratorCollection(
  120.                     new GroundLabelDecorator(Hud) {
  121.                         BackgroundBrush = Hud.Render.CreateBrush(200, 178, 255, 102, 0),
  122.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  123.                     },
  124.                     new MapShapeDecorator(Hud) {
  125.                         Brush = Hud.Render.CreateBrush(220, 255, 51, 153, 3f),
  126.                         ShapePainter = new PlusShapePainter(Hud),
  127.                         Radius = 8
  128.                     }
  129.                 )
  130.             });
  131.  
  132.             //  ActorSnoEnum._x1_plagued_lacunimale_a // Rat Caller
  133.             SpMonsterList.Add(new DAV_SpecMon("蠻牛獸") { // Beast
  134.                 showCustName = true,
  135.                 showCount = false,
  136.                 offsetZ = 3f,
  137.                 textFont = tmpFont,
  138.                 Members = new List<ActorSnoEnum> {
  139.                     ActorSnoEnum._beast_a, ActorSnoEnum._beast_b, ActorSnoEnum._beast_c, ActorSnoEnum._beast_d,
  140.                     ActorSnoEnum._x1_beast_skeleton_a
  141.                 },
  142.                 Decorator = new WorldDecoratorCollection(
  143.                     new GroundLabelDecorator(Hud) {
  144.                         BackgroundBrush = Hud.Render.CreateBrush(200, 255, 178, 102, 0),
  145.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  146.                     },
  147.                     new MapShapeDecorator(Hud) {
  148.                         Brush = Hud.Render.CreateBrush(220, 255, 125, 0, 3f),
  149.                         ShapePainter = new CrossShapePainter(Hud),
  150.                         Radius = 8
  151.                     }
  152.                 )
  153.             });
  154.  
  155.             SpMonsterList.Add(new DAV_SpecMon("Other Bad Monster") {
  156.                 showCustName = false,
  157.                 showCount = false,
  158.                 offsetZ = 3f,
  159.                 textFont = tmpFont,
  160.                 Members = new List<ActorSnoEnum> {
  161.                     ActorSnoEnum._x1_bogfamily_brute_a, // Tusked Bogan
  162.                     ActorSnoEnum._p1_lr_sandmonster_a, ActorSnoEnum._sandmonster_b, ActorSnoEnum._sandmonster_a_gauntlet, ActorSnoEnum._p1_lr_sandmonster_a,  // Sand Dweller
  163.                     ActorSnoEnum._dunedervish_b, ActorSnoEnum._dunedervish_c, // Dune Dervish
  164.                     ActorSnoEnum._malletdemon_a // Mallet Lord
  165.                 },
  166.                 Decorator = new WorldDecoratorCollection(
  167.                     new GroundLabelDecorator(Hud) {
  168.                         BackgroundBrush = Hud.Render.CreateBrush(200, 255, 178, 102, 0),
  169.                         TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
  170.                     },
  171.                     new MapLabelDecorator(Hud) {
  172.                         LabelFont = Hud.Render.CreateFont("tahoma", 6f, 200, 255, 178, 102, false, false, 128, 0, 0, 0, true),
  173.                         Up = true,
  174.                     }
  175.                 )
  176.             });
  177.         }
  178.  
  179.         public void PaintWorld(WorldLayer layer) {
  180.  
  181.             var uiMinimapRect = Hud.Render.MinimapUiElement.Rectangle;
  182.             var xref = uiMinimapRect.Left;
  183.             var yref = uiMinimapRect.Bottom;
  184.  
  185.             foreach (var spMon in SpMonsterList) {
  186.                 var monsters = Hud.Game.AliveMonsters.Where(x => spMon.Members.Contains(x.SnoActor.Sno));
  187.                 var spCount = monsters.Count();
  188.                 if (spCount == 0) continue;
  189.  
  190.                 spMon.PaintCount(spCount, xref, ref yref);
  191.                 foreach (var monster in monsters)
  192.                     spMon.Paint(layer, monster);
  193.             }
  194.         }
  195.     }
  196.  
  197.     public class DAV_SpecMon {
  198.         public bool showCustName { get; set; }
  199.         public string NameCustomized { get; set; }
  200.         public List<ActorSnoEnum> Members { get; set; }
  201.  
  202.         public float offsetZ { get; set; }
  203.         public bool showCount { get; set; }
  204.         public IFont textFont { get; set; }
  205.         public WorldDecoratorCollection Decorator { get; set; }
  206.  
  207.         public DAV_SpecMon(string cust) {
  208.             NameCustomized = cust;
  209.         }
  210.  
  211.         public void AddMember(params ActorSnoEnum[] members) {
  212.             foreach (var member in members)
  213.                 Members.Add(member);
  214.         }
  215.  
  216.         public void PaintCount(int count, float x, ref float y) {
  217.             if (!showCount) return;
  218.  
  219.             var message = NameCustomized + " : " + count;
  220.             var layout = textFont.GetTextLayout(message);
  221.             y -= layout.Metrics.Height;
  222.             textFont.DrawText(layout, x, y);
  223.         }
  224.  
  225.         public void Paint(WorldLayer layer, IMonster monster) {
  226.             if (Decorator == null) return;
  227.             Decorator.Paint(layer, monster, monster.FloorCoordinate.Offset(0, 0, offsetZ), (showCustName ? NameCustomized : monster.SnoMonster.NameLocalized));
  228.         }
  229.     }
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement