summaryrefslogtreecommitdiff
path: root/Valheim_v202102/Valheim/assembly_valheim/LocationProxy.cs
blob: 2ff2833145394fa62b8198595deceea72c2dbd8e (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
using UnityEngine;

public class LocationProxy : MonoBehaviour
{
	private GameObject m_instance;

	private ZNetView m_nview;

	private void Awake()
	{
		m_nview = GetComponent<ZNetView>();
		SpawnLocation();
	}

	public void SetLocation(string location, int seed, bool spawnNow, int pgw)
	{
		int stableHashCode = location.GetStableHashCode();
		m_nview.GetZDO().Set("location", stableHashCode);
		m_nview.GetZDO().Set("seed", seed);
		m_nview.GetZDO().SetPGWVersion(pgw);
		if (spawnNow)
		{
			SpawnLocation();
		}
	}

	private bool SpawnLocation()
	{
		int @int = m_nview.GetZDO().GetInt("location");
		int int2 = m_nview.GetZDO().GetInt("seed");
		if (@int == 0)
		{
			return false;
		}
		m_instance = ZoneSystem.instance.SpawnProxyLocation(@int, int2, base.transform.position, base.transform.rotation);
		if (m_instance == null)
		{
			return false;
		}
		m_instance.transform.SetParent(base.transform, worldPositionStays: true);
		return true;
	}
}