Code:
namespace Turbo.Plugins.User
{
using Turbo.Plugins.Default;
using System.Linq;
using System.Text;
using System.Collections.Generic;
public class WizardMirrorImagesIndicatorPlugin : BasePlugin, IInGameWorldPainter, IInGameTopPainter
{
public WorldDecoratorCollection MirrorImagesDecorator;
public TopLabelDecorator MirrorImagesCountLabel;
public string MirrorImagesLabel;
public int MirrorImagesCount;
public float barW, barH, barX, barY;
public bool MirrorImagesEnabled;
private static uint MirrorImagesSkillSNO = 98027;
public HashSet<ActorSnoEnum> MirrorImagesActorSNOs = new HashSet<ActorSnoEnum>
{
ActorSnoEnum._wizard_mirrorimage_male, // 107916
ActorSnoEnum._wizard_mirrorimage_female // 98010
};
public WizardMirrorImagesIndicatorPlugin()
{
Enabled = true;
MirrorImagesEnabled = true;
// Inits variables
MirrorImagesCount = 0;
MirrorImagesLabel = "";
}
public override void Load(IController hud)
{
base.Load(hud);
// Unlike the old XML system where it draws x,y,w,h in terms of percentage of screen size, the new plugin uses actual pixel coordinates
// To convert x,y,w,h sizes from the XML system to the new plugin system, multiply the screensize with percentage. ie. XML size of 2 => 0.02f * screensize
// Display coordinates for non-combined indicators
barW = Hud.Window.Size.Width * 0.012f;
barH = Hud.Window.Size.Height * 0.0175f;
barX = Hud.Window.Size.Width * 0.5f;
barY = Hud.Window.Size.Height * 0.36f;
// Decorator under each MirrorImage
MirrorImagesDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(240, 50, 200, 0, 4),
Radius = 0.5f,
},
new MapShapeDecorator(Hud)
{
ShapePainter = new RotatingTriangleShapePainter(Hud),
Brush = Hud.Render.CreateBrush(220, 200, 200, 0, 0),
Radius = 0f,
RadiusTransformator = new StandardPingRadiusTransformator(Hud, 250)
}
);
// Label Decorator for Indicator
MirrorImagesCountLabel = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 240, 0, false, false, false),
BackgroundTexture1 = Hud.Texture.Button2TextureBrown,
BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
BackgroundTextureOpacity2 = 0.25f
};
}
public void PaintWorld(WorldLayer layer)
{
// Don't draw if not playing a Wizard
if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Wizard) return;
// For MirrorImages, only when equipping the skill
if (MirrorImagesEnabled && Hud.Game.Me.Powers.UsedSkills.Where(x => x.SnoPower.Sno == MirrorImagesSkillSNO) != null)
{
// Iterate all the game actors, find out and count which are MirrorImages summoned by player
var MirrorImagesActors = Hud.Game.Actors.Where(EachActor => MirrorImagesActorSNOs.Contains(EachActor.SnoActor.Sno) && // Find out which are skeleton melees actors
EachActor.SummonerAcdDynamicId == Hud.Game.Me.SummonerId); // Then find out if they are summoned by the player
MirrorImagesCount = MirrorImagesActors.Count(); // And then count how many are found
// Paint circle decorator under each MirrorImage
foreach (var EachActor in MirrorImagesActors)
{
var text = string.IsNullOrWhiteSpace(MirrorImagesLabel) ? EachActor.SnoActor.NameLocalized : MirrorImagesLabel;
MirrorImagesDecorator.Paint(layer, EachActor, EachActor.FloorCoordinate, text);
}
}
else
{
MirrorImagesCount = 0;
}
}
public void PaintTopInGame(ClipState clipState)
{
// Don't draw if not playing a Wizard
if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Wizard) return;
if (clipState != ClipState.BeforeClip) return;
// Drawing count indicator
if (MirrorImagesEnabled && MirrorImagesCount != 0)
{
MirrorImagesCountLabel.TextFunc = () => MirrorImagesCount.ToString();
MirrorImagesCountLabel.Paint(barX, barY, barW, barH, HorizontalAlign.Center);
}
}
}
}
Put the Code in WizardMirrorImagesIndicator.cs in \plugins\User\