forked from alekswoje/BetterFollowbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPartyElement.cs
More file actions
89 lines (77 loc) · 2.96 KB
/
PartyElement.cs
File metadata and controls
89 lines (77 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Linq;
using ExileCore.PoEMemory;
using ExileCore.PoEMemory.MemoryObjects;
namespace BetterFollowbot;
public static class PartyElements
{
public static List<string> ListOfPlayersInParty(int child)
{
var playersInParty = new List<string>();
try
{
var baseWindow = BetterFollowbot.Instance.GameController.IngameState.IngameUi.Children[child];
if (baseWindow != null)
{
var partyList = baseWindow.Children[0]?.Children[0]?.Children;
playersInParty.AddRange(from player in partyList where player != null && player.ChildCount >= 3 select player.Children[0].Text);
}
}
catch (Exception)
{
// ignored
}
return playersInParty;
}
public static List<PartyElementWindow> GetPlayerInfoElementList()
{
var playersInParty = new List<PartyElementWindow>();
try
{
var baseWindow = BetterFollowbot.Instance.GameController?.IngameState?.IngameUi?.PartyElement;
var partElementList = baseWindow?.Children?[0]?.Children?[0]?.Children;
if (partElementList != null)
{
foreach (var partyElement in partElementList)
{
var playerName = partyElement?.Children?[0]?.Text;
if (partyElement?.Children != null)
{
var newElement = new PartyElementWindow
{
PlayerName = playerName,
//get party element
Element = partyElement,
//party element swirly tp thingo, if in another area it becomes child 4 as child 3 becomes the area string
TpButton = partyElement.Children[partyElement.ChildCount == 4 ? 3 : 2],
ZoneName = (partyElement.ChildCount == 4) ? partyElement.Children[2].Text : BetterFollowbot.Instance.GameController?.Area.CurrentArea.DisplayName
};
playersInParty.Add(newElement);
}
}
}
}
catch (Exception e)
{
// Error handling without logging
}
return playersInParty;
}
}
public class PartyElementWindow
{
public string PlayerName { get; set; } = string.Empty;
public PlayerData Data { get; set; } = new PlayerData();
public Element Element { get; set; } = new Element();
public string ZoneName { get; set; } = string.Empty;
public Element TpButton { get; set; } = new Element();
public override string ToString()
{
return $"PlayerName: {PlayerName}, Data.PlayerEntity.Distance: {Data.PlayerEntity.Distance(Entity.Player).ToString() ?? "Null"}";
}
}
public class PlayerData
{
public Entity PlayerEntity { get; set; } = null;
}