﻿using UnityEngine;
using System.Collections;
using GGM.Core;

public class TestComponent : GGMComponent
{
    [SerializeField]
    TestSubComponent testComponent;

    public void Start()
    {
    }

    public void DisableSelf()
    {
        this.gameObject.SetActive(false);
    }

    public void DestorySelf()
    {
        DestroySubComponent(testComponent);
    }
}

[System.Serializable]
public class TestSubComponent : SubComponent, IUpdateable, IFixedUpdateable
{
    public GameObject obj;
    public TestSubComponent(IComponent masterComponent) : base(masterComponent)
    {
    }

    public override void OnDestory()
    {
        Debug.Log(string.Concat(this.GetType(), "+OnDistory"));
    }

    public override void OnDisable()
    {
        base.OnDisable();
        Debug.Log(string.Concat(this.GetType(), "+OnDisable : ", IsEnabled));
    }

    public override void OnEnable()
    {
        base.OnEnable();
        Debug.Log(string.Concat(this.GetType(), "+OnEnable : ", IsEnabled));
    }

    public void Update()
    {
        Debug.Log("update!");
    }

    public void FixedUpdate()
    {
        Debug.Log("fixedUpdate!");
    }
}
