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

public class Furniture : MonoBehaviour
{
    public int weight;
    public bool immovable = false;

    private void Start()
    {
        House.instance.furnishings.Add(this);
        if (immovable){
            GetComponent<BoxCollider>().enabled = false;
        }
    }

    public float Distance
    {
        get
        {
            return this.transform.localPosition.x;
        }
    }

    public bool IsBeingCarried{
        get
        {
            return GameState.instance.players.Any(p => p.heldItem && p.heldItem == this.transform);
        }
    }

    public float Moment
    {
        get
        {
            if (this.Distance == 0)
            {
                return 0;
            }
            else if (this.Distance < 0)
            {
                return Mathf.Sqrt(Mathf.Abs(this.Distance)) * weight * -1;
            }
            else
            {
                return Mathf.Sqrt(this.Distance) * weight;
            }
        }
    }
}
