BehaveResult Tick(Tree sender) { if (spawnPosition == Vector3.zero) { return(BehaveResult.Failure); } if (!Enemy.IsNullOrInvalid(attackEnemy)) { return(BehaveResult.Success); } float d = 0.0f; if (gravity > PETools.PEMath.Epsilon) { d = PEUtil.SqrMagnitudeH(position, spawnPosition); } else { d = PEUtil.SqrMagnitude(position, spawnPosition); } if (d > 1f * 1f) { if (Stucking(3.0f)) { SetPosition(spawnPosition); } else { MoveToPosition(spawnPosition, SpeedState.Run); } return(BehaveResult.Running); } else { MoveToPosition(Vector3.zero); if (PEUtil.AngleH(transform.forward, spawnForward) > 5.0f) { FaceDirection(spawnForward); return(BehaveResult.Running); } else { FaceDirection(Vector3.zero); return(BehaveResult.Success); } } }