using System.Linq;
using Sirenix.OdinInspector;
using UnityEngine;

namespace VOID.Generic.AreaOfEffect
{
    [TypeRegistryItem("Point")]
    public class PointAreaOfEffect : AbstractAreaOfEffect
    {
        public override Mesh GetMesh()
        {
            var sphereMesh = Resources.GetBuiltinResource<Mesh>("Sphere.fbx");

            var mesh = new Mesh();
            mesh.vertices = sphereMesh.vertices.Select(vertex => vertex * 0.1f).ToArray();
            mesh.triangles = sphereMesh.triangles;
            mesh.uv = sphereMesh.uv;
            mesh.normals = sphereMesh.normals;
            mesh.colors = sphereMesh.colors;
            mesh.tangents = sphereMesh.tangents;

            return mesh;
        }

        public override Collider AddCollider(GameObject gameObject)
        {
            var collider = gameObject.AddComponent<SphereCollider>();
            collider.isTrigger = true;
            collider.radius = 0.05f;

            return collider;
        }
    }
}