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

public enum BurnState
{
    Waiting,
    Smoking,
    Burning,
    Smothered,
    GettingChoppedDown,
    Disabled
}

[RequireComponent(typeof(Combustible))]
public class Tree : MonoBehaviour {

    public GameObject Selector = null;

    private static int LAYERMASK_GameLogicObjects = 1 << 9;
    public static Collider[] GetGameLogicObjectsInRange(Vector3 worldPos, float radius)
    {
        return Physics.OverlapSphere(worldPos, radius, LAYERMASK_GameLogicObjects);
    }

    public bool SelectedAsTractorTarget
    {
        get
        {
            return _selected;
        }
    }
    private bool _selected = false;

    public void SetSelectedAsTractorTarget(bool state)
    {
        _selected = state;
        if (_selected)
        {
            if (SelectionObject == null)
            {
                SelectionObject = GameObject.Instantiate(Selector, transform);
            }
        }
        else
        {
            if (SelectionObject != null)
            {
                Destroy(SelectionObject);
                SelectionObject = null;
            }
        }
    }

    private GameObject SelectionObject = null;

	
	// Update is called once per frame
	void Update () {
		
	}

    public GameObject AttachedParticleEffect = null;

    public event System.EventHandler Destroyed;

    Tree()
    {
        TreeProcessor.AddTree(this);
    }

    private void OnDestroy()
    {
        Destroyed?.Invoke(this, null);
    }

    public BurnState burningState;
    public float TimeChoppingEnds;
    public float FallAngle = 90.0f;
    public float WiggleSpeed = 0.0f;
    public float WiggleAngle= 90.0f;
    public bool ShowingSuppression = false;
}
