Files
beyond/Assets/Scripts/Quests/GuiltOnScrollPickSetter.cs
2024-11-20 15:21:28 +01:00

50 lines
1.4 KiB
C#

using System;
using EPOOutline;
using PixelCrushers.QuestMachine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Beyond
{
public class GuiltOnScrollPickSetter : MonoBehaviour
{
public bTriggerGenericAction triggerAction;
public Quest guilt;
public int maturityToSafePickup = 0;
public Color lowMaturityColor, enoughMaturityColor;
private QuestObject questObject;
private void Awake()
{
questObject = GetComponentInChildren<QuestObject>();
PlayerAttribute maturity = Player.Instance.MaturityAttribute;
TryToSetGuilt(maturity.AttributeCurrentValue, 0);
maturity.OnValueChanged.AddListener(TryToSetGuilt);
}
private void OnDestroy()
{
if (Player.Instance)
{
PlayerAttribute maturity = Player.Instance.MaturityAttribute;
maturity.OnValueChanged.RemoveListener(TryToSetGuilt);
}
}
public void TryToSetGuilt(float newVal, float oldVal)
{
if (newVal < maturityToSafePickup)
{
triggerAction.m_guilt = guilt;
questObject.m_fresnelColor = lowMaturityColor;
}
else
{
triggerAction.m_guilt = null;
questObject.m_fresnelColor = enoughMaturityColor;
}
}
}
}