-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreatureTrackerComponent.cs
79 lines (69 loc) · 2.31 KB
/
CreatureTrackerComponent.cs
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
using UnityEngine;
namespace CreatureTrackerMinimap
{
internal class CreatureTrackerComponent : MonoBehaviour
{
private string displayName;
private string displayLevel;
private Sprite displayIcon;
private Minimap.PinData pinData;
private bool isFish;
private bool showName;
public void Initialize(string displayName, Sprite displayIcon, int level, bool isFish)
{
this.displayName = displayName;
this.displayIcon = displayIcon;
this.isFish = isFish;
SetLevel(level);
}
public void SetName(string displayName)
{
this.displayName = displayName;
if (pinData != null) pinData.m_name = GetDisplayName();
}
public void SetLevel(int level)
{
if (level == 2)
this.displayLevel = " ⭐";
else if (level == 3)
this.displayLevel += " ⭐⭐";
else
this.displayLevel = string.Empty;
if (pinData != null) pinData.m_name = GetDisplayName();
}
private string GetDisplayName()
{
return showName ? displayName + displayLevel : "";
}
private void Update()
{
if (isFish && CreatureTrackerMinimap.cfgTrackFish.Value == false)
{
OnDestroy();
return;
}
if (pinData == null)
{
showName = CreatureTrackerMinimap.cfgShowNames.Value;
pinData = Minimap.instance.AddPin(base.transform.position, Minimap.PinType.Hildir1, GetDisplayName(), false, false);
if (displayIcon != null)
{
pinData.m_icon = displayIcon;
pinData.m_worldSize = 0f;
}
}
else if (showName != CreatureTrackerMinimap.cfgShowNames.Value)
{
showName = CreatureTrackerMinimap.cfgShowNames.Value;
pinData.m_name = GetDisplayName();
}
pinData.m_pos = base.transform.position;
}
private void OnDestroy()
{
if (pinData == null) return;
Minimap.instance.RemovePin(pinData);
pinData = null;
}
}
}