35 lines
811 B
C#
35 lines
811 B
C#
using UnityEngine;
|
|
|
|
public class Lightswitch : MonoBehaviour, IInteract
|
|
{
|
|
[SerializeField] Light[] controlledLight;
|
|
[SerializeField] private bool requiresReview = true;
|
|
private bool isOn = false;
|
|
|
|
public void OnInteract()
|
|
{
|
|
isOn = !isOn;
|
|
UpdateLightState();
|
|
|
|
// Notify LevelManager for review after interaction
|
|
if (requiresReview && LevelManager.Instance != null)
|
|
{
|
|
LevelManager.Instance.RequestReview(gameObject);
|
|
}
|
|
}
|
|
|
|
private void UpdateLightState()
|
|
{
|
|
if (controlledLight != null)
|
|
{
|
|
foreach (var light in controlledLight)
|
|
{
|
|
if (light != null)
|
|
{
|
|
light.enabled = isOn;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |