29 lines
720 B
C#
29 lines
720 B
C#
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.InputSystem;
|
|
|
|
namespace RR.Game2D.Entities
|
|
{
|
|
public class DeactivatingLever : Lever
|
|
{
|
|
[SerializeField] private UnityEvent onDeactivate;
|
|
|
|
protected virtual void Deactivate()
|
|
{
|
|
if (!_isActivated) return;
|
|
|
|
StopAllCoroutines();
|
|
StartCoroutine(RotateLever(stick.rotation, _initialRotation));
|
|
|
|
onDeactivate?.Invoke();
|
|
}
|
|
|
|
protected override void OnActivateKey(InputAction.CallbackContext obj)
|
|
{
|
|
if (!_canBeActivated) return;
|
|
|
|
if (_isActivated) Deactivate();
|
|
else Activate();
|
|
}
|
|
}
|
|
} |