v1.0.0.11: Player/NPC tracking on minimap with Show Players and NPCs toggle
Made-with: Cursor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using Dalamud.Game.ClientState.Objects.SubKinds;
|
||||
@@ -18,6 +19,53 @@ namespace Mappy.MapRenderer;
|
||||
|
||||
public partial class MapRenderer
|
||||
{
|
||||
private unsafe void DrawMinimapGameObjects(
|
||||
Vector2 contentTopLeft,
|
||||
Func<float, float, Vector2> texToContent,
|
||||
Vector2 size,
|
||||
float scaleFactor,
|
||||
float offsetX,
|
||||
float offsetY)
|
||||
{
|
||||
if (!System.SystemConfig.MinimapShowPlayersAndNpcs) return;
|
||||
if (Service.ObjectTable is not { LocalPlayer: { } player }) return;
|
||||
|
||||
foreach (var obj in Service.ObjectTable.Reverse())
|
||||
{
|
||||
if (!obj.IsTargetable) continue;
|
||||
if (GroupManager.Instance()->MainGroup.IsEntityIdInParty(obj.EntityId)) continue;
|
||||
if (GroupManager.Instance()->MainGroup.IsEntityIdInAlliance(obj.EntityId)) continue;
|
||||
if (Vector3.Distance(obj.Position, player.Position) >= 150.0f) continue;
|
||||
|
||||
var iconId = obj.ObjectKind switch
|
||||
{
|
||||
ObjectKind.Player when GroupManager.Instance()->MainGroup.MemberCount is 0 && System.SystemConfig.ShowPlayers => 60421u,
|
||||
ObjectKind.Player when System.SystemConfig.ShowPlayers => 60444u,
|
||||
ObjectKind.BattleNpc when IsBoss(obj) && obj.TargetObject is null => 60402u,
|
||||
ObjectKind.BattleNpc when IsBoss(obj) && obj.TargetObject is not null => 60401u,
|
||||
ObjectKind.BattleNpc when obj is { SubKind: (int)BattleNpcSubKind.Enemy, TargetObject: not null } => 60422u,
|
||||
ObjectKind.BattleNpc when obj is { SubKind: (int)BattleNpcSubKind.Enemy, TargetObject: null } => 60424u,
|
||||
ObjectKind.BattleNpc when obj.SubKind == (int)BattleNpcSubKind.Pet => 60961u,
|
||||
ObjectKind.Treasure => 60003u,
|
||||
ObjectKind.GatheringPoint => System.GatheringPointIconCache.GetValue(obj.BaseId),
|
||||
ObjectKind.EventObj when IsAetherCurrent(obj) => 60653u,
|
||||
_ => 0u
|
||||
};
|
||||
|
||||
if (iconId is 0) continue;
|
||||
if (System.IconConfig.IconSettingMap.TryGetValue(iconId, out var setting) && setting.Hide) continue;
|
||||
|
||||
var pos = new Vector2(obj.Position.X, obj.Position.Z);
|
||||
var tx = 1024.0f + (pos.X - offsetX) * scaleFactor;
|
||||
var ty = 1024.0f + (pos.Y - offsetY) * scaleFactor;
|
||||
var contentPos = texToContent(tx, ty);
|
||||
if (!IsInMinimapBounds(contentPos, size, MinimapBoundsMargin)) continue;
|
||||
|
||||
var tooltip = GetTooltipForGameObject(obj);
|
||||
DrawMinimapIcon(iconId, contentPos + contentTopLeft, sizeScale: 1.5f, tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void DrawGameObjects()
|
||||
{
|
||||
if (AgentMap.Instance()->SelectedMapId != AgentMap.Instance()->CurrentMapId) return;
|
||||
|
||||
Reference in New Issue
Block a user