diff options
author | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
commit | a22c505984697881f5f911a165ee022087b69e09 (patch) | |
tree | d3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs | |
parent | 4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff) |
Diffstat (limited to 'Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs')
-rw-r--r-- | Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs b/Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs new file mode 100644 index 0000000..c408385 --- /dev/null +++ b/Thronefall_v1.0/Decompile/LaunchableDefenseMechanismInteractor.cs @@ -0,0 +1,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); + } +} |