summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs
blob: c408385488152e50b9c9012bf8d1a52fb74d05fe (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
using UnityEngine;

public class LaunchableDefenseMechanismInteractor : InteractorBase, DayNightCycle.IDaytimeSensitive
{
	public GameObject focusIndicator;

	public LaunchableProjectile projectilePrefab;

	public Transform projectileSpawn;

	public bool autoReloadOnDawn = true;

	private LaunchableProjectile currentProjectile;

	private void Start()
	{
		DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
		Reload();
		if (DayNightCycle.Instance.CurrentTimestate == DayNightCycle.Timestate.Day)
		{
			base.gameObject.SetActive(value: false);
		}
	}

	public override void Focus(PlayerInteraction player)
	{
		if ((bool)currentProjectile)
		{
			focusIndicator.SetActive(value: true);
		}
	}

	public override void InteractionBegin(PlayerInteraction player)
	{
		if ((bool)currentProjectile)
		{
			currentProjectile.Launch();
			currentProjectile.transform.parent = null;
			currentProjectile = null;
			Unfocus(player);
		}
	}

	public void OnDawn_AfterSunrise()
	{
		base.gameObject.SetActive(value: false);
		if (autoReloadOnDawn)
		{
			Reload();
		}
	}

	public void OnDawn_BeforeSunrise()
	{
	}

	public void OnDusk()
	{
		base.gameObject.SetActive(value: true);
	}

	public override void Unfocus(PlayerInteraction player)
	{
		focusIndicator.SetActive(value: false);
	}

	public void Reload()
	{
		if (!currentProjectile)
		{
			currentProjectile = Object.Instantiate(projectilePrefab, projectileSpawn.transform.position, projectileSpawn.transform.rotation, base.transform.parent);
		}
	}

	private void OnDrawGizmos()
	{
		Gizmos.color = Color.black;
		Gizmos.DrawWireMesh(projectilePrefab.GetComponentInChildren<MeshFilter>().sharedMesh, 0, projectileSpawn.position, projectileSpawn.rotation, projectilePrefab.transform.localScale);
		Gizmos.color = Color.magenta;
		Gizmos.DrawLine(projectileSpawn.position, projectileSpawn.position + projectileSpawn.forward * 15f);
		Gizmos.DrawWireSphere(projectileSpawn.position + projectileSpawn.forward * 15f, 0.3f);
	}
}