Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/FishCheckDirectionPlant.cs
2026-02-21 16:45:37 +08:00

75 lines
1.3 KiB
C#

using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
using UnityEngine;
public class FishCheckDirectionPlant : Action
{
private Fish fish;
private float nextDirectionChange;
public SharedGameObject target;
private Vector3 selectedPoint;
private WaterPlant plant;
[HideInInspector]
public new Transform transform;
public override void OnStart()
{
transform = GetComponent<Transform>();
base.OnStart();
fish = transform.GetComponent<Fish>();
nextDirectionChange = 0f;
plant = target.Value.GetComponent<WaterPlant>();
plant.occupyingFish = fish;
}
public override void OnEnd()
{
plant.occupyingFish = null;
plant = null;
base.OnEnd();
}
public override TaskStatus OnUpdate()
{
return TaskStatus.Running;
}
private bool IsInTrigger()
{
if (target.Value == null)
{
return false;
}
Collider component = target.Value.GetComponent<Collider>();
if ((bool)component)
{
return false;
}
return false;
}
private void SelectRandDirection()
{
if (target.Value == null)
{
Debug.Log("no target");
return;
}
Collider component = target.Value.GetComponent<Collider>();
if ((bool)component)
{
Vector3 normalized = (selectedPoint - fish.transform.position).normalized;
fish.targetDirection = normalized;
}
else
{
Debug.Log("no collider in plant obj");
}
}
}