using NBF;
using UnityEngine;

public class FFeeder : FPlayerGear
{
	[HideInInspector]
	public Rigidbody rigidbody;

	[HideInInspector]
	public FWaterDisplacement waterDisplacement;

	public ParticleSystem smuuggeParticle;

	[HideInInspector]
	public FRod currentRod;

	protected override void OnStart()
	{
		rigidbody = GetComponent<Rigidbody>();
		waterDisplacement = GetComponent<FWaterDisplacement>();
	}

	protected override void OnUpdate()
	{
		ShowWaterFX();
		if ((bool)currentRod)
		{
			if ((bool)currentRod.currentFish)
			{
				waterDisplacement.isFreeze = true;
			}
			else
			{
				waterDisplacement.isFreeze = false;
			}
		}
	}

	private void ShowWaterFX()
	{
		if (smuuggeParticle == null)
		{
			return;
		}
		if (waterDisplacement.waterHeightPosition - 0.1f <= transform.position.y && waterDisplacement.waterHeightPosition + 0.1f > transform.position.y)
		{
			if (!smuuggeParticle.isEmitting)
			{
				smuuggeParticle.Play();
			}
		}
		else if (smuuggeParticle.isPlaying)
		{
			smuuggeParticle.Stop();
		}
	}
}
