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

public class CleaveZone : MonoBehaviour
{
    private const string PLAYER = "Player";
    private const string ENEMY = "Enemy";
    public Ownership owner;
    private Collider cleaveZone;
    private HealthDelta lethality;

    void Awake() {
        this.cleaveZone = GetComponent<Collider>();
        this.lethality = GetComponent<HealthDelta>();
    }

    void Update() {
        if(this.owner == Ownership.PLAYER) {
            this.gameObject.layer = LayerMask.NameToLayer(PLAYER);
            this.lethality.affects = LayerMask.GetMask(ENEMY);
        }
        else if(this.owner == Ownership.ENEMY) {
            this.gameObject.layer = LayerMask.NameToLayer(ENEMY);
            this.lethality.affects = LayerMask.GetMask(PLAYER);
        }
    }

    public void Hazard(bool isOn) {
        this.cleaveZone.enabled = isOn;
    }
    // void OnTriggerEnter(Collider other) {
    //     if(this.owner == Ownership.PLAYER) {
    //         if(((1 << other.gameObject.layer) & LayerMask.GetMask("Enemy")) != 0) {
    //             //Do Damage
    //             Debug.Log("Cleaved Enemy");
    //         }
    //     }
    //     else if(this.owner == Ownership.ENEMY) {
    //         if(((1 << other.gameObject.layer) & LayerMask.GetMask("Player")) != 0) {
    //             //Do Damage
    //             Debug.Log("Cleaved Player");
    //         }
    //     }
    // }
}
