using System;
using System.Collections;
using System.Collections.Generic;
using Fort23.UTool;
using GameLogic.Combat.CombatTool;
using GameLogic.Combat.Hero;
using GameTimeLine.CustomizeTimeLogic;
using UnityEngine;
using Utility;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;

public class CombatHeroGameObject: IDisposable
{
    public GameObjectPool GameObjectPool;

    public Vector3 position
    {
        get { return GameObjectPool.own.transform.position; }
    }
    private CombatHeroEntity _combatHeroEntity;
    private CombatHeroHitPoint _combatHeroHitPoints = new CombatHeroHitPoint();

    public void Init(CombatHeroEntity combatHeroEntity, GameObjectPool gameObjectPool)
    {
        _combatHeroEntity = combatHeroEntity;
        GameObjectPool = gameObjectPool;
        SetGameObject(gameObjectPool);
    }

    public void SetGameObject(GameObjectPool gameObjectPool)
    {
        GameObjectPool = gameObjectPool;
        HitPointMono hitPointMonos = GameObjectPool.own.GetComponentInChildren<HitPointMono>(true);
        HitPointMono hitPointMono = hitPointMonos;
        _combatHeroHitPoints = new CombatHeroHitPoint();
        _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
        CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
    }

    public void SetPosition(Vector3 pos)
    {
        GameObjectPool.own.transform.position = pos;
    }

    public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
        where T : ILifetCycleHitPoint
    {
        return (T)(object)_combatHeroHitPoints;
    }

    public T GetMainHotPoin<T>(bool isIgnoreHind) where T : ILifetCycleHitPoint
    {
        return (T)(object)_combatHeroHitPoints;
    }

    public void Dispose()
    {
        CombatController.currActiveCombat.CombatHeroController.RemoveHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
        GameObjectPool?.Dispose();
    }
}