summaryrefslogtreecommitdiff
path: root/Valheim_r202102_v0.141.2/Valheim/assembly_valheim/Teleport.cs
blob: a395fb7ef2bc873a7e2c24f6def314fa530fce47 (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
using UnityEngine;

public class Teleport : MonoBehaviour, Hoverable, Interactable
{
	public string m_hoverText = "$location_enter";

	public string m_enterText = "";

	public Teleport m_targetPoint;

	public string GetHoverText()
	{
		return Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] " + m_hoverText);
	}

	public string GetHoverName()
	{
		return "";
	}

	private void OnTriggerEnter(Collider collider)
	{
		Player component = collider.GetComponent<Player>();
		if (!(component == null) && !(Player.m_localPlayer != component))
		{
			Interact(component, hold: false);
		}
	}

	public bool Interact(Humanoid character, bool hold)
	{
		if (hold)
		{
			return false;
		}
		if (m_targetPoint == null)
		{
			return false;
		}
		if (character.TeleportTo(m_targetPoint.GetTeleportPoint(), m_targetPoint.transform.rotation, distantTeleport: false))
		{
			if (m_enterText.Length > 0)
			{
				MessageHud.instance.ShowBiomeFoundMsg(m_enterText, playStinger: false);
			}
			return true;
		}
		return false;
	}

	private Vector3 GetTeleportPoint()
	{
		return base.transform.position + base.transform.forward - base.transform.up;
	}

	public bool UseItem(Humanoid user, ItemDrop.ItemData item)
	{
		return false;
	}

	private void OnDrawGizmos()
	{
	}
}