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

/// <summary>
/// Class for the interaction between a shits core and the blackhole
/// </summary>
public class CoreBlackHoleForce : BlackHoleForce
{    
    // Gravity force offset % is used so we can either slow down or increase the default pull from the black hole.
    public float gravityForceOffsetPercent;
    private BlackHoleManager _currentBlackHoleManager;

    protected override void DoStartTasks()
    {
        // Get the current black hole.
        _currentBlackHoleManager = GameObject.Find("BlackHole").GetComponent<BlackHoleManager>();
        base.DoStartTasks();
    }

    public override void ApplyBlackHoleForce(float appliedForce)
    {
        // Check if we're blackhole immune before trying to pull the core in.
        if (!blackHolePullImmunue)
        {
            _objectRigidBody.AddForce((-_objectRigidBody.transform.up * appliedForce) * gravityForceOffsetPercent);
        }
    }

    public override void HitBlackHole()
    {
        // CORE HIT THE BLACK HOLE
        // Grow the blackhole.
        _currentBlackHoleManager.Grow();

        // Destroy the Core.
        Destroy(gameObject);        
        base.HitBlackHole();
    }
}
