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(); base.OnStart(); fish = transform.GetComponent(); nextDirectionChange = 0f; plant = target.Value.GetComponent(); 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(); if ((bool)component) { return false; } return false; } private void SelectRandDirection() { if (target.Value == null) { Debug.Log("no target"); return; } Collider component = target.Value.GetComponent(); if ((bool)component) { Vector3 normalized = (selectedPoint - fish.transform.position).normalized; fish.targetDirection = normalized; } else { Debug.Log("no collider in plant obj"); } } }