You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
821 B
C#
43 lines
821 B
C#
using Fusion;
|
|
using UnityEngine;
|
|
|
|
namespace Projectiles
|
|
{
|
|
/// <summary>
|
|
/// A very simple turret that holds a single weapon that is constantly firing.
|
|
/// </summary>
|
|
public class SimpleTurret : NetworkBehaviour
|
|
{
|
|
// PRIVATE MEMBERS
|
|
|
|
[SerializeField]
|
|
private Transform _fireTransform;
|
|
|
|
private Weapon _weapon;
|
|
private WeaponContext _weaponContext = new();
|
|
|
|
// NetworkBehaviour INTERFACE
|
|
|
|
public override void FixedUpdateNetwork()
|
|
{
|
|
if (HasStateAuthority == false)
|
|
return;
|
|
|
|
// Fire constantly
|
|
_weaponContext.Buttons.SetDown(EInputButton.Fire);
|
|
|
|
_weapon.ProcessFireInput();
|
|
}
|
|
|
|
// MONOBEHAVIOUR
|
|
|
|
protected void Awake()
|
|
{
|
|
_weaponContext.FireTransform = _fireTransform;
|
|
|
|
_weapon = GetComponentInChildren<Weapon>(true);
|
|
_weapon.SetWeaponContext(_weaponContext);
|
|
}
|
|
}
|
|
}
|