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

[System.Serializable]
public class KF3CharacterContainerSerializable : KF3ObjectContainerSerializable
{
    public bool IsCerulean;
    public int ModelId;
    public string CostumeName;
    public string AnimationName;

    public KF3CharacterContainerSerializable() { }

    public KF3CharacterContainerSerializable(KF3CharacterContainer container)
    {
        this.GUID = container.GUID;
        this.ModelId = container.ModelId;
        this.CostumeName = container.CostumeName;
        this.AnimationName = container.AnimationName;
        this.IsCerulean = container as KF3CeruleanContainer != null;
        this.Frames = container.Frames.Select(f => new FrameContent(f)).ToList();
    }

    public KF3CharacterContainerSerializable(KF3CharacterContainerSerializable source)
    {
        this.ModelId = source.ModelId;
        this.CostumeName = source.CostumeName;
        this.AnimationName = source.AnimationName;
        this.IsCerulean = source.IsCerulean;
        this.Filename = source.Filename;
        this.GUID = source.GUID;
        this.Frames = source.Frames.Select(f => new FrameContent(f)).ToList();
    }

    public static string GetRendererName(KF3ObjectContainer container1, Renderer r)
    {
        var container = container1 as KF3FriendContainer;
        if (container == null) return r.gameObject.name;
        else if (r.gameObject.name.ToLower() == "model")
        {
            if (r.transform.parent == container.Body.transform)
                return "hair";
            else if (container.Ears && r.transform.parent == container.Ears.transform)
                return "ears";
            else if (container.EarsAlt && r.transform.parent == container.EarsAlt.transform)
                return "ears (alt)";
            else if (container.Tail && r.transform.parent == container.Tail.transform)
                return "tail";
            else if (container.TailAlt && r.transform.parent == container.TailAlt.transform)
                return "tail (alt)";
            else
                return r.gameObject.name;
        }
        else
            return r.gameObject.name;
    }
}