summaryrefslogtreecommitdiff
path: root/Valheim_r202102_v0.141.2/Valheim/assembly_valheim/KeyHints.cs
blob: 176f9fcb753cfebf001bd4ef0f9ebbff19183495 (plain)
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
90
91
92
93
94
95
using UnityEngine;

public class KeyHints : MonoBehaviour
{
	private static KeyHints m_instance;

	[Header("Key hints")]
	public GameObject m_buildHints;

	public GameObject m_combatHints;

	public GameObject m_primaryAttackGP;

	public GameObject m_primaryAttackKB;

	public GameObject m_secondaryAttackGP;

	public GameObject m_secondaryAttackKB;

	public GameObject m_bowDrawGP;

	public GameObject m_bowDrawKB;

	private bool m_keyHintsEnabled = true;

	public static KeyHints instance => m_instance;

	private void OnDestroy()
	{
		m_instance = null;
	}

	private void Awake()
	{
		m_instance = this;
		ApplySettings();
	}

	private void Start()
	{
	}

	public void ApplySettings()
	{
		m_keyHintsEnabled = PlayerPrefs.GetInt("KeyHints", 1) == 1;
	}

	private void Update()
	{
		UpdateHints();
	}

	private void UpdateHints()
	{
		Player localPlayer = Player.m_localPlayer;
		if (!m_keyHintsEnabled || localPlayer == null || localPlayer.IsDead() || Chat.instance.IsChatDialogWindowVisible())
		{
			m_buildHints.SetActive(value: false);
			m_combatHints.SetActive(value: false);
			return;
		}
		_ = m_buildHints.activeSelf;
		_ = m_buildHints.activeSelf;
		ItemDrop.ItemData currentWeapon = localPlayer.GetCurrentWeapon();
		if (localPlayer.InPlaceMode())
		{
			m_buildHints.SetActive(value: true);
			m_combatHints.SetActive(value: false);
		}
		else if ((bool)localPlayer.GetShipControl())
		{
			m_buildHints.SetActive(value: false);
			m_combatHints.SetActive(value: false);
		}
		else if (currentWeapon != null && (currentWeapon != localPlayer.m_unarmedWeapon.m_itemData || localPlayer.IsTargeted()))
		{
			m_buildHints.SetActive(value: false);
			m_combatHints.SetActive(value: true);
			bool flag = currentWeapon.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow;
			bool active = !flag && currentWeapon.HavePrimaryAttack();
			bool active2 = !flag && currentWeapon.HaveSecondaryAttack();
			m_bowDrawGP.SetActive(flag);
			m_bowDrawKB.SetActive(flag);
			m_primaryAttackGP.SetActive(active);
			m_primaryAttackKB.SetActive(active);
			m_secondaryAttackGP.SetActive(active2);
			m_secondaryAttackKB.SetActive(active2);
		}
		else
		{
			m_buildHints.SetActive(value: false);
			m_combatHints.SetActive(value: false);
		}
	}
}