using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ShowBasedOnEmotion : MonoBehaviour
{
    public Renderer renderer;
    public ParticleSystem particleSystem;
    public Emotion.types emotion;
    private Entity mainEntity;
    private int counter;
    private bool wasVisible = false;

    private void Start() {
        counter = Random.Range(0, 4);
    }

    public void Reset() {
        renderer = GetComponent<Renderer>();
        particleSystem = GetComponent<ParticleSystem>();
    }

    // Update is called once per frame
    void Update()
    {
        if (mainEntity == null) {
            mainEntity = ThirdPersonController.main.entity;
        }
        counter--;
        if (counter < 0) {
            renderer.enabled = mainEntity.emotions.Contains(emotion);
            if (particleSystem != null) {
                ParticleSystem.EmissionModule emission = particleSystem.emission;
                emission.rateOverTime = renderer.enabled ? 0.0f : 10.0f;
            }
            counter = 3;
            wasVisible = renderer.enabled;
        }
    }
}
